1# Configure and add `astc-encoder`, if needed 2if (ASTC_CPU_DECODING) 3 set(DECOMPRESSOR ON) # Disable compression code 4 set(CLI OFF) # Disable the command line interface 5 6 # Compile with the AVX2 instruction set. This is the fastest option available on x86_64. 7 # At run time, if the CPU doesn't support AVX2, the library will simply return an error status 8 # during initialization and we will fall back on the compute shader to decompress ASTC textures. 9 # 10 # In the future, we should define `ASTCENC_DYNAMIC_LIBRARY` and build multiple versions of the 11 # library for each SIMD architecture, and dynamically load the fastest one at run time. 12 # See also: https://github.com/ARM-software/astc-encoder/issues/79 13 set(ISA_AVX2 ON) 14 15 add_subdirectory(astc-encoder) 16endif () 17 18# Enable perfetto in CMake if needed 19# add_subdirectory(perfetto-tracing-only) 20add_subdirectory(renderdoc) 21add_subdirectory(stb) 22 23if(ENABLE_VKCEREAL_TESTS) 24 set(AEMU_BASE_USE_LZ4 ON CACHE BOOL "" FORCE) 25endif() 26 27if(NOT TARGET lz4_static AND AEMU_BASE_USE_LZ4) 28 set(BUILD_STATIC_LIBS ON CACHE BOOL "" FORCE) 29 if(DEPENDENCY_RESOLUTION STREQUAL "AOSP") 30 set(LZ4_PATH ${PROJECT_SOURCE_DIR}/../../../external/lz4/build/cmake) 31 if(EXISTS ${LZ4_PATH}) 32 add_subdirectory(${LZ4_PATH} lz4) 33 endif() 34 elseif(DEPENDENCY_RESOLUTION STREQUAL "SYSTEM") 35 find_package(PkgConfig REQUIRED) 36 pkg_search_module(lz4 REQUIRED IMPORTED_TARGET GLOBAL liblz4) 37 add_library(lz4_static ALIAS PkgConfig::lz4) 38 endif() 39endif() 40 41if(NOT TARGET gtest_main AND ENABLE_VKCEREAL_TESTS) 42 # For Windows: Prevent overriding the parent project's compiler/linker settings 43 set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 44 if(DEPENDENCY_RESOLUTION STREQUAL "AOSP") 45 set(GOOGLETEST_PATH ${PROJECT_SOURCE_DIR}/../../../external/googletest) 46 if(EXISTS ${GOOGLETEST_PATH}) 47 add_subdirectory(${GOOGLETEST_PATH} googletest) 48 endif() 49 elseif(DEPENDENCY_RESOLUTION STREQUAL "SYSTEM") 50 find_package(PkgConfig REQUIRED) 51 pkg_search_module(gtest REQUIRED IMPORTED_TARGET GLOBAL gtest) 52 pkg_search_module(gtest_main REQUIRED IMPORTED_TARGET GLOBAL gtest_main) 53 pkg_search_module(gmock REQUIRED IMPORTED_TARGET GLOBAL gmock) 54 pkg_search_module(gmock_main REQUIRED IMPORTED_TARGET GLOBAL gmock_main) 55 add_library(gtest ALIAS PkgConfig::gtest) 56 add_library(gtest_main ALIAS PkgConfig::gtest_main) 57 add_library(gmock ALIAS PkgConfig::gmock) 58 add_library(gmock_main ALIAS PkgConfig::gmock_main) 59 endif() 60endif() 61 62if(NOT TARGET aemu_common) 63 set(AEMU_COMMON_BUILD_CONFIG "gfxstream" CACHE STRING "") 64 if(DEPENDENCY_RESOLUTION STREQUAL "AOSP") 65 set(AEMU_COMMON_PATH ${PROJECT_SOURCE_DIR}/../../../hardware/google/aemu) 66 if(EXISTS ${AEMU_COMMON_PATH}) 67 add_subdirectory(${AEMU_COMMON_PATH} aemu_common) 68 endif() 69 elseif(DEPENDENCY_RESOLUTION STREQUAL "SYSTEM") 70 find_package(PkgConfig REQUIRED) 71 set(AEMU_PC_FILES 72 aemu_base 73 aemu_logging 74 aemu_host_common 75 aemu_base_testing_support 76 aemu_host_common_testing_support 77 aemu_snapshot) 78 foreach(PC_FILE IN LISTS AEMU_PC_FILES) 79 pkg_search_module(${PC_FILE} REQUIRED IMPORTED_TARGET GLOBAL ${PC_FILE}>=0.0.0) 80 endforeach() 81 82 add_library(aemu-base.headers INTERFACE) 83 target_include_directories(aemu-base.headers INTERFACE ${aemu_base_INCLUDE_DIRS}) 84 85 add_library(aemu-host-common.headers INTERFACE) 86 target_include_directories(aemu-host-common.headers INTERFACE ${aemu_host_common_INCLUDE_DIRS}) 87 target_link_libraries(aemu-host-common.headers INTERFACE renderdoc gfxstream_vulkan_headers) 88 89 add_library(gfxstream-snapshot.headers INTERFACE) 90 target_include_directories(gfxstream-snapshot.headers INTERFACE ${aemu_snapshot_INCLUDE_DIRS}) 91 add_library(gfxstream-snapshot ALIAS PkgConfig::aemu_snapshot) 92 93 add_library(logging-base INTERFACE) 94 target_link_libraries(logging-base INTERFACE PkgConfig::aemu_logging) 95 96 if (WIN32) 97 set(aemu-base-platform-deps Shlwapi) 98 else() 99 set(aemu-base-platform-deps dl rt) 100 endif() 101 add_library(aemu-base INTERFACE) 102 target_link_libraries( 103 aemu-base 104 INTERFACE 105 PkgConfig::aemu_base 106 logging-base 107 ${aemu-base-platform-deps}) 108 if(TARGET lz4_static) 109 target_link_libraries(aemu-base INTERFACE lz4_static) 110 endif() 111 if(TARGET perfetto-tracing-only) 112 target_link_libraries(aemu-base INTERFACE perfetto-tracing-only) 113 endif() 114 add_library(aemu-host-common INTERFACE) 115 target_link_libraries(aemu-host-common INTERFACE PkgConfig::aemu_host_common aemu-base) 116 117 add_library(aemu-base-testing-support INTERFACE) 118 target_link_libraries( 119 aemu-base-testing-support 120 INTERFACE 121 PkgConfig::aemu_base_testing_support 122 aemu-base 123 gmock 124 gtest) 125 126 add_library(aemu-host-common-testing-support INTERFACE) 127 target_link_libraries( 128 aemu-host-common-testing-support 129 INTERFACE 130 PkgConfig::aemu_host_common_testing_support 131 PkgConfig::aemu_host_common 132 PkgConfig::aemu_base 133 PkgConfig::aemu_logging 134 gmock 135 gtest) 136 if(TARGET lz4_static) 137 target_link_libraries(aemu-host-common-testing-support INTERFACE lz4_static) 138 endif() 139 140 if(TARGET perfetto-tracing-only) 141 target_link_libraries(aemu-host-common-testing-support INTERFACE perfetto-tracing-only) 142 endif() 143 add_library(aemu_common INTERFACE) 144 target_link_libraries(aemu_common INTERFACE aemu-base aemu-host-common) 145 target_include_directories(aemu_common INTERFACE aemu-base.headers aemu-host-common.headers) 146 endif() 147endif() 148 149if(NOT TARGET gfxstream_vulkan_headers) 150 if(DEPENDENCY_RESOLUTION STREQUAL "AOSP") 151 set(GFXSTREAM_PROTOCOLS_PATH ${PROJECT_SOURCE_DIR}/../../../external/gfxstream-protocols) 152 if(EXISTS ${GFXSTREAM_PROTOCOLS_PATH}) 153 add_subdirectory(${GFXSTREAM_PROTOCOLS_PATH} gfxstream-protocols) 154 endif() 155 elseif(DEPENDENCY_RESOLUTION STREQUAL "SYSTEM") 156 find_package(Vulkan 1.2.198 REQUIRED) 157 add_library(gfxstream_vulkan_headers INTERFACE) 158 target_include_directories(gfxstream_vulkan_headers INTERFACE ${Vulkan_INCLUDE_DIRS}) 159 target_compile_definitions(gfxstream_vulkan_headers 160 INTERFACE VK_GFXSTREAM_STRUCTURE_TYPE_EXT) 161 endif() 162endif() 163 164if(NOT TARGET flatbuffers) 165 set(FLATBUFFERS_BUILD_TESTS OFF) 166 set(FLATBUFFERS_BUILD_CPP17 ON) 167 168 if(DEPENDENCY_RESOLUTION STREQUAL "AOSP") 169 set(FLATBUFFERS_PATH ${PROJECT_SOURCE_DIR}/../../../external/flatbuffers) 170 if(EXISTS ${FLATBUFFERS_PATH}) 171 add_subdirectory(${FLATBUFFERS_PATH} flatbuffers) 172 endif() 173 elseif(DEPENDENCY_RESOLUTION STREQUAL "SYSTEM") 174 find_package(PkgConfig REQUIRED) 175 pkg_search_module(flatbuffers REQUIRED IMPORTED_TARGET GLOBAL flatbuffers>=2.0.6) 176 add_library(flatbuffers ALIAS PkgConfig::flatbuffers) 177 find_program(FLATC flatc NO_CACHE REQUIRED) 178 add_executable(flatc IMPORTED GLOBAL) 179 set_property(TARGET flatc PROPERTY IMPORTED_LOCATION ${FLATC}) 180 endif() 181endif() 182 183if (QNX) # QNX SDP provides EGL headers 184 add_library(gfxstream_egl_headers INTERFACE) 185 target_include_directories(gfxstream_egl_headers INTERFACE ${QNX_TARGET}/usr/include) 186endif() 187 188if(NOT TARGET gfxstream_egl_headers) 189 if(DEPENDENCY_RESOLUTION STREQUAL "AOSP") 190 # ANGLE provides the EGL headers for us. 191 set(ANGLE_PATH ${PROJECT_SOURCE_DIR}/../../../external/angle) 192 if(NOT EXISTS ${ANGLE_PATH}) 193 message(FATAL_ERROR "ANGLE is not found.") 194 endif() 195 add_library(gfxstream_egl_headers INTERFACE) 196 target_include_directories(gfxstream_egl_headers INTERFACE ${ANGLE_PATH}/include) 197 elseif(DEPENDENCY_RESOLUTION STREQUAL "SYSTEM") 198 find_package(PkgConfig REQUIRED) 199 pkg_search_module(egl REQUIRED IMPORTED_TARGET GLOBAL egl>=1.5) 200 add_library(gfxstream_egl_headers ALIAS PkgConfig::egl) 201endif() 202 203if(WITH_BENCHMARK) 204 # Add Google's benchmarking framework 205 set(BENCHMARK_ENABLE_EXCEPTIONS OFF) # We disable exceptions in gfxstream 206 set(BENCHMARK_ENABLE_TESTING OFF) # Don't build the unit tests for the library, to save time 207 set(BENCHMARK_ENABLE_GTEST_TESTS OFF) 208 209 if(DEPENDENCY_RESOLUTION STREQUAL "AOSP") 210 set(GOOGLE_BENCHMARK_PATH ${PROJECT_SOURCE_DIR}/../../../external/google-benchmark) 211 if(EXISTS ${GOOGLE_BENCHMARK_PATH}) 212 add_subdirectory(${GOOGLE_BENCHMARK_PATH} google-benchmark) 213 endif() 214 elseif(DEPENDENCY_RESOLUTION STREQUAL "SYSTEM") 215 message(FATAL_ERROR "Not implemented") 216endif() 217 218if(NOT TARGET libdrm_headers) 219 if(DEPENDENCY_RESOLUTION STREQUAL "AOSP") 220 set(LIBDRM_PATH ${PROJECT_SOURCE_DIR}/../../../external/libdrm) 221 if(NOT EXISTS ${LIBDRM_PATH}) 222 message(FATAL_ERROR "LIBDRM is not found.") 223 endif() 224 add_library(libdrm_headers INTERFACE) 225 target_include_directories(libdrm_headers INTERFACE ${LIBDRM_PATH}/include/drm) 226 elseif(DEPENDENCY_RESOLUTION STREQUAL "SYSTEM") 227 find_package(PkgConfig REQUIRED) 228 pkg_search_module(drm REQUIRED IMPORTED_TARGET GLOBAL libdrm) 229 add_library(libdrm_headers ALIAS PkgConfig::drm) 230endif() 231 232if(NOT TARGET aemu_common) 233 message(FATAL_ERROR "The dependency aemu_common not found") 234endif() 235if(NOT TARGET gfxstream_vulkan_headers) 236 message(FATAL_ERROR "The dependency gfxstream_vulkan_headers not found") 237endif() 238if(NOT TARGET flatbuffers) 239 message(FATAL_ERROR "The dependency flatbuffers not found.") 240endif() 241if(NOT TARGET libdrm_headers) 242 message(FATAL_ERROR "The dependency libdrm_headers not found.") 243endif() 244