• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1cmake_policy(SET CMP0048 NEW)
2project(gfx-streaming-kit)
3cmake_minimum_required(VERSION 3.18)
4
5option(BUILD_ASAN_WIN32 "Build with ASAN on Windows platform" OFF)
6
7if (WIN32)
8    add_definitions("-DUNICODE -D_UNICODE -DNOMINMAX -DEMUGL_BUILD -DVK_USE_PLATFORM_WIN32_KHR -DBUILDING_EMUGL_COMMON_SHARED")
9
10    option(RECORDER_DELEGATE_LIB "Use recorder_delegate_lib dll" OFF)
11    if(RECORDER_DELEGATE_LIB)
12        add_definitions(-DRECORDER_DELEGATE_LIB)
13    endif()
14endif()
15
16option(VIRGL_RENDERER_UNSTABLE_APIS "Use unstable virglrenderer APIs" OFF)
17if(VIRGL_RENDERER_UNSTABLE_APIS)
18    add_definitions(-DVIRGL_RENDERER_UNSTABLE_APIS)
19endif()
20
21if(UNIX AND NOT APPLE)
22    set(LINUX TRUE)
23endif()
24
25find_package(Threads)
26include(ExternalProject)
27
28include(GoogleTest)
29enable_testing()
30# Disable test discovery after build.
31# By default, `gtest_discover_tests()` adds a post-build step to run the test executables in order to discover the test
32# targets. This is problematic in some build environments. (for example: if cross-compiling)
33set(CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE "PRE_TEST")
34
35# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
36set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
37set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
38set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/distribution)
39if (WIN32)
40    SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
41else()
42    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3")
43endif()
44set(CMAKE_POSITION_INDEPENDENT_CODE ON)
45set(CMAKE_CXX_STANDARD 17)
46set(CMAKE_C_STANDARD 11)
47
48if (APPLE)
49    add_compile_definitions(VK_USE_PLATFORM_MACOS_MVK)
50elseif(UNIX)
51    # TODO(kaiyili, b/179477624): Add Linux specific Vulkan platform macro definitions
52elseif(WIN32)
53    add_compile_definitions(VK_USE_PLATFORM_WIN32_KHR)
54endif()
55
56add_compile_definitions(GLM_FORCE_RADIANS)
57add_compile_definitions(GLM_FORCE_DEFAULT_ALIGNED_GENTYPES)
58
59if (MSVC)
60    # ask msvc not to warn not secure C ISO functions
61    add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
62    # ask msvc not to warn non C ISO POSIX functions
63    add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE)
64endif()
65
66# Macro to easily set the TEST_INCLUDE_FILES properties to point to `test_properties.cmake`
67# This macro should be called at the end of any CMakeLists.txt file that defines test targets.
68macro("set_test_include_files")
69set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES ${CMAKE_SOURCE_DIR}/test_properties.cmake)
70endmacro()
71
72# Uncomment for ASAN support
73# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
74# set (CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
75
76if (WIN32)
77    if (BUILD_ASAN_WIN32)
78        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
79        # ASAN does not work with flag /MDd, replace it with /MD
80        string(REPLACE "/MDd" "/MD" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
81        set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
82
83        # ASAN linker
84        # User needs to use -D ASAN_LIB_DIR:STRING=/path/to/asan_libs to add library directory
85        if (NOT DEFINED ASAN_LIB_DIR)
86            message(FATAL_ERROR "Please input ASAN library path with -D ASAN_LIB_DIR:STRING=/path/to/asan_lib_dir")
87        endif()
88        link_libraries(clang_rt.asan_dynamic-x86_64.lib clang_rt.asan_dynamic_runtime_thunk-x86_64.lib)
89        message("Linking ASAN libraries from: ${ASAN_LIB_DIR}")
90        link_directories(${ASAN_LIB_DIR})
91    endif()
92endif()
93
94set(GFXSTREAM_REPO_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
95
96include(android.cmake)
97
98# Third party dependencies
99add_subdirectory(third-party)
100
101# Common base libraries for host################################################
102
103add_subdirectory(base)
104add_subdirectory(snapshot)
105add_subdirectory(host-common)
106
107# Backends######################################################################
108
109add_subdirectory(stream-servers)
110
111# Protocols and associated code generators######################################
112
113add_subdirectory(protocols)
114
115# Fake Android guest#########################3##################################
116
117if (NOT WIN32)
118    add_subdirectory(fake-android-guest)
119endif()
120