CMakeLists.txt 13 KB

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