CMakeLists.txt 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. add_library(common
  2. Analytics.cpp
  3. Analytics.h
  4. Assembler/AssemblerShared.cpp
  5. Assembler/AssemblerShared.h
  6. Assembler/AssemblerTables.cpp
  7. Assembler/AssemblerTables.h
  8. Assembler/GekkoAssembler.cpp
  9. Assembler/GekkoAssembler.h
  10. Assembler/GekkoIRGen.cpp
  11. Assembler/GekkoIRGen.h
  12. Assembler/GekkoLexer.cpp
  13. Assembler/GekkoLexer.h
  14. Assembler/GekkoParser.cpp
  15. Assembler/GekkoParser.h
  16. Assert.h
  17. BitField.h
  18. BitSet.h
  19. BitUtils.h
  20. BlockingLoop.h
  21. ChunkFile.h
  22. CodeBlock.h
  23. ColorUtil.cpp
  24. ColorUtil.h
  25. Common.h
  26. CommonFuncs.cpp
  27. CommonFuncs.h
  28. CommonPaths.h
  29. CommonTypes.h
  30. Config/Config.cpp
  31. Config/Config.h
  32. Config/ConfigInfo.cpp
  33. Config/ConfigInfo.h
  34. Config/Enums.h
  35. Config/Layer.cpp
  36. Config/Layer.h
  37. Contains.h
  38. CPUDetect.h
  39. Crypto/AES.cpp
  40. Crypto/AES.h
  41. Crypto/bn.cpp
  42. Crypto/bn.h
  43. Crypto/ec.cpp
  44. Crypto/ec.h
  45. Crypto/HMAC.cpp
  46. Crypto/HMAC.h
  47. Crypto/SHA1.cpp
  48. Crypto/SHA1.h
  49. Debug/MemoryPatches.cpp
  50. Debug/MemoryPatches.h
  51. Debug/Threads.h
  52. Debug/Watches.cpp
  53. Debug/Watches.h
  54. DynamicLibrary.cpp
  55. DynamicLibrary.h
  56. ENet.cpp
  57. ENet.h
  58. EnumFormatter.h
  59. EnumMap.h
  60. EnumUtils.h
  61. Event.h
  62. FatFsUtil.cpp
  63. FatFsUtil.h
  64. FileSearch.cpp
  65. FileSearch.h
  66. FileUtil.cpp
  67. FileUtil.h
  68. FixedSizeQueue.h
  69. Flag.h
  70. FloatUtils.cpp
  71. FloatUtils.h
  72. FormatUtil.h
  73. FPURoundMode.h
  74. GekkoDisassembler.cpp
  75. GekkoDisassembler.h
  76. Hash.cpp
  77. Hash.h
  78. HookableEvent.h
  79. HostDisassembler.cpp
  80. HostDisassembler.h
  81. HttpRequest.cpp
  82. HttpRequest.h
  83. Image.cpp
  84. Image.h
  85. IniFile.cpp
  86. IniFile.h
  87. Inline.h
  88. IOFile.cpp
  89. IOFile.h
  90. JitRegister.cpp
  91. JitRegister.h
  92. JsonUtil.h
  93. JsonUtil.cpp
  94. Lazy.h
  95. LinearDiskCache.h
  96. Logging/ConsoleListener.h
  97. Logging/Log.h
  98. Logging/LogManager.cpp
  99. Logging/LogManager.h
  100. MathUtil.h
  101. Matrix.cpp
  102. Matrix.h
  103. MemArena.h
  104. MemoryUtil.cpp
  105. MemoryUtil.h
  106. MinizipUtil.h
  107. MsgHandler.cpp
  108. MsgHandler.h
  109. NandPaths.cpp
  110. NandPaths.h
  111. Network.cpp
  112. Network.h
  113. PcapFile.cpp
  114. PcapFile.h
  115. Profiler.cpp
  116. Profiler.h
  117. QoSSession.cpp
  118. QoSSession.h
  119. Random.cpp
  120. Random.h
  121. Result.h
  122. ScopeGuard.h
  123. SDCardUtil.cpp
  124. SDCardUtil.h
  125. Semaphore.h
  126. SettingsHandler.cpp
  127. SettingsHandler.h
  128. SFMLHelper.cpp
  129. SFMLHelper.h
  130. SmallVector.h
  131. SocketContext.cpp
  132. SocketContext.h
  133. SpanUtils.h
  134. SPSCQueue.h
  135. StringLiteral.h
  136. StringUtil.cpp
  137. StringUtil.h
  138. SymbolDB.cpp
  139. SymbolDB.h
  140. Thread.cpp
  141. Thread.h
  142. Timer.cpp
  143. Timer.h
  144. TimeUtil.cpp
  145. TimeUtil.h
  146. TraversalClient.cpp
  147. TraversalClient.h
  148. TraversalProto.h
  149. TypeUtils.h
  150. Unreachable.h
  151. UPnP.cpp
  152. UPnP.h
  153. VariantUtil.h
  154. Version.cpp
  155. Version.h
  156. WindowSystemInfo.h
  157. WorkQueueThread.h
  158. )
  159. add_dependencies(common dolphin_scmrev)
  160. if(NOT MSVC AND _M_ARM_64)
  161. set_source_files_properties(
  162. Crypto/AES.cpp
  163. Crypto/SHA1.cpp
  164. PROPERTIES COMPILE_FLAGS "-march=armv8-a+crypto")
  165. endif()
  166. target_link_libraries(common
  167. PUBLIC
  168. ${CMAKE_THREAD_LIBS_INIT}
  169. enet::enet
  170. fmt::fmt
  171. MbedTLS::mbedtls
  172. minizip::minizip
  173. sfml-network
  174. PRIVATE
  175. CURL::libcurl
  176. FatFs
  177. Iconv::Iconv
  178. spng::spng
  179. ${VTUNE_LIBRARIES}
  180. )
  181. if ((DEFINED CMAKE_ANDROID_ARCH_ABI AND CMAKE_ANDROID_ARCH_ABI MATCHES "x86|x86_64") OR
  182. (NOT DEFINED CMAKE_ANDROID_ARCH_ABI AND _M_X86_64))
  183. target_link_libraries(common PRIVATE bdisasm)
  184. endif()
  185. if (APPLE)
  186. target_link_libraries(common
  187. PRIVATE
  188. ${APPKIT_LIBRARY}
  189. ${COREFOUNDATION_LIBRARY}
  190. ${IOK_LIBRARY}
  191. )
  192. elseif(WIN32)
  193. target_link_libraries(common
  194. PRIVATE
  195. kernel32.lib
  196. shlwapi.lib
  197. winmm.lib
  198. )
  199. if (_M_X86_64)
  200. target_link_libraries(common PRIVATE opengl32.lib)
  201. endif()
  202. elseif (ANDROID)
  203. target_link_libraries(common
  204. PRIVATE
  205. androidcommon
  206. )
  207. elseif(HAIKU)
  208. target_link_libraries(common PRIVATE be GL)
  209. endif()
  210. if(ANDROID)
  211. target_sources(common PRIVATE
  212. AndroidAnalytics.cpp
  213. AndroidAnalytics.h
  214. Logging/ConsoleListenerDroid.cpp
  215. MemArenaAndroid.cpp
  216. )
  217. elseif(WIN32)
  218. target_sources(common PRIVATE
  219. LdrWatcher.cpp
  220. LdrWatcher.h
  221. Logging/ConsoleListenerWin.cpp
  222. MemArenaWin.cpp
  223. )
  224. elseif(APPLE)
  225. target_sources(common PRIVATE
  226. Logging/ConsoleListenerNix.cpp
  227. MemArenaDarwin.cpp
  228. )
  229. else()
  230. target_sources(common PRIVATE
  231. Logging/ConsoleListenerNix.cpp
  232. MemArenaUnix.cpp
  233. )
  234. endif()
  235. if(_M_ARM_64)
  236. target_sources(common PRIVATE
  237. Arm64Emitter.cpp
  238. Arm64Emitter.h
  239. ArmCommon.h
  240. ArmCPUDetect.cpp
  241. ArmFPURoundMode.cpp
  242. )
  243. else()
  244. if(_M_X86_64) #X86
  245. target_sources(common PRIVATE
  246. x64ABI.cpp
  247. x64ABI.h
  248. x64Emitter.cpp
  249. x64Emitter.h
  250. x64FPURoundMode.cpp
  251. x64CPUDetect.cpp
  252. x64Reg.h
  253. )
  254. else() # Generic
  255. target_sources(common PRIVATE
  256. GenericFPURoundMode.cpp
  257. GenericCPUDetect.cpp
  258. )
  259. endif()
  260. endif()
  261. # OpenGL Interface
  262. target_sources(common PRIVATE
  263. GL/GLContext.cpp
  264. GL/GLContext.h
  265. GL/GLUtil.cpp
  266. GL/GLUtil.h
  267. GL/GLExtensions/GLExtensions.cpp
  268. GL/GLExtensions/GLExtensions.h
  269. )
  270. if(ENABLE_EGL AND EGL_FOUND)
  271. target_sources(common PRIVATE
  272. GL/GLInterface/EGL.cpp
  273. GL/GLInterface/EGL.h
  274. )
  275. if(ANDROID)
  276. target_sources(common PRIVATE
  277. GL/GLInterface/EGLAndroid.cpp
  278. GL/GLInterface/EGLAndroid.h
  279. )
  280. elseif(ENABLE_X11 AND X11_FOUND)
  281. target_sources(common PRIVATE
  282. GL/GLInterface/EGLX11.cpp
  283. GL/GLInterface/EGLX11.h
  284. )
  285. endif()
  286. target_include_directories(common PRIVATE ${EGL_INCLUDE_DIRS})
  287. target_link_libraries(common PUBLIC ${EGL_LIBRARIES})
  288. endif()
  289. if(WIN32)
  290. target_sources(common PRIVATE
  291. CompatPatches.cpp
  292. GL/GLInterface/WGL.cpp
  293. GL/GLInterface/WGL.h
  294. WindowsRegistry.cpp
  295. )
  296. elseif(APPLE)
  297. target_sources(common PRIVATE
  298. GL/GLInterface/AGL.h
  299. GL/GLInterface/AGL.mm
  300. )
  301. elseif(HAIKU)
  302. target_sources(common PRIVATE
  303. GL/GLInterface/BGL.h
  304. GL/GLInterface/BGL.cpp
  305. )
  306. elseif(ENABLE_X11 AND X11_FOUND)
  307. target_sources(common PRIVATE
  308. GL/GLX11Window.cpp
  309. GL/GLX11Window.h
  310. GL/GLInterface/GLX.cpp
  311. GL/GLInterface/GLX.h
  312. )
  313. # GLX has a hard dependency on libGL.
  314. # Make sure to link to it if using GLX.
  315. target_link_libraries(common PUBLIC ${OPENGL_LIBRARIES})
  316. endif()
  317. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  318. target_link_libraries(common PUBLIC dl rt)
  319. endif()
  320. if(WIN32)
  321. target_sources(common PRIVATE HRWrap.h HRWrap.cpp)
  322. endif()
  323. if(USE_UPNP)
  324. target_link_libraries(common PRIVATE Miniupnpc::miniupnpc)
  325. endif()
  326. if(OPROFILE_FOUND)
  327. target_link_libraries(common PRIVATE OProfile::OProfile)
  328. endif()
  329. if(ENABLE_LLVM)
  330. find_package(LLVM CONFIG)
  331. if(LLVM_FOUND)
  332. message(STATUS "LLVM found, enabling LLVM support in disassembler")
  333. target_compile_definitions(common PRIVATE HAVE_LLVM)
  334. # Minimal documentation about LLVM's CMake functions is available here:
  335. # https://releases.llvm.org/16.0.0/docs/CMake.html#embedding-llvm-in-your-project
  336. # https://groups.google.com/g/llvm-dev/c/YeEVe7HTasQ?pli=1
  337. #
  338. # However, you have to read the source code in any case.
  339. # Look for LLVM-Config.cmake in your (Unix) system:
  340. # $ find /usr -name LLVM-Config\\.cmake 2>/dev/null
  341. llvm_expand_pseudo_components(LLVM_EXPAND_COMPONENTS
  342. AllTargetsInfos AllTargetsDisassemblers AllTargetsCodeGens
  343. )
  344. llvm_config(common USE_SHARED
  345. mcdisassembler target ${LLVM_EXPAND_COMPONENTS}
  346. )
  347. target_include_directories(common PRIVATE ${LLVM_INCLUDE_DIRS})
  348. endif()
  349. endif()
  350. if(UNIX)
  351. # Posix networking code needs to be fixed for Windows
  352. add_executable(traversal_server TraversalServer.cpp)
  353. target_link_libraries(traversal_server PRIVATE common fmt::fmt)
  354. if(SYSTEMD_FOUND)
  355. target_link_libraries(traversal_server PRIVATE ${SYSTEMD_LIBRARIES})
  356. endif()
  357. elseif(WIN32)
  358. find_package(PowerShell REQUIRED)
  359. execute_process(
  360. COMMAND ${POWERSHELL_EXE} -Command "[System.Diagnostics.FileVersionInfo]::GetVersionInfo('$ENV{VCToolsRedistDir}vc_redist.x64.exe').ProductVersion"
  361. OUTPUT_VARIABLE VC_TOOLS_VERSION
  362. OUTPUT_STRIP_TRAILING_WHITESPACE
  363. )
  364. configure_file(
  365. "${CMAKE_CURRENT_SOURCE_DIR}/build_info.txt.in"
  366. "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/build_info.txt"
  367. )
  368. target_link_libraries(common PRIVATE "-INCLUDE:enableCompatPatches")
  369. endif()
  370. if(MSVC)
  371. # Add precompiled header
  372. target_link_libraries(common PRIVATE use_pch)
  373. endif()