CMakeLists.txt 13 KB

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