CMakeLists.txt 9.7 KB

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