CMakeLists.txt 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. # SPDX-FileCopyrightText: 2018 yuzu Emulator Project
  2. # SPDX-FileCopyrightText: 2024 suyu Emulator Project
  3. # SPDX-License-Identifier: GPL-2.0-or-later
  4. if (DEFINED ENV{AZURECIREPO})
  5. set(BUILD_REPOSITORY $ENV{AZURECIREPO})
  6. endif()
  7. if (DEFINED ENV{TITLEBARFORMATIDLE})
  8. set(TITLE_BAR_FORMAT_IDLE $ENV{TITLEBARFORMATIDLE})
  9. endif ()
  10. if (DEFINED ENV{TITLEBARFORMATRUNNING})
  11. set(TITLE_BAR_FORMAT_RUNNING $ENV{TITLEBARFORMATRUNNING})
  12. endif ()
  13. if (DEFINED ENV{DISPLAYVERSION})
  14. set(DISPLAY_VERSION $ENV{DISPLAYVERSION})
  15. endif ()
  16. include(GenerateSCMRev)
  17. add_library(common STATIC
  18. address_space.cpp
  19. address_space.h
  20. algorithm.h
  21. alignment.h
  22. announce_multiplayer_room.h
  23. assert.cpp
  24. assert.h
  25. atomic_helpers.h
  26. atomic_ops.h
  27. bit_cast.h
  28. bit_field.h
  29. bit_set.h
  30. bit_util.h
  31. bounded_threadsafe_queue.h
  32. cityhash.cpp
  33. cityhash.h
  34. common_funcs.h
  35. common_precompiled_headers.h
  36. common_types.h
  37. concepts.h
  38. container_hash.h
  39. demangle.cpp
  40. demangle.h
  41. detached_tasks.cpp
  42. detached_tasks.h
  43. div_ceil.h
  44. dynamic_library.cpp
  45. dynamic_library.h
  46. elf.h
  47. error.cpp
  48. error.h
  49. expected.h
  50. fiber.cpp
  51. fiber.h
  52. fixed_point.h
  53. free_region_manager.h
  54. fs/file.cpp
  55. fs/file.h
  56. fs/fs.cpp
  57. fs/fs.h
  58. fs/fs_paths.h
  59. fs/fs_types.h
  60. fs/fs_util.cpp
  61. fs/fs_util.h
  62. fs/path_util.cpp
  63. fs/path_util.h
  64. hash.h
  65. heap_tracker.cpp
  66. heap_tracker.h
  67. hex_util.cpp
  68. hex_util.h
  69. host_memory.cpp
  70. host_memory.h
  71. input.h
  72. intrusive_red_black_tree.h
  73. literals.h
  74. logging/backend.cpp
  75. logging/backend.h
  76. logging/filter.cpp
  77. logging/filter.h
  78. logging/formatter.h
  79. logging/log.h
  80. logging/log_entry.h
  81. logging/text_formatter.cpp
  82. logging/text_formatter.h
  83. logging/types.h
  84. lz4_compression.cpp
  85. lz4_compression.h
  86. make_unique_for_overwrite.h
  87. math_util.h
  88. memory_detect.cpp
  89. memory_detect.h
  90. microprofile.cpp
  91. microprofile.h
  92. microprofileui.h
  93. multi_level_page_table.cpp
  94. multi_level_page_table.h
  95. nvidia_flags.cpp
  96. nvidia_flags.h
  97. overflow.h
  98. page_table.cpp
  99. page_table.h
  100. param_package.cpp
  101. param_package.h
  102. parent_of_member.h
  103. point.h
  104. precompiled_headers.h
  105. quaternion.h
  106. range_map.h
  107. range_mutex.h
  108. range_sets.h
  109. range_sets.inc
  110. reader_writer_queue.h
  111. ring_buffer.h
  112. ${CMAKE_CURRENT_BINARY_DIR}/scm_rev.cpp
  113. scm_rev.h
  114. scope_exit.h
  115. scratch_buffer.h
  116. settings.cpp
  117. settings.h
  118. settings_common.cpp
  119. settings_common.h
  120. settings_enums.h
  121. settings_input.cpp
  122. settings_input.h
  123. settings_setting.h
  124. slot_vector.h
  125. socket_types.h
  126. spin_lock.cpp
  127. spin_lock.h
  128. stb.cpp
  129. stb.h
  130. steady_clock.cpp
  131. steady_clock.h
  132. stream.cpp
  133. stream.h
  134. string_util.cpp
  135. string_util.h
  136. swap.h
  137. thread.cpp
  138. thread.h
  139. thread_queue_list.h
  140. thread_worker.h
  141. threadsafe_queue.h
  142. time_zone.cpp
  143. time_zone.h
  144. tiny_mt.h
  145. tree.h
  146. typed_address.h
  147. uint128.h
  148. unique_function.h
  149. uuid.cpp
  150. uuid.h
  151. vector_math.h
  152. virtual_buffer.cpp
  153. virtual_buffer.h
  154. wall_clock.cpp
  155. wall_clock.h
  156. zstd_compression.cpp
  157. zstd_compression.h
  158. )
  159. if (SUYU_ENABLE_PORTABLE)
  160. add_compile_definitions(SUYU_ENABLE_PORTABLE)
  161. endif()
  162. if (WIN32)
  163. target_sources(common PRIVATE
  164. windows/timer_resolution.cpp
  165. windows/timer_resolution.h
  166. )
  167. target_link_libraries(common PRIVATE ntdll)
  168. endif()
  169. if (NOT WIN32)
  170. target_sources(common PRIVATE
  171. signal_chain.cpp
  172. signal_chain.h
  173. )
  174. endif()
  175. if(ANDROID)
  176. target_sources(common
  177. PUBLIC
  178. fs/fs_android.cpp
  179. fs/fs_android.h
  180. android/android_common.cpp
  181. android/android_common.h
  182. android/id_cache.cpp
  183. android/id_cache.h
  184. android/applets/software_keyboard.cpp
  185. android/applets/software_keyboard.h
  186. )
  187. endif()
  188. if (UNIX AND NOT APPLE)
  189. target_sources(common PRIVATE
  190. linux/gamemode.cpp
  191. linux/gamemode.h
  192. )
  193. target_link_libraries(common PRIVATE gamemode::headers)
  194. endif()
  195. if(ARCHITECTURE_x86_64)
  196. target_sources(common
  197. PRIVATE
  198. x64/cpu_detect.cpp
  199. x64/cpu_detect.h
  200. x64/cpu_wait.cpp
  201. x64/cpu_wait.h
  202. x64/native_clock.cpp
  203. x64/native_clock.h
  204. x64/rdtsc.cpp
  205. x64/rdtsc.h
  206. x64/xbyak_abi.h
  207. x64/xbyak_util.h
  208. )
  209. target_link_libraries(common PRIVATE xbyak::xbyak)
  210. endif()
  211. if (HAS_NCE)
  212. target_sources(common
  213. PRIVATE
  214. arm64/native_clock.cpp
  215. arm64/native_clock.h
  216. )
  217. endif()
  218. if (MSVC)
  219. target_compile_definitions(common PRIVATE
  220. # The standard library doesn't provide any replacement for codecvt yet
  221. # so we can disable this deprecation warning for the time being.
  222. _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
  223. )
  224. target_compile_options(common PRIVATE
  225. /we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data
  226. /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
  227. /we4800 # Implicit conversion from 'type' to bool. Possible information loss
  228. )
  229. else()
  230. set_source_files_properties(stb.cpp PROPERTIES COMPILE_OPTIONS "-Wno-implicit-fallthrough;-Wno-missing-declarations;-Wno-missing-field-initializers")
  231. # Get around GCC failing with intrinsics in Debug
  232. if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_BUILD_TYPE MATCHES "Debug")
  233. set_property(
  234. SOURCE stb.cpp
  235. APPEND
  236. PROPERTY COMPILE_OPTIONS ";-O2"
  237. )
  238. endif()
  239. endif()
  240. if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  241. target_compile_options(common PRIVATE
  242. -fsized-deallocation
  243. -Werror=unreachable-code-aggressive
  244. )
  245. target_compile_definitions(common PRIVATE
  246. # Clang 14 and earlier have errors when explicitly instantiating Settings::Setting
  247. $<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,15>:CANNOT_EXPLICITLY_INSTANTIATE>
  248. )
  249. endif()
  250. target_link_libraries(common PUBLIC Boost::context Boost::headers fmt::fmt microprofile stb::headers Threads::Threads)
  251. target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd LLVM::Demangle)
  252. if (ANDROID)
  253. # For ASharedMemory_create
  254. target_link_libraries(common PRIVATE android)
  255. endif()
  256. if (SUYU_USE_PRECOMPILED_HEADERS)
  257. target_precompile_headers(common PRIVATE precompiled_headers.h)
  258. endif()
  259. create_target_directory_groups(common)