CMakeLists.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. set(client_SRCS
  2. StdInc.cpp
  3. ../CCallback.cpp
  4. adventureMap/AdventureMapInterface.cpp
  5. adventureMap/AdventureMapShortcuts.cpp
  6. adventureMap/AdventureMapWidget.cpp
  7. adventureMap/AdventureOptions.cpp
  8. adventureMap/CInGameConsole.cpp
  9. adventureMap/CInfoBar.cpp
  10. adventureMap/CList.cpp
  11. adventureMap/CMinimap.cpp
  12. adventureMap/CResDataBar.cpp
  13. adventureMap/MapAudioPlayer.cpp
  14. adventureMap/TurnTimerWidget.cpp
  15. battle/BattleActionsController.cpp
  16. battle/BattleAnimationClasses.cpp
  17. battle/BattleEffectsController.cpp
  18. battle/BattleFieldController.cpp
  19. battle/BattleInterface.cpp
  20. battle/BattleInterfaceClasses.cpp
  21. battle/BattleObstacleController.cpp
  22. battle/BattleProjectileController.cpp
  23. battle/BattleRenderer.cpp
  24. battle/BattleSiegeController.cpp
  25. battle/BattleStacksController.cpp
  26. battle/BattleWindow.cpp
  27. battle/CreatureAnimation.cpp
  28. eventsSDL/NotificationHandler.cpp
  29. eventsSDL/InputHandler.cpp
  30. eventsSDL/InputSourceKeyboard.cpp
  31. eventsSDL/InputSourceMouse.cpp
  32. eventsSDL/InputSourceText.cpp
  33. eventsSDL/InputSourceTouch.cpp
  34. gui/CGuiHandler.cpp
  35. gui/CIntObject.cpp
  36. gui/CursorHandler.cpp
  37. gui/EventDispatcher.cpp
  38. gui/EventsReceiver.cpp
  39. gui/InterfaceObjectConfigurable.cpp
  40. gui/FramerateManager.cpp
  41. gui/ShortcutHandler.cpp
  42. gui/WindowHandler.cpp
  43. lobby/CBonusSelection.cpp
  44. lobby/CCampaignInfoScreen.cpp
  45. lobby/CLobbyScreen.cpp
  46. lobby/CSavingScreen.cpp
  47. lobby/CScenarioInfoScreen.cpp
  48. lobby/CSelectionBase.cpp
  49. lobby/OptionsTab.cpp
  50. lobby/RandomMapTab.cpp
  51. lobby/SelectionTab.cpp
  52. mainmenu/CCampaignScreen.cpp
  53. mainmenu/CMainMenu.cpp
  54. mainmenu/CPrologEpilogVideo.cpp
  55. mainmenu/CreditsScreen.cpp
  56. mainmenu/CHighScoreScreen.cpp
  57. mapView/MapRenderer.cpp
  58. mapView/MapRendererContext.cpp
  59. mapView/MapRendererContextState.cpp
  60. mapView/MapView.cpp
  61. mapView/MapViewActions.cpp
  62. mapView/MapViewCache.cpp
  63. mapView/MapViewController.cpp
  64. mapView/MapViewModel.cpp
  65. mapView/mapHandler.cpp
  66. render/CAnimation.cpp
  67. render/CBitmapHandler.cpp
  68. render/CDefFile.cpp
  69. render/Canvas.cpp
  70. render/ColorFilter.cpp
  71. render/Colors.cpp
  72. render/Graphics.cpp
  73. render/IFont.cpp
  74. renderSDL/CBitmapFont.cpp
  75. renderSDL/CBitmapHanFont.cpp
  76. renderSDL/CTrueTypeFont.cpp
  77. renderSDL/CursorHardware.cpp
  78. renderSDL/CursorSoftware.cpp
  79. renderSDL/RenderHandler.cpp
  80. renderSDL/SDLImage.cpp
  81. renderSDL/SDLImageLoader.cpp
  82. renderSDL/SDLRWwrapper.cpp
  83. renderSDL/ScreenHandler.cpp
  84. renderSDL/SDL_Extensions.cpp
  85. widgets/Buttons.cpp
  86. widgets/CArtifactHolder.cpp
  87. widgets/CComponent.cpp
  88. widgets/CExchangeController.cpp
  89. widgets/CGarrisonInt.cpp
  90. widgets/CreatureCostBox.cpp
  91. widgets/ComboBox.cpp
  92. widgets/Images.cpp
  93. widgets/MiscWidgets.cpp
  94. widgets/ObjectLists.cpp
  95. widgets/TextControls.cpp
  96. widgets/Scrollable.cpp
  97. widgets/Slider.cpp
  98. widgets/CArtifactsOfHeroBase.cpp
  99. widgets/CArtifactsOfHeroMain.cpp
  100. widgets/CArtifactsOfHeroKingdom.cpp
  101. widgets/CArtifactsOfHeroAltar.cpp
  102. widgets/CArtifactsOfHeroMarket.cpp
  103. widgets/CArtifactsOfHeroBackpack.cpp
  104. widgets/CWindowWithArtifacts.cpp
  105. widgets/RadialMenu.cpp
  106. windows/CCastleInterface.cpp
  107. windows/CCreatureWindow.cpp
  108. windows/CHeroOverview.cpp
  109. windows/CHeroWindow.cpp
  110. windows/CKingdomInterface.cpp
  111. windows/CMapOverview.cpp
  112. windows/CMessage.cpp
  113. windows/CPuzzleWindow.cpp
  114. windows/CQuestLog.cpp
  115. windows/CSpellWindow.cpp
  116. windows/CTradeWindow.cpp
  117. windows/CWindowObject.cpp
  118. windows/CreaturePurchaseCard.cpp
  119. windows/GUIClasses.cpp
  120. windows/InfoWindows.cpp
  121. windows/QuickRecruitmentWindow.cpp
  122. windows/CHeroBackpackWindow.cpp
  123. windows/settings/GeneralOptionsTab.cpp
  124. windows/settings/OtherOptionsTab.cpp
  125. windows/settings/SettingsMainWindow.cpp
  126. windows/settings/BattleOptionsTab.cpp
  127. windows/settings/AdventureOptionsTab.cpp
  128. CGameInfo.cpp
  129. CMT.cpp
  130. CMusicHandler.cpp
  131. CPlayerInterface.cpp
  132. PlayerLocalState.cpp
  133. CServerHandler.cpp
  134. CVideoHandler.cpp
  135. Client.cpp
  136. ClientCommandManager.cpp
  137. HeroMovementController.cpp
  138. NetPacksClient.cpp
  139. NetPacksLobbyClient.cpp
  140. )
  141. set(client_HEADERS
  142. StdInc.h
  143. adventureMap/AdventureMapInterface.h
  144. adventureMap/AdventureMapShortcuts.h
  145. adventureMap/AdventureMapWidget.h
  146. adventureMap/AdventureState.h
  147. adventureMap/AdventureOptions.h
  148. adventureMap/CInGameConsole.h
  149. adventureMap/CInfoBar.h
  150. adventureMap/CList.h
  151. adventureMap/CMinimap.h
  152. adventureMap/CResDataBar.h
  153. adventureMap/MapAudioPlayer.h
  154. adventureMap/TurnTimerWidget.h
  155. battle/BattleActionsController.h
  156. battle/BattleAnimationClasses.h
  157. battle/BattleConstants.h
  158. battle/BattleEffectsController.h
  159. battle/BattleFieldController.h
  160. battle/BattleInterface.h
  161. battle/BattleInterfaceClasses.h
  162. battle/BattleObstacleController.h
  163. battle/BattleProjectileController.h
  164. battle/BattleRenderer.h
  165. battle/BattleSiegeController.h
  166. battle/BattleStacksController.h
  167. battle/BattleWindow.h
  168. battle/CreatureAnimation.h
  169. eventsSDL/NotificationHandler.h
  170. eventsSDL/InputHandler.h
  171. eventsSDL/InputSourceKeyboard.h
  172. eventsSDL/InputSourceMouse.h
  173. eventsSDL/InputSourceText.h
  174. eventsSDL/InputSourceTouch.h
  175. gui/CGuiHandler.h
  176. gui/CIntObject.h
  177. gui/CursorHandler.h
  178. gui/EventDispatcher.h
  179. gui/EventsReceiver.h
  180. gui/InterfaceObjectConfigurable.h
  181. gui/FramerateManager.h
  182. gui/MouseButton.h
  183. gui/Shortcut.h
  184. gui/ShortcutHandler.h
  185. gui/TextAlignment.h
  186. gui/WindowHandler.h
  187. lobby/CBonusSelection.h
  188. lobby/CCampaignInfoScreen.h
  189. lobby/CLobbyScreen.h
  190. lobby/CSavingScreen.h
  191. lobby/CScenarioInfoScreen.h
  192. lobby/CSelectionBase.h
  193. lobby/OptionsTab.h
  194. lobby/RandomMapTab.h
  195. lobby/SelectionTab.h
  196. mainmenu/CCampaignScreen.h
  197. mainmenu/CMainMenu.h
  198. mainmenu/CPrologEpilogVideo.h
  199. mainmenu/CreditsScreen.h
  200. mainmenu/CHighScoreScreen.h
  201. mapView/IMapRendererContext.h
  202. mapView/IMapRendererObserver.h
  203. mapView/MapRenderer.h
  204. mapView/MapRendererContext.h
  205. mapView/MapRendererContextState.h
  206. mapView/MapView.h
  207. mapView/MapViewActions.h
  208. mapView/MapViewCache.h
  209. mapView/MapViewController.h
  210. mapView/MapViewModel.h
  211. mapView/mapHandler.h
  212. render/CAnimation.h
  213. render/CBitmapHandler.h
  214. render/CDefFile.h
  215. render/Canvas.h
  216. render/ColorFilter.h
  217. render/Colors.h
  218. render/EFont.h
  219. render/Graphics.h
  220. render/ICursor.h
  221. render/IFont.h
  222. render/IImage.h
  223. render/IImageLoader.h
  224. render/IRenderHandler.h
  225. render/IScreenHandler.h
  226. renderSDL/CBitmapFont.h
  227. renderSDL/CBitmapHanFont.h
  228. renderSDL/CTrueTypeFont.h
  229. renderSDL/CursorHardware.h
  230. renderSDL/CursorSoftware.h
  231. renderSDL/RenderHandler.h
  232. renderSDL/SDLImage.h
  233. renderSDL/SDLImageLoader.h
  234. renderSDL/SDLRWwrapper.h
  235. renderSDL/ScreenHandler.h
  236. renderSDL/SDL_Extensions.h
  237. renderSDL/SDL_PixelAccess.h
  238. widgets/Buttons.h
  239. widgets/CArtifactHolder.h
  240. widgets/CComponent.h
  241. widgets/CExchangeController.h
  242. widgets/CGarrisonInt.h
  243. widgets/CreatureCostBox.h
  244. widgets/ComboBox.h
  245. widgets/Images.h
  246. widgets/MiscWidgets.h
  247. widgets/ObjectLists.h
  248. widgets/TextControls.h
  249. widgets/Scrollable.h
  250. widgets/Slider.h
  251. widgets/CArtifactsOfHeroBase.h
  252. widgets/CArtifactsOfHeroMain.h
  253. widgets/CArtifactsOfHeroKingdom.h
  254. widgets/CArtifactsOfHeroAltar.h
  255. widgets/CArtifactsOfHeroMarket.h
  256. widgets/CArtifactsOfHeroBackpack.h
  257. widgets/CWindowWithArtifacts.h
  258. widgets/RadialMenu.h
  259. windows/CCastleInterface.h
  260. windows/CCreatureWindow.h
  261. windows/CHeroOverview.h
  262. windows/CHeroWindow.h
  263. windows/CKingdomInterface.h
  264. windows/CMessage.h
  265. windows/CMapOverview.h
  266. windows/CPuzzleWindow.h
  267. windows/CQuestLog.h
  268. windows/CSpellWindow.h
  269. windows/CTradeWindow.h
  270. windows/CWindowObject.h
  271. windows/CreaturePurchaseCard.h
  272. windows/GUIClasses.h
  273. windows/InfoWindows.h
  274. windows/QuickRecruitmentWindow.h
  275. windows/CHeroBackpackWindow.h
  276. windows/settings/GeneralOptionsTab.h
  277. windows/settings/OtherOptionsTab.h
  278. windows/settings/SettingsMainWindow.h
  279. windows/settings/BattleOptionsTab.h
  280. windows/settings/AdventureOptionsTab.h
  281. CGameInfo.h
  282. CMT.h
  283. CMusicHandler.h
  284. CPlayerInterface.h
  285. PlayerLocalState.h
  286. CServerHandler.h
  287. CVideoHandler.h
  288. Client.h
  289. ClientCommandManager.h
  290. ClientNetPackVisitors.h
  291. HeroMovementController.h
  292. LobbyClientNetPackVisitors.h
  293. resource.h
  294. )
  295. if(APPLE_IOS)
  296. set(client_SRCS ${client_SRCS}
  297. CFocusableHelper.cpp
  298. ios/GameChatKeyboardHandler.m
  299. ios/main.m
  300. ios/startSDL.mm
  301. ios/utils.mm
  302. )
  303. set(client_HEADERS ${client_HEADERS}
  304. CFocusableHelper.h
  305. ios/GameChatKeyboardHandler.h
  306. ios/startSDL.h
  307. ios/utils.h
  308. )
  309. endif()
  310. assign_source_group(${client_SRCS} ${client_HEADERS} VCMI_client.rc)
  311. if(ANDROID)
  312. add_library(vcmiclient SHARED ${client_SRCS} ${client_HEADERS})
  313. else()
  314. add_executable(vcmiclient ${client_SRCS} ${client_HEADERS})
  315. endif()
  316. add_dependencies(vcmiclient vcmiserver)
  317. if(NOT ENABLE_STATIC_AI_LIBS)
  318. add_dependencies(vcmiclient
  319. BattleAI
  320. EmptyAI
  321. StupidAI
  322. VCAI
  323. )
  324. if(ENABLE_NULLKILLER_AI)
  325. add_dependencies(vcmiclient Nullkiller)
  326. endif()
  327. endif()
  328. if(APPLE_IOS)
  329. if(ENABLE_ERM)
  330. add_dependencies(vcmiclient vcmiERM)
  331. endif()
  332. if(ENABLE_LUA)
  333. add_dependencies(vcmiclient vcmiLua)
  334. endif()
  335. endif()
  336. if(WIN32)
  337. target_sources(vcmiclient PRIVATE "VCMI_client.rc")
  338. set_target_properties(vcmiclient
  339. PROPERTIES
  340. OUTPUT_NAME "VCMI_client"
  341. PROJECT_LABEL "VCMI_client"
  342. )
  343. set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT vcmiclient)
  344. if(NOT ENABLE_DEBUG_CONSOLE)
  345. set_target_properties(vcmiclient PROPERTIES WIN32_EXECUTABLE)
  346. target_link_libraries(vcmiclient SDL2::SDL2main)
  347. endif()
  348. target_compile_definitions(vcmiclient PRIVATE WINDOWS_IGNORE_PACKING_MISMATCH)
  349. # TODO: very hacky, find proper solution to copy AI dlls into bin dir
  350. if(MSVC)
  351. add_custom_command(TARGET vcmiclient POST_BUILD
  352. WORKING_DIRECTORY "$<TARGET_FILE_DIR:vcmiclient>"
  353. COMMAND ${CMAKE_COMMAND} -E copy AI/fuzzylite.dll fuzzylite.dll
  354. COMMAND ${CMAKE_COMMAND} -E copy AI/tbb12.dll tbb12.dll
  355. )
  356. endif()
  357. elseif(APPLE_IOS)
  358. target_link_libraries(vcmiclient PRIVATE
  359. iOS_utils
  360. # FFmpeg
  361. bz2
  362. iconv
  363. z
  364. "-framework AudioToolbox"
  365. "-framework AVFoundation"
  366. "-framework CoreMedia"
  367. "-framework VideoToolbox"
  368. )
  369. set_target_properties(vcmiclient PROPERTIES
  370. MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_LIST_DIR}/ios/Info.plist"
  371. XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/Frameworks"
  372. XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "$(CODE_SIGNING_ALLOWED_FOR_APPS)"
  373. XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME AppIcon
  374. )
  375. foreach(XCODE_RESOURCE LaunchScreen.storyboard Images.xcassets Settings.bundle vcmi_logo.png)
  376. set(XCODE_RESOURCE_PATH ios/${XCODE_RESOURCE})
  377. target_sources(vcmiclient PRIVATE ${XCODE_RESOURCE_PATH})
  378. set_source_files_properties(${XCODE_RESOURCE_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  379. # workaround to prevent CMAKE_SKIP_PRECOMPILE_HEADERS being added as compile flag
  380. if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.22.0" AND CMAKE_VERSION VERSION_LESS "3.25.0")
  381. set_source_files_properties(${XCODE_RESOURCE_PATH} PROPERTIES LANGUAGE CXX)
  382. endif()
  383. endforeach()
  384. set(CMAKE_EXE_LINKER_FLAGS "-Wl,-e,_client_main")
  385. endif()
  386. if(ENABLE_SINGLE_APP_BUILD)
  387. target_link_libraries(vcmiclient PRIVATE vcmiserver)
  388. if(ENABLE_LAUNCHER)
  389. target_link_libraries(vcmiclient PRIVATE vcmilauncher)
  390. endif()
  391. endif()
  392. target_link_libraries(vcmiclient PRIVATE
  393. ${VCMI_LIB_TARGET} SDL2::SDL2 SDL2::Image SDL2::Mixer SDL2::TTF
  394. )
  395. if(ffmpeg_LIBRARIES)
  396. target_link_libraries(vcmiclient PRIVATE
  397. ${ffmpeg_LIBRARIES}
  398. )
  399. else()
  400. target_compile_definitions(vcmiclient PRIVATE DISABLE_VIDEO)
  401. endif()
  402. target_include_directories(vcmiclient PUBLIC
  403. ${CMAKE_CURRENT_SOURCE_DIR}
  404. )
  405. if (ffmpeg_INCLUDE_DIRS)
  406. target_include_directories(vcmiclient PRIVATE
  407. ${ffmpeg_INCLUDE_DIRS}
  408. )
  409. endif()
  410. vcmi_set_output_dir(vcmiclient "")
  411. enable_pch(vcmiclient)
  412. if(APPLE_IOS)
  413. vcmi_install_conan_deps("\${CMAKE_INSTALL_PREFIX}")
  414. add_custom_command(TARGET vcmiclient POST_BUILD
  415. COMMAND ios/set_build_version.sh "$<TARGET_BUNDLE_CONTENT_DIR:vcmiclient>"
  416. COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --component "${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}" --config "$<CONFIG>" --prefix "$<TARGET_BUNDLE_CONTENT_DIR:vcmiclient>"
  417. COMMAND ios/rpath_remove_symlinks.sh
  418. COMMAND ios/codesign.sh
  419. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  420. )
  421. install(TARGETS vcmiclient DESTINATION Payload COMPONENT app) # for ipa generation with cpack
  422. elseif(ANDROID)
  423. vcmi_install_conan_deps("\${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
  424. add_custom_command(TARGET vcmiclient POST_BUILD
  425. COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --config "$<CONFIG>" --prefix "${CMAKE_SOURCE_DIR}/android/vcmi-app/src/main"
  426. )
  427. install(TARGETS vcmiclient DESTINATION ${LIB_DIR})
  428. else()
  429. install(TARGETS vcmiclient DESTINATION ${BIN_DIR})
  430. endif()
  431. #install icons and desktop file on Linux
  432. if(NOT WIN32 AND NOT APPLE AND NOT ANDROID)
  433. #FIXME: move to client makefile?
  434. install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.16x16.png" DESTINATION share/icons/hicolor/16x16/apps RENAME vcmiclient.png)
  435. install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.22x22.png" DESTINATION share/icons/hicolor/22x22/apps RENAME vcmiclient.png)
  436. install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.32x32.png" DESTINATION share/icons/hicolor/32x32/apps RENAME vcmiclient.png)
  437. install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.48x48.png" DESTINATION share/icons/hicolor/48x48/apps RENAME vcmiclient.png)
  438. install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.64x64.png" DESTINATION share/icons/hicolor/64x64/apps RENAME vcmiclient.png)
  439. install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.128x128.png" DESTINATION share/icons/hicolor/128x128/apps RENAME vcmiclient.png)
  440. install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.256x256.png" DESTINATION share/icons/hicolor/256x256/apps RENAME vcmiclient.png)
  441. install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.512x512.png" DESTINATION share/icons/hicolor/512x512/apps RENAME vcmiclient.png)
  442. install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.1024x1024.png" DESTINATION share/icons/hicolor/1024x1024/apps RENAME vcmiclient.png)
  443. install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.2048x2048.png" DESTINATION share/icons/hicolor/2048x2048/apps RENAME vcmiclient.png)
  444. install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.svg" DESTINATION share/icons/hicolor/scalable/apps RENAME vcmiclient.svg)
  445. install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.desktop" DESTINATION share/applications)
  446. endif()