CMakeLists.txt 12 KB

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