CMakeLists.txt 11 KB

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