1if (WIN32) 2endif() 3 4add_library(aemu-base.headers INTERFACE) 5# TODO: Remove this once host-common/logging.h is moved into base. 6target_link_libraries(aemu-base.headers INTERFACE aemu-host-common.headers) 7target_include_directories(aemu-base.headers INTERFACE include) 8 9if(WIN32) 10 target_compile_definitions(aemu-base.headers INTERFACE WIN32_LEAN_AND_MEAN) 11endif() 12 13if(ENABLE_CLANG_THREAD_SAFETY_CHECKS) 14 target_compile_definitions(aemu-base.headers INTERFACE -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) 15 target_compile_options(aemu-base.headers INTERFACE -Wthread-safety) 16endif() 17 18if (BUILD_STANDALONE) 19 if (NOT DEFINED aemu-base-srcs) 20 # Build everything by default 21 set(aemu-base-srcs 22 AlignedBuf.cpp 23 CLog.cpp 24 CpuTime.cpp 25 FileUtils.cpp 26 FunctorThread.cpp 27 GLObjectCounter.cpp 28 GraphicsObjectCounter.cpp 29 HealthMonitor.cpp 30 LayoutResolver.cpp 31 MemStream.cpp 32 StdioStream.cpp 33 MemoryTracker.cpp 34 MessageChannel.cpp 35 PathUtils.cpp 36 ring_buffer.cpp 37 SharedLibrary.cpp 38 StringFormat.cpp 39 Stream.cpp 40 StreamSerializing.cpp 41 SubAllocator.cpp 42 System.cpp 43 Tracing.cpp) 44 set(aemu-base-posix-srcs 45 SharedMemory_posix.cpp 46 Thread_pthread.cpp) 47 set(aemu-base-windows-srcs 48 msvc.cpp 49 SharedMemory_win32.cpp 50 Thread_win32.cpp 51 Win32UnicodeString.cpp) 52 if(AEMU_BASE_USE_LZ4) 53 list(APPEND aemu-base-srcs CompressingStream.cpp DecompressingStream.cpp) 54 endif() 55 56 if (APPLE) 57 set(aemu-platform-srcs 58 ${aemu-base-posix-srcs} 59 system-native-mac.mm) 60 elseif (WIN32) 61 set(aemu-platform-srcs 62 ${aemu-base-windows-srcs}) 63 else() 64 set(aemu-platform-srcs 65 ${aemu-base-posix-srcs}) 66 endif() 67 68 set(aemu-base-srcs ${aemu-base-srcs} ${aemu-platform-srcs}) 69 endif() 70 71 add_library(aemu-base ${aemu-base-srcs}) 72 if (BUILD_SHARED_LIBS) 73 set_target_properties( 74 aemu-base 75 PROPERTIES 76 VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} 77 SOVERSION ${VERSION_MAJOR}) 78 endif() 79 80 target_compile_definitions(aemu-base PRIVATE) 81 82 if (WIN32) 83 set(aemu-base-platform-deps Shlwapi) 84 elseif (QNX) 85 set(aemu-base-platform-deps dl) 86 elseif(LINUX) 87 set(aemu-base-platform-deps dl rt) 88 elseif(APPLE) 89 set(aemu-base-platform-deps "-framework Foundation" "-framework AppKit" "-framework IOKit") 90 endif() 91 92 target_link_libraries( 93 aemu-base 94 PUBLIC 95 aemu-base.headers 96 # TODO(joshuaduong): Remove this when logging.h is moved into base 97 aemu-host-common.headers 98 PRIVATE 99 ${LOGGING_LIB_NAME} 100 ${aemu-base-platform-deps}) 101 102 target_include_directories( 103 aemu-base 104 PRIVATE 105 ${AEMU_COMMON_REPO_ROOT}/include 106 PUBLIC 107 ${AEMU_COMMON_REPO_ROOT}) 108 if (NOT MSVC) 109 target_compile_options( 110 aemu-base PRIVATE -fvisibility=default) 111 endif() 112 if(AEMU_COMMON_USE_PERFETTO) 113 target_compile_definitions(aemu-base PRIVATE "USE_PERFETTO_TRACING") 114 target_link_libraries(aemu-base PRIVATE perfetto-tracing-only) 115 endif() 116 if(AEMU_BASE_USE_LZ4) 117 target_link_libraries(aemu-base PRIVATE lz4_static) 118 endif() 119endif() 120 121if (APPLE) 122 set(aemu-base-platform-test-srcs "") 123elseif (WIN32) 124 set(aemu-base-platform-test-srcs Win32UnicodeString_unittest.cpp) 125else() 126 set(aemu-base-platform-test-srcs "") 127endif() 128 129if (ENABLE_VKCEREAL_TESTS) 130 # Tests 131 add_library( 132 aemu-base-testing-support 133 testing/file_io.cpp) 134 target_link_libraries( 135 aemu-base-testing-support 136 PRIVATE 137 aemu-base.headers 138 gtest 139 gmock) 140 141 if (NOT DEFINED aemu-base-test-srcs) 142 set(aemu-base-test-srcs 143 AlignedBuf_unittest.cpp 144 HealthMonitor_unittest.cpp 145 ArraySize_unittest.cpp 146 LayoutResolver_unittest.cpp 147 LruCache_unittest.cpp 148 ManagedDescriptor_unittest.cpp 149 Optional_unittest.cpp 150 ring_buffer_unittest.cpp 151 StringFormat_unittest.cpp 152 SubAllocator_unittest.cpp 153 TypeTraits_unittest.cpp 154 WorkerThread_unittest.cpp 155 HybridEntityManager_unittest.cpp) 156 endif() 157 add_executable(aemu-base_unittests ${aemu-base-test-srcs}) 158 target_link_libraries( 159 aemu-base_unittests 160 PRIVATE 161 aemu-base.headers 162 ${GFXSTREAM_BASE_LIB} 163 ${LOGGING_LIB_NAME} 164 aemu-base-testing-support 165 gmock 166 gtest_main) 167 gtest_discover_tests(aemu-base_unittests) 168endif() 169