CMakeLists.txt 13 KB

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