CMakeLists.txt 10 KB

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