CMakeLists.txt 13 KB

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