CMakeLists.txt 13 KB

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