CMakeLists.txt 14 KB

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