CMakeLists.txt 14 KB

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