CMakeLists.txt 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. if(POLICY CMP0084)
  2. # Disable trying to search for Qt3/4 if what we actually want is not found
  3. cmake_policy(SET CMP0084 NEW)
  4. endif()
  5. if (MSVC)
  6. if(_M_ARM_64)
  7. list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/Externals/Qt/Qt6.5.1/ARM64")
  8. else()
  9. list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/Externals/Qt/Qt6.5.1/x64")
  10. endif()
  11. endif()
  12. set(CMAKE_AUTOMOC ON)
  13. set(CMAKE_AUTORCC ON)
  14. find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Svg)
  15. message(STATUS "Found Qt version ${Qt6_VERSION}")
  16. set_property(TARGET Qt6::Core PROPERTY INTERFACE_COMPILE_FEATURES "")
  17. add_executable(dolphin-emu
  18. AboutDialog.cpp
  19. AboutDialog.h
  20. CheatSearchFactoryWidget.cpp
  21. CheatSearchFactoryWidget.h
  22. CheatSearchWidget.cpp
  23. CheatSearchWidget.h
  24. CheatsManager.cpp
  25. CheatsManager.h
  26. Achievements/AchievementBox.cpp
  27. Achievements/AchievementBox.h
  28. Achievements/AchievementHeaderWidget.cpp
  29. Achievements/AchievementHeaderWidget.h
  30. Achievements/AchievementLeaderboardWidget.cpp
  31. Achievements/AchievementLeaderboardWidget.h
  32. Achievements/AchievementProgressWidget.cpp
  33. Achievements/AchievementProgressWidget.h
  34. Achievements/AchievementSettingsWidget.cpp
  35. Achievements/AchievementSettingsWidget.h
  36. Achievements/AchievementsWindow.cpp
  37. Achievements/AchievementsWindow.h
  38. Config/ARCodeWidget.cpp
  39. Config/ARCodeWidget.h
  40. Config/CheatCodeEditor.cpp
  41. Config/CheatCodeEditor.h
  42. Config/CheatWarningWidget.cpp
  43. Config/CheatWarningWidget.h
  44. Config/CommonControllersWidget.cpp
  45. Config/CommonControllersWidget.h
  46. Config/ConfigControls/ConfigBool.cpp
  47. Config/ConfigControls/ConfigBool.h
  48. Config/ConfigControls/ConfigChoice.cpp
  49. Config/ConfigControls/ConfigChoice.h
  50. Config/ConfigControls/ConfigInteger.cpp
  51. Config/ConfigControls/ConfigInteger.h
  52. Config/ConfigControls/ConfigRadio.cpp
  53. Config/ConfigControls/ConfigRadio.h
  54. Config/ConfigControls/ConfigFloatSlider.cpp
  55. Config/ConfigControls/ConfigFloatSlider.h
  56. Config/ConfigControls/ConfigSlider.cpp
  57. Config/ConfigControls/ConfigSlider.h
  58. Config/ControllerInterface/ControllerInterfaceWindow.cpp
  59. Config/ControllerInterface/ControllerInterfaceWindow.h
  60. Config/ControllerInterface/DualShockUDPClientAddServerDialog.cpp
  61. Config/ControllerInterface/DualShockUDPClientAddServerDialog.h
  62. Config/ControllerInterface/DualShockUDPClientWidget.cpp
  63. Config/ControllerInterface/DualShockUDPClientWidget.h
  64. Config/ControllerInterface/ServerStringValidator.cpp
  65. Config/ControllerInterface/ServerStringValidator.h
  66. Config/ControllersWindow.cpp
  67. Config/ControllersWindow.h
  68. Config/FilesystemWidget.cpp
  69. Config/FilesystemWidget.h
  70. Config/FreeLookWidget.cpp
  71. Config/FreeLookWidget.h
  72. Config/FreeLookWindow.cpp
  73. Config/FreeLookWindow.h
  74. Config/GameConfigEdit.cpp
  75. Config/GameConfigEdit.h
  76. Config/GameConfigHighlighter.cpp
  77. Config/GameConfigHighlighter.h
  78. Config/GameConfigWidget.cpp
  79. Config/GameConfigWidget.h
  80. Config/GamecubeControllersWidget.cpp
  81. Config/GamecubeControllersWidget.h
  82. Config/GeckoCodeWidget.cpp
  83. Config/GeckoCodeWidget.h
  84. Config/Graphics/AdvancedWidget.cpp
  85. Config/Graphics/AdvancedWidget.h
  86. Config/Graphics/EnhancementsWidget.cpp
  87. Config/Graphics/EnhancementsWidget.h
  88. Config/Graphics/GeneralWidget.cpp
  89. Config/Graphics/GeneralWidget.h
  90. Config/Graphics/GraphicsWindow.cpp
  91. Config/Graphics/GraphicsWindow.h
  92. Config/Graphics/HacksWidget.cpp
  93. Config/Graphics/HacksWidget.h
  94. Config/Graphics/ColorCorrectionConfigWindow.cpp
  95. Config/Graphics/ColorCorrectionConfigWindow.h
  96. Config/Graphics/PostProcessingConfigWindow.cpp
  97. Config/Graphics/PostProcessingConfigWindow.h
  98. Config/GraphicsModListWidget.cpp
  99. Config/GraphicsModListWidget.h
  100. Config/GraphicsModWarningWidget.cpp
  101. Config/GraphicsModWarningWidget.h
  102. Config/HardcoreWarningWidget.cpp
  103. Config/HardcoreWarningWidget.h
  104. Config/InfoWidget.cpp
  105. Config/InfoWidget.h
  106. Config/LogConfigWidget.cpp
  107. Config/LogConfigWidget.h
  108. Config/LogWidget.cpp
  109. Config/LogWidget.h
  110. Config/Mapping/FreeLookGeneral.cpp
  111. Config/Mapping/FreeLookGeneral.h
  112. Config/Mapping/FreeLookRotation.cpp
  113. Config/Mapping/FreeLookRotation.h
  114. Config/Mapping/GBAPadEmu.cpp
  115. Config/Mapping/GBAPadEmu.h
  116. Config/Mapping/GCKeyboardEmu.cpp
  117. Config/Mapping/GCKeyboardEmu.h
  118. Config/Mapping/GCMicrophone.cpp
  119. Config/Mapping/GCMicrophone.h
  120. Config/Mapping/GCPadEmu.cpp
  121. Config/Mapping/GCPadEmu.h
  122. Config/Mapping/GCPadWiiUConfigDialog.cpp
  123. Config/Mapping/GCPadWiiUConfigDialog.h
  124. Config/Mapping/Hotkey3D.cpp
  125. Config/Mapping/Hotkey3D.h
  126. Config/Mapping/HotkeyControllerProfile.cpp
  127. Config/Mapping/HotkeyControllerProfile.h
  128. Config/Mapping/HotkeyDebugging.cpp
  129. Config/Mapping/HotkeyDebugging.h
  130. Config/Mapping/HotkeyGBA.cpp
  131. Config/Mapping/HotkeyGBA.h
  132. Config/Mapping/HotkeyGeneral.cpp
  133. Config/Mapping/HotkeyGeneral.h
  134. Config/Mapping/HotkeyGraphics.cpp
  135. Config/Mapping/HotkeyGraphics.h
  136. Config/Mapping/HotkeyStates.cpp
  137. Config/Mapping/HotkeyStates.h
  138. Config/Mapping/HotkeyStatesOther.cpp
  139. Config/Mapping/HotkeyStatesOther.h
  140. Config/Mapping/HotkeyTAS.cpp
  141. Config/Mapping/HotkeyTAS.h
  142. Config/Mapping/HotkeyUSBEmu.cpp
  143. Config/Mapping/HotkeyUSBEmu.h
  144. Config/Mapping/HotkeyWii.cpp
  145. Config/Mapping/HotkeyWii.h
  146. Config/Mapping/IOWindow.cpp
  147. Config/Mapping/MappingButton.cpp
  148. Config/Mapping/MappingButton.h
  149. Config/Mapping/MappingCommon.cpp
  150. Config/Mapping/MappingCommon.h
  151. Config/Mapping/MappingIndicator.cpp
  152. Config/Mapping/MappingIndicator.h
  153. Config/Mapping/MappingNumeric.cpp
  154. Config/Mapping/MappingNumeric.h
  155. Config/Mapping/MappingWidget.cpp
  156. Config/Mapping/MappingWidget.h
  157. Config/Mapping/MappingWindow.cpp
  158. Config/Mapping/MappingWindow.h
  159. Config/Mapping/WiimoteEmuExtension.cpp
  160. Config/Mapping/WiimoteEmuExtension.h
  161. Config/Mapping/WiimoteEmuExtensionMotionInput.cpp
  162. Config/Mapping/WiimoteEmuExtensionMotionInput.h
  163. Config/Mapping/WiimoteEmuExtensionMotionSimulation.cpp
  164. Config/Mapping/WiimoteEmuExtensionMotionSimulation.h
  165. Config/Mapping/WiimoteEmuGeneral.cpp
  166. Config/Mapping/WiimoteEmuGeneral.h
  167. Config/Mapping/WiimoteEmuMotionControl.cpp
  168. Config/Mapping/WiimoteEmuMotionControl.h
  169. Config/Mapping/WiimoteEmuMotionControlIMU.cpp
  170. Config/Mapping/WiimoteEmuMotionControlIMU.h
  171. Config/NewPatchDialog.cpp
  172. Config/NewPatchDialog.h
  173. Config/PatchesWidget.cpp
  174. Config/PatchesWidget.h
  175. Config/PropertiesDialog.cpp
  176. Config/PropertiesDialog.h
  177. Config/SettingsWindow.cpp
  178. Config/SettingsWindow.h
  179. Config/ToolTipControls/BalloonTip.cpp
  180. Config/ToolTipControls/BalloonTip.h
  181. Config/ToolTipControls/ToolTipCheckBox.cpp
  182. Config/ToolTipControls/ToolTipCheckBox.h
  183. Config/ToolTipControls/ToolTipComboBox.cpp
  184. Config/ToolTipControls/ToolTipComboBox.h
  185. Config/ToolTipControls/ToolTipPushButton.cpp
  186. Config/ToolTipControls/ToolTipPushButton.h
  187. Config/ToolTipControls/ToolTipRadioButton.cpp
  188. Config/ToolTipControls/ToolTipRadioButton.h
  189. Config/ToolTipControls/ToolTipSlider.cpp
  190. Config/ToolTipControls/ToolTipSlider.h
  191. Config/ToolTipControls/ToolTipSpinBox.cpp
  192. Config/ToolTipControls/ToolTipSpinBox.h
  193. Config/ToolTipControls/ToolTipWidget.h
  194. Config/VerifyWidget.cpp
  195. Config/VerifyWidget.h
  196. Config/WiimoteControllersWidget.cpp
  197. Config/WiimoteControllersWidget.h
  198. ConvertDialog.cpp
  199. ConvertDialog.h
  200. Debugger/AssembleInstructionDialog.cpp
  201. Debugger/AssembleInstructionDialog.h
  202. Debugger/AssemblerWidget.cpp
  203. Debugger/AssemblerWidget.h
  204. Debugger/AssemblyEditor.cpp
  205. Debugger/AssemblyEditor.h
  206. Debugger/BranchWatchDialog.cpp
  207. Debugger/BranchWatchDialog.h
  208. Debugger/BranchWatchTableModel.cpp
  209. Debugger/BranchWatchTableModel.h
  210. Debugger/BreakpointDialog.cpp
  211. Debugger/BreakpointDialog.h
  212. Debugger/BreakpointWidget.cpp
  213. Debugger/BreakpointWidget.h
  214. Debugger/CodeViewWidget.cpp
  215. Debugger/CodeViewWidget.h
  216. Debugger/CodeWidget.cpp
  217. Debugger/CodeWidget.h
  218. Debugger/GekkoSyntaxHighlight.cpp
  219. Debugger/GekkoSyntaxHighlight.h
  220. Debugger/JitBlockTableModel.cpp
  221. Debugger/JitBlockTableModel.h
  222. Debugger/JITWidget.cpp
  223. Debugger/JITWidget.h
  224. Debugger/MemoryViewWidget.cpp
  225. Debugger/MemoryViewWidget.h
  226. Debugger/MemoryWidget.cpp
  227. Debugger/MemoryWidget.h
  228. Debugger/NetworkWidget.cpp
  229. Debugger/NetworkWidget.h
  230. Debugger/PatchInstructionDialog.cpp
  231. Debugger/PatchInstructionDialog.h
  232. Debugger/RegisterColumn.cpp
  233. Debugger/RegisterColumn.h
  234. Debugger/RegisterWidget.cpp
  235. Debugger/RegisterWidget.h
  236. Debugger/ThreadWidget.cpp
  237. Debugger/ThreadWidget.h
  238. Debugger/WatchWidget.cpp
  239. Debugger/WatchWidget.h
  240. DiscordHandler.cpp
  241. DiscordHandler.h
  242. DiscordJoinRequestDialog.cpp
  243. DiscordJoinRequestDialog.h
  244. FIFO/FIFOAnalyzer.cpp
  245. FIFO/FIFOAnalyzer.h
  246. FIFO/FIFOPlayerWindow.cpp
  247. FIFO/FIFOPlayerWindow.h
  248. GameList/GameList.cpp
  249. GameList/GameList.h
  250. GameList/GameListModel.cpp
  251. GameList/GameListModel.h
  252. GameList/GameTracker.cpp
  253. GameList/GameTracker.h
  254. GameList/GridProxyModel.cpp
  255. GameList/GridProxyModel.h
  256. GameList/ListProxyModel.cpp
  257. GameList/ListProxyModel.h
  258. GCMemcardCreateNewDialog.cpp
  259. GCMemcardCreateNewDialog.h
  260. GCMemcardManager.cpp
  261. GCMemcardManager.h
  262. Host.cpp
  263. Host.h
  264. HotkeyScheduler.cpp
  265. HotkeyScheduler.h
  266. InfinityBase/InfinityBaseWindow.cpp
  267. InfinityBase/InfinityBaseWindow.h
  268. Main.cpp
  269. MainWindow.cpp
  270. MainWindow.h
  271. MenuBar.cpp
  272. MenuBar.h
  273. NetPlay/ChunkedProgressDialog.cpp
  274. NetPlay/ChunkedProgressDialog.h
  275. NetPlay/GameDigestDialog.cpp
  276. NetPlay/GameDigestDialog.h
  277. NetPlay/GameListDialog.cpp
  278. NetPlay/GameListDialog.h
  279. NetPlay/NetPlayBrowser.cpp
  280. NetPlay/NetPlayBrowser.h
  281. NetPlay/NetPlayDialog.cpp
  282. NetPlay/NetPlayDialog.h
  283. NetPlay/NetPlaySetupDialog.cpp
  284. NetPlay/NetPlaySetupDialog.h
  285. NetPlay/PadMappingDialog.cpp
  286. NetPlay/PadMappingDialog.h
  287. NANDRepairDialog.cpp
  288. NANDRepairDialog.h
  289. NKitWarningDialog.cpp
  290. NKitWarningDialog.h
  291. QtUtils/AspectRatioWidget.cpp
  292. QtUtils/AspectRatioWidget.h
  293. QtUtils/BlockUserInputFilter.cpp
  294. QtUtils/BlockUserInputFilter.h
  295. QtUtils/ClearLayoutRecursively.cpp
  296. QtUtils/ClearLayoutRecursively.h
  297. QtUtils/ClickableStatusBar.h
  298. QtUtils/DolphinFileDialog.cpp
  299. QtUtils/DolphinFileDialog.h
  300. QtUtils/DoubleClickEventFilter.cpp
  301. QtUtils/DoubleClickEventFilter.h
  302. QtUtils/ElidedButton.cpp
  303. QtUtils/ElidedButton.h
  304. QtUtils/FileOpenEventFilter.cpp
  305. QtUtils/FileOpenEventFilter.h
  306. QtUtils/FromStdString.h
  307. QtUtils/ImageConverter.cpp
  308. QtUtils/ImageConverter.h
  309. QtUtils/ModalMessageBox.cpp
  310. QtUtils/ModalMessageBox.h
  311. QtUtils/NonDefaultQPushButton.cpp
  312. QtUtils/NonDefaultQPushButton.h
  313. QtUtils/ParallelProgressDialog.h
  314. QtUtils/PartiallyClosableTabWidget.cpp
  315. QtUtils/PartiallyClosableTabWidget.h
  316. QtUtils/QtUtils.cpp
  317. QtUtils/QtUtils.h
  318. QtUtils/SetWindowDecorations.cpp
  319. QtUtils/SetWindowDecorations.h
  320. QtUtils/SignalBlocking.h
  321. QtUtils/UTF8CodePointCountValidator.cpp
  322. QtUtils/UTF8CodePointCountValidator.h
  323. QtUtils/WindowActivationEventFilter.cpp
  324. QtUtils/WindowActivationEventFilter.h
  325. QtUtils/WrapInScrollArea.cpp
  326. QtUtils/WrapInScrollArea.h
  327. RenderWidget.cpp
  328. RenderWidget.h
  329. ResourcePackManager.cpp
  330. ResourcePackManager.h
  331. Resources.cpp
  332. Resources.h
  333. RiivolutionBootWidget.cpp
  334. RiivolutionBootWidget.h
  335. SearchBar.cpp
  336. SearchBar.h
  337. Settings.cpp
  338. Settings.h
  339. Settings/AdvancedPane.cpp
  340. Settings/AdvancedPane.h
  341. Settings/AudioPane.cpp
  342. Settings/AudioPane.h
  343. Settings/BroadbandAdapterSettingsDialog.cpp
  344. Settings/BroadbandAdapterSettingsDialog.h
  345. Settings/GameCubePane.cpp
  346. Settings/GameCubePane.h
  347. Settings/GeneralPane.cpp
  348. Settings/GeneralPane.h
  349. Settings/InterfacePane.cpp
  350. Settings/InterfacePane.h
  351. Settings/PathPane.cpp
  352. Settings/PathPane.h
  353. Settings/USBDeviceAddToWhitelistDialog.cpp
  354. Settings/USBDeviceAddToWhitelistDialog.h
  355. Settings/WiiPane.cpp
  356. Settings/WiiPane.h
  357. SkylanderPortal/SkylanderModifyDialog.cpp
  358. SkylanderPortal/SkylanderModifyDialog.h
  359. SkylanderPortal/SkylanderPortalWindow.cpp
  360. SkylanderPortal/SkylanderPortalWindow.h
  361. TAS/GCTASInputWindow.cpp
  362. TAS/GCTASInputWindow.h
  363. TAS/GBATASInputWindow.cpp
  364. TAS/GBATASInputWindow.h
  365. TAS/IRWidget.cpp
  366. TAS/IRWidget.h
  367. TAS/StickWidget.cpp
  368. TAS/StickWidget.h
  369. TAS/TASCheckBox.cpp
  370. TAS/TASCheckBox.h
  371. TAS/TASControlState.cpp
  372. TAS/TASControlState.h
  373. TAS/TASInputWindow.cpp
  374. TAS/TASInputWindow.h
  375. TAS/TASSlider.cpp
  376. TAS/TASSlider.h
  377. TAS/TASSpinBox.cpp
  378. TAS/TASSpinBox.h
  379. TAS/WiiTASInputWindow.cpp
  380. TAS/WiiTASInputWindow.h
  381. ToolBar.cpp
  382. ToolBar.h
  383. Translation.cpp
  384. Translation.h
  385. Updater.cpp
  386. Updater.h
  387. WiiUpdate.cpp
  388. WiiUpdate.h
  389. )
  390. if (WIN32)
  391. target_sources(dolphin-emu PRIVATE
  392. Styles/Dark/dark.qrc
  393. )
  394. endif()
  395. if (NOT WIN32)
  396. target_sources(dolphin-emu PRIVATE
  397. QtUtils/SignalDaemon.cpp
  398. QtUtils/SignalDaemon.h
  399. )
  400. endif()
  401. target_compile_definitions(dolphin-emu
  402. PRIVATE
  403. -DQT_USE_QSTRINGBUILDER
  404. -DQT_NO_CAST_FROM_ASCII
  405. -DQT_NO_CAST_TO_ASCII
  406. )
  407. target_include_directories(dolphin-emu
  408. PRIVATE
  409. ${CMAKE_CURRENT_BINARY_DIR}
  410. ${Qt6Gui_PRIVATE_INCLUDE_DIRS}
  411. )
  412. target_link_libraries(dolphin-emu
  413. PRIVATE
  414. core
  415. Qt6::Widgets
  416. uicommon
  417. imgui
  418. implot
  419. )
  420. if (WIN32)
  421. target_link_libraries(dolphin-emu
  422. PRIVATE
  423. gdi32.lib
  424. shell32.lib
  425. dwmapi.lib # Needed to set window decorations for dark theme
  426. )
  427. endif()
  428. if (MSVC)
  429. set(qtGui "")
  430. set(qtGuiPriv "")
  431. set(qtWidgetsPriv "")
  432. list(TRANSFORM Qt6Gui_INCLUDE_DIRS PREPEND "/external:I" OUTPUT_VARIABLE qtGui)
  433. list(TRANSFORM Qt6Gui_PRIVATE_INCLUDE_DIRS PREPEND "/external:I" OUTPUT_VARIABLE qtGuiPriv)
  434. list(TRANSFORM Qt6Widgets_PRIVATE_INCLUDE_DIRS PREPEND "/external:I" OUTPUT_VARIABLE qtWidgetsPriv)
  435. target_compile_options(dolphin-emu PRIVATE "${qtGui}")
  436. target_compile_options(dolphin-emu PRIVATE "${qtGuiPriv}")
  437. target_compile_options(dolphin-emu PRIVATE "${qtWidgets}")
  438. # Qt 6.3.0 headers use std::aligned_storage instead of alignas
  439. target_compile_definitions(dolphin-emu PRIVATE _SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING)
  440. # Qt6 requires RTTI
  441. remove_cxx_flag_from_target(dolphin-emu "/GR-")
  442. target_compile_options(dolphin-emu PRIVATE "/GR")
  443. endif()
  444. if(WIN32)
  445. target_sources(dolphin-emu PRIVATE DolphinQt.manifest DolphinQt.rc)
  446. set_target_properties(dolphin-emu PROPERTIES
  447. DEBUG_POSTFIX D
  448. OUTPUT_NAME Dolphin
  449. WIN32_EXECUTABLE TRUE
  450. )
  451. # Copy Sys dir
  452. add_custom_command(TARGET dolphin-emu POST_BUILD
  453. COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Sys"
  454. COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/Data/Sys" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Sys"
  455. )
  456. # Copy COPYING
  457. add_custom_command(TARGET dolphin-emu POST_BUILD
  458. COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/COPYING" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/COPYING"
  459. )
  460. # Copy Licenses dir
  461. add_custom_command(TARGET dolphin-emu POST_BUILD
  462. COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/LICENSES" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Licenses"
  463. )
  464. # Copy qt.conf
  465. add_custom_command(TARGET dolphin-emu POST_BUILD
  466. COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/qt.conf.win" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf"
  467. )
  468. # Delegate to Qt's official deployment binary on Windows to copy over the necessary Qt-specific libraries, etc.
  469. get_target_property(MOC_EXECUTABLE_LOCATION Qt6::moc IMPORTED_LOCATION)
  470. get_filename_component(QT_BINARY_DIRECTORY "${MOC_EXECUTABLE_LOCATION}" DIRECTORY)
  471. find_program(WINDEPLOYQT_EXE windeployqt HINTS "${QT_BINARY_DIRECTORY}")
  472. # Note: We set the PATH for the duration of this command so that the
  473. # deployment application is able to locate the Qt libraries to copy.
  474. # if the necessary paths aren't already set beforehand.
  475. #
  476. # For example, consider a hypothetical emulation project named Orca.
  477. # Orca supplies its own version of Qt instead of having developers actually
  478. # install the officially supported Qt libraries -- a method that would make
  479. # wrangling around with Qt through CMake much nicer and lessen the external
  480. # library maintenance burden of the project, but alas.
  481. #
  482. # In this case, as Qt is not installed through the official binary, this also
  483. # means proper path variables will not be set up, thus the need to ensure they're
  484. # always set up.
  485. #
  486. add_custom_command(TARGET dolphin-emu POST_BUILD
  487. COMMAND "${CMAKE_COMMAND}" -E env PATH="${QT_BINARY_DIRECTORY}"
  488. "${WINDEPLOYQT_EXE}" --libdir="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
  489. --plugindir="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/QtPlugins"
  490. $<IF:$<CONFIG:Debug>,--debug,--release>
  491. --no-translations
  492. --no-compiler-runtime
  493. --no-system-d3d-compiler
  494. --no-opengl-sw
  495. "$<TARGET_FILE:dolphin-emu>"
  496. )
  497. endif()
  498. # Handle localization
  499. find_package(Gettext)
  500. if(WIN32 AND NOT Gettext_FOUND)
  501. message(STATUS "Using Gettext from Externals")
  502. set(GETTEXT_MSGFMT_EXECUTABLE "${CMAKE_SOURCE_DIR}/Externals/gettext/msgfmt.exe")
  503. endif()
  504. if(GETTEXT_MSGFMT_EXECUTABLE)
  505. set(pot_file "${CMAKE_SOURCE_DIR}/Languages/po/dolphin-emu.pot")
  506. file(GLOB LINGUAS ${CMAKE_SOURCE_DIR}/Languages/po/*.po)
  507. target_sources(dolphin-emu PRIVATE ${pot_file} ${LINGUAS})
  508. source_group("Localization" FILES ${LINGUAS})
  509. source_group("Localization\\\\Generated" FILES ${pot_file})
  510. foreach(po ${LINGUAS})
  511. get_filename_component(lang ${po} NAME_WE)
  512. if(WIN32)
  513. set(mo_dir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Languages)
  514. set(mo ${mo_dir}/${lang}.mo)
  515. else()
  516. set(mo_dir ${CMAKE_CURRENT_BINARY_DIR}/${lang})
  517. set(mo ${mo_dir}/dolphin-emu.mo)
  518. endif()
  519. target_sources(dolphin-emu PRIVATE ${mo})
  520. source_group("Localization\\\\Generated" FILES ${mo})
  521. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  522. set_source_files_properties(${mo} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/${lang}.lproj")
  523. else()
  524. install(FILES ${mo} DESTINATION share/locale/${lang}/LC_MESSAGES)
  525. endif()
  526. if(WIN32)
  527. add_custom_command(OUTPUT ${mo}
  528. COMMAND ${CMAKE_COMMAND} -E make_directory ${mo_dir}
  529. COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${mo} ${po}
  530. DEPENDS ${po}
  531. )
  532. else()
  533. add_custom_command(OUTPUT ${mo}
  534. COMMAND ${CMAKE_COMMAND} -E make_directory ${mo_dir}
  535. COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${po} ${pot_file}
  536. COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${mo} ${po}
  537. DEPENDS ${po}
  538. )
  539. endif()
  540. endforeach()
  541. endif()
  542. if(APPLE)
  543. include(BundleUtilities)
  544. set(BUNDLE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/DolphinQt.app)
  545. # Ask for an application bundle.
  546. set_target_properties(dolphin-emu PROPERTIES
  547. MACOSX_BUNDLE true
  548. MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist"
  549. XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
  550. OUTPUT_NAME DolphinQt
  551. )
  552. # Copy qt.conf into the bundle
  553. target_sources(dolphin-emu PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/qt.conf")
  554. set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/qt.conf" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  555. # Copy icon into the bundle
  556. target_sources(dolphin-emu PRIVATE "${CMAKE_SOURCE_DIR}/Data/Dolphin.icns")
  557. set_source_files_properties("${CMAKE_SOURCE_DIR}/Data/Dolphin.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  558. # Manually include plugins
  559. find_package(Qt6QMacStylePlugin REQUIRED PATHS ${Qt6Widgets_DIR})
  560. find_package(Qt6QCocoaIntegrationPlugin REQUIRED PATHS ${Qt6Gui_DIR})
  561. # Copy Qt plugins into the bundle
  562. get_target_property(qtcocoa_location Qt6::QCocoaIntegrationPlugin LOCATION)
  563. target_sources(dolphin-emu PRIVATE "${qtcocoa_location}")
  564. set_source_files_properties("${qtcocoa_location}" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS/platforms)
  565. get_target_property(qtmacstyle_location Qt6::QMacStylePlugin LOCATION)
  566. target_sources(dolphin-emu PRIVATE "${qtmacstyle_location}")
  567. set_source_files_properties("${qtmacstyle_location}" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS/styles)
  568. # Copy resources into the bundle
  569. set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/Data/Sys")
  570. file(GLOB_RECURSE resources RELATIVE "${CMAKE_SOURCE_DIR}/Data" "${CMAKE_SOURCE_DIR}/Data/Sys/*")
  571. foreach(res ${resources})
  572. target_sources(dolphin-emu PRIVATE "${CMAKE_SOURCE_DIR}/Data/${res}")
  573. get_filename_component(resdir "${res}" DIRECTORY)
  574. set_source_files_properties("${CMAKE_SOURCE_DIR}/Data/${res}" PROPERTIES
  575. MACOSX_PACKAGE_LOCATION "Resources/${resdir}")
  576. source_group("Resources" FILES "${CMAKE_SOURCE_DIR}/Data/${res}")
  577. endforeach()
  578. # Copy MoltenVK into the bundle
  579. if(ENABLE_VULKAN)
  580. if(USE_BUNDLED_MOLTENVK)
  581. add_dependencies(dolphin-emu MoltenVK)
  582. ExternalProject_Get_Property(MoltenVK SOURCE_DIR)
  583. target_sources(dolphin-emu PRIVATE "${SOURCE_DIR}/Package/Release/MoltenVK/dynamic/dylib/macOS/libMoltenVK.dylib")
  584. set_source_files_properties("${SOURCE_DIR}/Package/Release/MoltenVK/dynamic/dylib/macOS/libMoltenVK.dylib" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks GENERATED ON)
  585. else()
  586. find_file(MOLTENVK_DYLIB NAMES libMoltenVK.dylib PATH_SUFFIXES lib)
  587. if(NOT MOLTENVK_DYLIB)
  588. message(FATAL_ERROR "Couldn't find libMoltenVK.dylib. Enable USE_BUNDLED_MOLTENVK?")
  589. endif()
  590. target_sources(dolphin-emu PRIVATE ${MOLTENVK_DYLIB})
  591. set_source_files_properties(${MOLTENVK_DYLIB} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks)
  592. endif()
  593. endif()
  594. if(NOT SKIP_POSTPROCESS_BUNDLE)
  595. # Update library references to make the bundle portable
  596. include(DolphinPostprocessBundle)
  597. dolphin_postprocess_bundle(dolphin-emu)
  598. # Fix rpath
  599. add_custom_command(TARGET dolphin-emu
  600. POST_BUILD COMMAND
  601. ${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../Frameworks/"
  602. $<TARGET_FILE:dolphin-emu>)
  603. endif()
  604. if(MACOS_CODE_SIGNING)
  605. add_custom_command(TARGET dolphin-emu
  606. POST_BUILD
  607. COMMAND "${CMAKE_SOURCE_DIR}/Tools/mac-codesign.sh"
  608. "-e" "${CMAKE_CURRENT_SOURCE_DIR}/DolphinEmu$<$<CONFIG:Debug>:Debug>.entitlements"
  609. "${MACOS_CODE_SIGNING_IDENTITY}"
  610. "${BUNDLE_PATH}"
  611. )
  612. endif()
  613. else()
  614. install(TARGETS dolphin-emu RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
  615. endif()
  616. if(USE_MGBA)
  617. target_sources(dolphin-emu PRIVATE
  618. GBAHost.cpp
  619. GBAHost.h
  620. GBAWidget.cpp
  621. GBAWidget.h
  622. )
  623. endif()
  624. if(USE_DISCORD_PRESENCE)
  625. target_compile_definitions(dolphin-emu PRIVATE -DUSE_DISCORD_PRESENCE)
  626. endif()
  627. if(USE_RETRO_ACHIEVEMENTS)
  628. target_link_libraries(dolphin-emu PRIVATE rcheevos)
  629. target_compile_definitions(dolphin-emu PRIVATE -DUSE_RETRO_ACHIEVEMENTS)
  630. endif()