CMakeLists.txt 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. # Minimum required version greatly affect CMake behavior
  2. # So cmake_minimum_required must be called before the project()
  3. # 3.16.0 is used since it's used by our currently oldest suppored system: Ubuntu-20.04
  4. cmake_minimum_required(VERSION 3.16.0)
  5. project(VCMI)
  6. # TODO
  7. # macOS:
  8. # - There is problem with running fixup_bundle in main project after subdirectories.
  9. # Cmake put them after all install code of main CMakelists in cmake_install.cmake
  10. # Currently I just added extra add_subdirectory and CMakeLists.txt in osx directory to bypass that.
  11. #
  12. # Vckpg:
  13. # - Improve install code once there is better way to deploy DLLs and Qt plugins
  14. #
  15. # Other:
  16. # - Cleanup remove_directory copy_directory if performance will be a problem.
  17. # We can use some macro over copy_if_different since it's only work for single file.
  18. # - Find a way to move add_custom_command for assets deploy out of "lib/CMakeLists.txt"
  19. # - Consider to remove M_DATA_DIR, DM_BIN_DIR, DM_LIB_DIR and not use them in code as well
  20. # - Try to get rid of FOLDER override with define_property
  21. # It's used currently to make sure that 3rd-party dependencies in git submodules get proper FOLDER property
  22. # - Make FindFuzzyLite check for the right version and disable FORCE_BUNDLED_FL by default
  23. if(APPLE)
  24. if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
  25. set(APPLE_MACOS 1)
  26. else()
  27. set(APPLE_IOS 1)
  28. endif()
  29. endif()
  30. ############################################
  31. # User-provided options #
  32. ############################################
  33. if(NOT CMAKE_BUILD_TYPE)
  34. set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
  35. "Choose the type of build, options are: Debug Release RelWithDebInfo. Default is RelWithDebInfo."
  36. FORCE)
  37. set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo)
  38. endif()
  39. set(buildLobby OFF)
  40. set(singleProcess OFF)
  41. set(staticAI OFF)
  42. if(ANDROID)
  43. set(staticAI ON)
  44. set(singleProcess ON)
  45. endif()
  46. option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
  47. option(ENABLE_LUA "Enable compilation of LUA scripting module" OFF)
  48. if(NOT ANDROID)
  49. option(ENABLE_LAUNCHER "Enable compilation of launcher" ON)
  50. option(ENABLE_EDITOR "Enable compilation of map editor" ON)
  51. endif()
  52. option(ENABLE_TRANSLATIONS "Enable generation of translations for launcher and editor" ON)
  53. option(ENABLE_NULLKILLER_AI "Enable compilation of Nullkiller AI library" ON)
  54. if(APPLE_IOS)
  55. set(BUNDLE_IDENTIFIER_PREFIX "" CACHE STRING "Bundle identifier prefix")
  56. set(APP_DISPLAY_NAME "VCMI" CACHE STRING "App name on the home screen")
  57. set(ENABLE_SINGLE_APP_BUILD ON)
  58. else()
  59. option(ENABLE_TEST "Enable compilation of unit tests" OFF)
  60. option(ENABLE_SINGLE_APP_BUILD "Builds client and server as single executable" ${singleProcess})
  61. endif()
  62. option(ENABLE_PCH "Enable compilation using precompiled headers" ON)
  63. option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON)
  64. option(ENABLE_DEBUG_CONSOLE "Enable debug console for Windows builds" ON)
  65. option(ENABLE_STRICT_COMPILATION "Treat all compiler warnings as errors" OFF)
  66. option(ENABLE_MULTI_PROCESS_BUILDS "Enable /MP flag for MSVS solution" ON)
  67. option(COPY_CONFIG_ON_BUILD "Copies config folder into output directory at building phase" ON)
  68. option(ENABLE_STATIC_AI_LIBS "Add AI code into VCMI lib directly" ${staticAI})
  69. option(ENABLE_COLORIZED_COMPILER_OUTPUT "Colorize compilation output (Clang/GNU)." ON)
  70. if(ENABLE_COLORIZED_COMPILER_OUTPUT)
  71. if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  72. add_compile_options(-fcolor-diagnostics)
  73. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  74. add_compile_options(-fdiagnostics-color=always)
  75. endif()
  76. endif()
  77. # Used for Snap packages and also useful for debugging
  78. if(NOT APPLE_IOS AND NOT ANDROID)
  79. option(ENABLE_MONOLITHIC_INSTALL "Install everything in single directory on Linux and Mac" OFF)
  80. endif()
  81. if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
  82. set(buildLobby ON)
  83. endif()
  84. if(NOT APPLE_IOS AND NOT ANDROID)
  85. option(ENABLE_LOBBY "Enable compilation of lobby server" ${buildLobby})
  86. endif()
  87. option(ENABLE_CCACHE "Speed up recompilation by caching previous compilations" OFF)
  88. if(ENABLE_CCACHE)
  89. find_program(CCACHE ccache REQUIRED)
  90. endif()
  91. # The XCode and MSVC builds each require some more configuration further down.
  92. if(ENABLE_CCACHE)
  93. set(CMAKE_C_COMPILER_LAUNCHER "ccache")
  94. set(CMAKE_CXX_COMPILER_LAUNCHER "ccache")
  95. endif()
  96. if(ENABLE_CCACHE AND (CMAKE_GENERATOR STREQUAL "Xcode"))
  97. # https://stackoverflow.com/a/36515503/2278742
  98. # Set up wrapper scripts
  99. configure_file(xcode/launch-c.in xcode/launch-c)
  100. configure_file(xcode/launch-cxx.in xcode/launch-cxx)
  101. execute_process(COMMAND chmod a+rx
  102. "${CMAKE_BINARY_DIR}/xcode/launch-c"
  103. "${CMAKE_BINARY_DIR}/xcode/launch-cxx")
  104. # Set Xcode project attributes to route compilation through our scripts
  105. set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/xcode/launch-c")
  106. set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/xcode/launch-cxx")
  107. set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/xcode/launch-c")
  108. set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/xcode/launch-cxx")
  109. endif()
  110. # Allow to pass package name from Travis CI
  111. set(PACKAGE_NAME_SUFFIX "" CACHE STRING "Suffix for CPack package name")
  112. set(PACKAGE_FILE_NAME "" CACHE STRING "Override for CPack package filename")
  113. # ERM depends on LUA implicitly
  114. if(ENABLE_ERM AND NOT ENABLE_LUA)
  115. set(ENABLE_LUA ON)
  116. endif()
  117. # We don't want to deploy assets into build directory for android/iOS build
  118. if((APPLE_IOS OR ANDROID) AND COPY_CONFIG_ON_BUILD)
  119. set(COPY_CONFIG_ON_BUILD OFF)
  120. endif()
  121. ############################################
  122. # Miscellaneous options #
  123. ############################################
  124. set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules ${PROJECT_SOURCE_DIR}/CI)
  125. # Contains custom functions and macros, but don't altering any options
  126. include(VCMIUtils)
  127. include(VersionDefinition)
  128. if(ANDROID)
  129. set(VCMI_VERSION "${APP_SHORT_VERSION}")
  130. configure_file("android/GeneratedVersion.java.in" "${CMAKE_SOURCE_DIR}/android/vcmi-app/src/main/java/eu/vcmi/vcmi/util/GeneratedVersion.java" @ONLY)
  131. endif()
  132. vcmi_print_important_variables()
  133. # Options to enable folders in CMake generated projects for Visual Studio, Xcode, etc
  134. # Very useful to put 3rd-party libraries such as Minizip, GoogleTest and FuzzyLite in their own folders
  135. set_property(GLOBAL PROPERTY USE_FOLDERS TRUE)
  136. # Make FOLDER property inheritable
  137. # So when we set FOLDER property on AI directory all and targets inside will inherit it
  138. #
  139. # Important! This trick depend on undefined behavior since we override CMake own property.
  140. # In same time define_property documentation states it's function for custom properties.
  141. define_property(
  142. TARGET
  143. PROPERTY FOLDER
  144. INHERITED
  145. BRIEF_DOCS "Set the folder name."
  146. FULL_DOCS "Use to organize targets in an IDE."
  147. )
  148. # Generate Version.cpp
  149. if(ENABLE_GITVERSION)
  150. add_custom_target(update_version ALL
  151. BYPRODUCTS "Version.cpp"
  152. COMMAND ${CMAKE_COMMAND} -DGIT_SHA1="${GIT_SHA1}" -P "${PROJECT_SOURCE_DIR}/cmake_modules/Version.cmake"
  153. )
  154. else()
  155. add_definitions(-DVCMI_NO_EXTRA_VERSION)
  156. endif(ENABLE_GITVERSION)
  157. # Precompiled header configuration
  158. if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0 )
  159. set(ENABLE_PCH OFF) # broken
  160. endif()
  161. if(ENABLE_PCH)
  162. macro(enable_pch name)
  163. target_precompile_headers(${name} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:<StdInc.h$<ANGLE-R>>)
  164. endmacro(enable_pch)
  165. else()
  166. macro(enable_pch ignore)
  167. endmacro(enable_pch)
  168. endif()
  169. ############################################
  170. # Documentation section #
  171. ############################################
  172. include(UseDoxygen OPTIONAL)
  173. ############################################
  174. # Compile and linking options #
  175. ############################################
  176. #Enable C++17 Globally
  177. set (CMAKE_CXX_STANDARD 17)
  178. #General visibility options
  179. set(CMAKE_CXX_VISIBILITY_PRESET hidden)
  180. set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
  181. #Global fallback mapping
  182. # RelWithDebInfo falls back to Release, then MinSizeRel, and then to None (tbb in 22.04 requires it)
  183. set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO RelWithDebInfo Release MinSizeRel None "")
  184. # MinSizeRel falls back to Release, then RelWithDebInfo, and then to None (tbb in 22.04 requires it)
  185. set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL MinSizeRel Release RelWithDebInfo None "")
  186. # Release falls back to RelWithDebInfo, then MinSizeRel, and then to None (tbb in 22.04 requires it)
  187. set(CMAKE_MAP_IMPORTED_CONFIG_RELEASE Release RelWithDebInfo MinSizeRel None "")
  188. set(CMAKE_XCODE_ATTRIBUTE_APP_DISPLAY_NAME ${APP_DISPLAY_NAME})
  189. set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
  190. set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Debug] dwarf)
  191. set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE NO)
  192. set(CMAKE_XCODE_ATTRIBUTE_ENABLE_NS_ASSERTIONS NO)
  193. set(CMAKE_XCODE_ATTRIBUTE_ENABLE_NS_ASSERTIONS[variant=Debug] YES)
  194. set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION NO)
  195. set(CMAKE_XCODE_ATTRIBUTE_MARKETING_VERSION ${APP_SHORT_VERSION})
  196. set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO)
  197. set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH[variant=Debug] YES)
  198. #Check for endian
  199. if(${CMAKE_VERSION} VERSION_LESS "3.20.0")
  200. include(TestBigEndian)
  201. test_big_endian(VCMI_ENDIAN_BIG)
  202. if(VCMI_ENDIAN_BIG)
  203. add_definitions(-DVCMI_ENDIAN_BIG)
  204. endif()
  205. elseif(${CMAKE_CXX_BYTE_ORDER} EQUAL "BIG_ENDIAN")
  206. add_definitions(-DVCMI_ENDIAN_BIG)
  207. endif()
  208. if(ENABLE_LAUNCHER)
  209. add_definitions(-DENABLE_LAUNCHER)
  210. endif()
  211. if(ENABLE_EDITOR)
  212. add_definitions(-DENABLE_EDITOR)
  213. endif()
  214. if(ENABLE_SINGLE_APP_BUILD)
  215. add_definitions(-DSINGLE_PROCESS_APP=1)
  216. endif()
  217. if(APPLE_IOS)
  218. set(CMAKE_MACOSX_RPATH 1)
  219. set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0)
  220. if(NOT USING_CONAN)
  221. list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_PREFIX_PATH}") # required for Boost
  222. set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH FALSE)
  223. set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE)
  224. endif()
  225. set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED NO)
  226. set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED_FOR_APPS YES)
  227. set(CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${BUNDLE_IDENTIFIER_PREFIX}.$(PRODUCT_NAME)")
  228. set(CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2")
  229. endif()
  230. if(APPLE_MACOS)
  231. # Not supported by standard library of our current minimal target - macOS 10.14 or newer required
  232. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-aligned-allocation")
  233. endif()
  234. if(MINGW OR MSVC)
  235. # Windows Vista or newer for FuzzyLite 6 to compile
  236. # Except for conan which already has this definition in its preset
  237. if(NOT USING_CONAN)
  238. add_definitions(-D_WIN32_WINNT=0x0600)
  239. endif()
  240. #delete lib prefix for dlls (libvcmi -> vcmi)
  241. set(CMAKE_SHARED_LIBRARY_PREFIX "")
  242. if(MSVC)
  243. if(ENABLE_CCACHE)
  244. # https://github.com/ccache/ccache/discussions/1154#discussioncomment-3611387
  245. file(COPY_FILE
  246. ${CCACHE} ${CMAKE_BINARY_DIR}/cl.exe
  247. ONLY_IF_DIFFERENT)
  248. set(CMAKE_VS_GLOBALS
  249. "CLToolExe=cl.exe"
  250. "CLToolPath=${CMAKE_BINARY_DIR}"
  251. "TrackFileAccess=false"
  252. "UseMultiToolTask=true"
  253. )
  254. endif()
  255. add_definitions(-DBOOST_ALL_NO_LIB)
  256. add_definitions(-DBOOST_ALL_DYN_LINK)
  257. set(Boost_USE_STATIC_LIBS OFF)
  258. # Don't link with SDLMain
  259. if(ENABLE_DEBUG_CONSOLE)
  260. set(SDL2_BUILDING_LIBRARY ON)
  261. add_definitions(-DVCMI_WITH_DEBUG_CONSOLE)
  262. endif()
  263. # Suppress warnings
  264. add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  265. add_definitions(-D_SCL_SECURE_NO_WARNINGS)
  266. add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) # Fix gtest and gmock build
  267. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
  268. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
  269. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250") # 4250: 'class1' : inherits 'class2::member' via dominance
  270. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") # 4251: class 'xxx' needs to have dll-interface to be used by clients of class 'yyy'
  271. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244") # 4244: conversion from 'xxx' to 'yyy', possible loss of data
  272. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") # 4267: conversion from 'xxx' to 'yyy', possible loss of data
  273. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4275") # 4275: non dll-interface class 'xxx' used as base for dll-interface class
  274. #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800") # 4800: implicit conversion from 'xxx' to bool. Possible information loss
  275. if(ENABLE_STRICT_COMPILATION)
  276. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") # Treats all compiler warnings as errors
  277. endif()
  278. if(ENABLE_MULTI_PROCESS_BUILDS)
  279. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
  280. endif()
  281. # Workaround: Visual Studio has issues with exports of classes that inherit templates
  282. # https://stackoverflow.com/questions/44960760/msvc-dll-exporting-class-that-inherits-from-template-cause-lnk2005-already-defin
  283. # Reported to Microsoft here:
  284. # https://developercommunity.visualstudio.com/content/problem/224597/linker-failing-because-of-multiple-definitions-of.html
  285. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /FORCE:MULTIPLE")
  286. # Required at least for compatibility with Boost 1.68 on Vcpkg
  287. set(SYSTEM_LIBS ${SYSTEM_LIBS} bcrypt)
  288. endif(MSVC)
  289. if(MINGW)
  290. # Temporary (?) workaround for failing builds on MinGW CI due to bug in TBB
  291. set(CMAKE_CXX_EXTENSIONS ON)
  292. set(SYSTEM_LIBS ${SYSTEM_LIBS} ole32 oleaut32 ws2_32 mswsock dbghelp bcrypt)
  293. # Check for iconv (may be needed for Boost.Locale)
  294. include(CheckLibraryExists)
  295. check_library_exists(iconv libiconv_open "" ICONV_FOUND)
  296. if(ICONV_FOUND)
  297. set(SYSTEM_LIBS ${SYSTEM_LIBS} iconv)
  298. endif()
  299. # Prevent compiler issues when building Debug
  300. # Assembler might fail with "too many sections"
  301. # With big-obj or 64-bit build will take hours
  302. if(CMAKE_BUILD_TYPE MATCHES Debug)
  303. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og")
  304. endif()
  305. endif(MINGW)
  306. endif(MINGW OR MSVC)
  307. if(ANDROID)
  308. if(ANDROID_NDK_MAJOR LESS 23 AND ANDROID_ABI MATCHES "^armeabi")
  309. # libunwind must come before other shared libs:
  310. # https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Unwinding
  311. list(APPEND SYSTEM_LIBS unwind)
  312. endif()
  313. list(APPEND SYSTEM_LIBS log)
  314. endif()
  315. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR NOT WIN32)
  316. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
  317. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith")
  318. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuninitialized")
  319. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0 OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
  320. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmismatched-tags")
  321. endif()
  322. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") # low chance of valid reports, a lot of emitted warnings
  323. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch") # large number of false-positives, disabled
  324. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder") # large number of noise, low chance of any significant issues
  325. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare") # low chance of any significant issues
  326. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-varargs") # emitted in fuzzylite headers, disabled
  327. if(ENABLE_STRICT_COMPILATION)
  328. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
  329. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=array-bounds") # false positives in boost::multiarray during release build, keep as warning-only
  330. endif()
  331. # Fix string inspection with lldb
  332. # https://stackoverflow.com/questions/58578615/cannot-inspect-a-stdstring-variable-in-lldb
  333. if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  334. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstandalone-debug")
  335. endif()
  336. if(UNIX)
  337. set(SYSTEM_LIBS ${SYSTEM_LIBS} ${CMAKE_DL_LIBS})
  338. endif()
  339. endif()
  340. # Check if some platform-specific libraries are needed for linking
  341. if(NOT WIN32 AND NOT APPLE_IOS)
  342. include(CheckLibraryExists)
  343. # Shared memory functions used by Boost.Interprocess
  344. # FindBoost handle linking with pthreads, but doesn't handle this
  345. CHECK_LIBRARY_EXISTS(rt shm_open "" HAVE_RT_LIB)
  346. if(HAVE_RT_LIB)
  347. set(SYSTEM_LIBS ${SYSTEM_LIBS} rt)
  348. endif()
  349. if(HAIKU)
  350. set(SYSTEM_LIBS ${SYSTEM_LIBS} network)
  351. endif()
  352. endif()
  353. if(ENABLE_LUA)
  354. add_definitions(-DSCRIPTING_ENABLED=1)
  355. endif()
  356. if(USING_CONAN AND (MINGW AND CMAKE_HOST_UNIX))
  357. # Hack for workaround https://github.com/conan-io/conan-center-index/issues/15405
  358. # Remove once it will be fixed
  359. execute_process(COMMAND
  360. bash -c "grep -rl Mf ${CONAN_INSTALL_FOLDER} | xargs sed -i 's/Mf/mf/g'"
  361. )
  362. # Hack for workaround ffmpeg broken linking (conan ffmpeg forgots to link to ws2_32)
  363. # Remove once it will be fixed
  364. execute_process(COMMAND
  365. bash -c "grep -rl secur32 ${CONAN_INSTALL_FOLDER} | xargs sed -i 's/secur32)/secur32 ws2_32)/g'"
  366. )
  367. execute_process(COMMAND
  368. bash -c "grep -rl secur32 ${CONAN_INSTALL_FOLDER} | xargs sed -i 's/secur32 mfplat/secur32 ws2_32 mfplat/g'"
  369. )
  370. # Fixup tbb for cross-compiling on Conan
  371. # Remove once it will be fixed
  372. execute_process(COMMAND
  373. bash -c "grep -rl tbb12 ${CONAN_INSTALL_FOLDER} | xargs sed -i 's/tbb tbb12/tbb12/g'"
  374. )
  375. endif()
  376. ############################################
  377. # Finding packages #
  378. ############################################
  379. find_package(Boost 1.48.0 REQUIRED COMPONENTS date_time filesystem locale program_options system thread)
  380. find_package(ZLIB REQUIRED)
  381. # Conan compatibility
  382. if(TARGET zlib::zlib)
  383. add_library(ZLIB::ZLIB ALIAS zlib::zlib)
  384. endif()
  385. set(FFMPEG_COMPONENTS avutil swscale avformat avcodec)
  386. if(APPLE_IOS AND NOT USING_CONAN)
  387. list(APPEND FFMPEG_COMPONENTS swresample)
  388. endif()
  389. find_package(ffmpeg COMPONENTS ${FFMPEG_COMPONENTS})
  390. option(FORCE_BUNDLED_MINIZIP "Force bundled Minizip library" OFF)
  391. if(NOT FORCE_BUNDLED_MINIZIP)
  392. find_package(minizip)
  393. if(TARGET minizip::minizip)
  394. add_definitions(-DUSE_SYSTEM_MINIZIP)
  395. endif()
  396. endif()
  397. find_package(SDL2 REQUIRED)
  398. find_package(SDL2_image REQUIRED)
  399. if(TARGET SDL2_image::SDL2_image)
  400. add_library(SDL2::Image ALIAS SDL2_image::SDL2_image)
  401. endif()
  402. find_package(SDL2_mixer REQUIRED)
  403. if(TARGET SDL2_mixer::SDL2_mixer)
  404. add_library(SDL2::Mixer ALIAS SDL2_mixer::SDL2_mixer)
  405. endif()
  406. find_package(SDL2_ttf REQUIRED)
  407. if(TARGET SDL2_ttf::SDL2_ttf)
  408. add_library(SDL2::TTF ALIAS SDL2_ttf::SDL2_ttf)
  409. endif()
  410. if(ENABLE_LOBBY)
  411. find_package(SQLite3 REQUIRED)
  412. endif()
  413. if(ENABLE_LAUNCHER OR ENABLE_EDITOR)
  414. # Widgets finds its own dependencies (QtGui and QtCore).
  415. find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network)
  416. find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network)
  417. if(ENABLE_TRANSLATIONS)
  418. find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS LinguistTools)
  419. add_definitions(-DENABLE_QT_TRANSLATIONS)
  420. endif()
  421. endif()
  422. if(ENABLE_NULLKILLER_AI)
  423. find_package(TBB REQUIRED)
  424. endif()
  425. if(ENABLE_LUA)
  426. find_package(luajit)
  427. if(TARGET luajit::luajit)
  428. message(STATUS "Using LuaJIT provided by system")
  429. else()
  430. message(STATUS "Cannot find LuaJIT! Fallback to using usual Lua.")
  431. find_package(Lua REQUIRED)
  432. if(Lua_FOUND)
  433. add_library(luajit::luajit UNKNOWN IMPORTED)
  434. set_target_properties(luajit::luajit PROPERTIES
  435. INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}")
  436. set_target_properties(luajit::luajit PROPERTIES
  437. IMPORTED_LOCATION "${LUA_LIBRARIES}")
  438. endif()
  439. endif()
  440. endif()
  441. ############################################
  442. # Output directories #
  443. ############################################
  444. if(WIN32) # on Win everything goes into H3 root directory
  445. set(BIN_DIR "." CACHE STRING "Where to install binaries")
  446. set(LIB_DIR "." CACHE STRING "Where to install main library")
  447. set(DATA_DIR "." CACHE STRING "Where to install data files")
  448. elseif(APPLE)
  449. # includes lib path which determines where to install shared libraries (either /lib or /lib64)
  450. include(GNUInstallDirs)
  451. set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks")
  452. if(ENABLE_MONOLITHIC_INSTALL)
  453. set(BIN_DIR "." CACHE STRING "Where to install binaries")
  454. set(LIB_DIR "." CACHE STRING "Where to install main library")
  455. set(DATA_DIR "." CACHE STRING "Where to install data files")
  456. else()
  457. if(APPLE_MACOS)
  458. set(APP_BUNDLE_DIR "${CMAKE_PROJECT_NAME}.app")
  459. set(APP_BUNDLE_CONTENTS_DIR "${APP_BUNDLE_DIR}/Contents")
  460. set(APP_BUNDLE_BINARY_DIR "${APP_BUNDLE_CONTENTS_DIR}/MacOS")
  461. set(APP_BUNDLE_RESOURCES_DIR "${APP_BUNDLE_CONTENTS_DIR}/Resources")
  462. set(BIN_DIR "${APP_BUNDLE_BINARY_DIR}" CACHE STRING "Where to install binaries")
  463. set(LIB_DIR "${APP_BUNDLE_CONTENTS_DIR}/Frameworks" CACHE STRING "Where to install main library")
  464. set(DATA_DIR "${APP_BUNDLE_RESOURCES_DIR}/Data" CACHE STRING "Where to install data files")
  465. else()
  466. set(LIB_DIR "Frameworks")
  467. set(DATA_DIR ".")
  468. endif()
  469. endif()
  470. elseif(ANDROID)
  471. include(GNUInstallDirs)
  472. set(LIB_DIR "jniLibs/${ANDROID_ABI}")
  473. set(DATA_DIR "assets")
  474. else()
  475. # includes lib path which determines where to install shared libraries (either /lib or /lib64)
  476. include(GNUInstallDirs)
  477. if(ENABLE_MONOLITHIC_INSTALL)
  478. set(BIN_DIR "." CACHE STRING "Where to install binaries")
  479. set(LIB_DIR "." CACHE STRING "Where to install main library")
  480. set(DATA_DIR "." CACHE STRING "Where to install data files")
  481. # following constants only used for platforms using XDG (Linux, BSD, etc)
  482. add_definitions(-DM_DATA_DIR="${DATA_DIR}")
  483. add_definitions(-DM_BIN_DIR="${BIN_DIR}")
  484. add_definitions(-DM_LIB_DIR="${LIB_DIR}")
  485. set(CMAKE_INSTALL_RPATH "$ORIGIN/")
  486. else()
  487. if(NOT BIN_DIR)
  488. set(BIN_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING "Where to install binaries")
  489. endif()
  490. if(NOT LIB_DIR)
  491. set(LIB_DIR "${CMAKE_INSTALL_LIBDIR}/vcmi" CACHE STRING "Where to install main library")
  492. endif()
  493. if(NOT DATA_DIR)
  494. set(DATA_DIR "${CMAKE_INSTALL_DATAROOTDIR}/vcmi" CACHE STRING "Where to install data files")
  495. endif()
  496. # following constants only used for platforms using XDG (Linux, BSD, etc)
  497. add_definitions(-DM_DATA_DIR="${CMAKE_INSTALL_PREFIX}/${DATA_DIR}")
  498. add_definitions(-DM_BIN_DIR="${CMAKE_INSTALL_PREFIX}/${BIN_DIR}")
  499. add_definitions(-DM_LIB_DIR="${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
  500. set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
  501. endif()
  502. endif()
  503. # iOS/Android have flat libs directory structure
  504. if(APPLE_IOS OR ANDROID)
  505. set(AI_LIB_DIR "${LIB_DIR}")
  506. set(SCRIPTING_LIB_DIR "${LIB_DIR}")
  507. else()
  508. set(AI_LIB_DIR "${LIB_DIR}/AI")
  509. set(SCRIPTING_LIB_DIR "${LIB_DIR}/scripting")
  510. endif()
  511. #######################################
  512. # Add subdirectories #
  513. #######################################
  514. if(APPLE_IOS)
  515. add_subdirectory(ios)
  516. endif()
  517. set(VCMI_LIB_TARGET vcmi)
  518. add_subdirectory_with_folder("AI" AI)
  519. include(VCMI_lib)
  520. add_subdirectory(lib)
  521. if(ENABLE_SINGLE_APP_BUILD)
  522. add_subdirectory(lib_server)
  523. endif()
  524. if(ENABLE_ERM)
  525. add_subdirectory(scripting/erm)
  526. endif()
  527. if(ENABLE_LUA)
  528. add_subdirectory(scripting/lua)
  529. endif()
  530. if(NOT TARGET minizip::minizip)
  531. add_subdirectory_with_folder("3rdparty" lib/minizip)
  532. add_library(minizip::minizip ALIAS minizip)
  533. endif()
  534. if(ENABLE_LAUNCHER)
  535. add_subdirectory(launcher)
  536. endif()
  537. if(ENABLE_EDITOR)
  538. add_subdirectory(mapeditor)
  539. endif()
  540. if(ENABLE_LOBBY)
  541. add_subdirectory(lobby)
  542. endif()
  543. add_subdirectory(client)
  544. add_subdirectory(server)
  545. if(ENABLE_TEST)
  546. enable_testing()
  547. add_subdirectory(test)
  548. endif()
  549. #######################################
  550. # Installation section #
  551. #######################################
  552. if(ANDROID)
  553. if(ANDROID_STL MATCHES "_shared$")
  554. set(stlLibName "${CMAKE_SHARED_LIBRARY_PREFIX}${ANDROID_STL}${CMAKE_SHARED_LIBRARY_SUFFIX}")
  555. install(FILES "${CMAKE_SYSROOT}/usr/lib/${ANDROID_SYSROOT_LIB_SUBDIR}/${stlLibName}"
  556. DESTINATION ${LIB_DIR}
  557. )
  558. endif()
  559. # zip internal assets - 'config' and 'Mods' dirs, save md5 of the zip
  560. install(CODE "
  561. cmake_path(ABSOLUTE_PATH CMAKE_INSTALL_PREFIX
  562. OUTPUT_VARIABLE absolute_install_prefix
  563. )
  564. set(absolute_data_dir \"\${absolute_install_prefix}/${DATA_DIR}\")
  565. file(MAKE_DIRECTORY \"\${absolute_data_dir}\")
  566. set(internal_data_zip \"\${absolute_data_dir}/internalData.zip\")
  567. execute_process(COMMAND
  568. \"${CMAKE_COMMAND}\" -E tar c \"\${internal_data_zip}\" --format=zip -- config Mods
  569. WORKING_DIRECTORY \"${CMAKE_SOURCE_DIR}\"
  570. )
  571. file(MD5 \"\${internal_data_zip}\" internal_data_zip_md5)
  572. file(WRITE \"\${absolute_data_dir}/internalDataHash.txt\"
  573. \${internal_data_zip_md5}
  574. )
  575. ")
  576. else()
  577. install(DIRECTORY config DESTINATION ${DATA_DIR})
  578. install(DIRECTORY Mods DESTINATION ${DATA_DIR})
  579. endif()
  580. if(ENABLE_LUA)
  581. install(DIRECTORY scripts DESTINATION ${DATA_DIR})
  582. endif()
  583. # that script is useless for Windows / iOS / Android
  584. if(NOT WIN32 AND NOT APPLE_IOS AND NOT ANDROID)
  585. install(FILES vcmibuilder DESTINATION ${BIN_DIR} PERMISSIONS
  586. OWNER_WRITE OWNER_READ OWNER_EXECUTE
  587. GROUP_READ GROUP_EXECUTE
  588. WORLD_READ WORLD_EXECUTE)
  589. endif()
  590. if(WIN32)
  591. if(USING_CONAN)
  592. #Conan imports enabled
  593. vcmi_install_conan_deps("\${CMAKE_INSTALL_PREFIX}")
  594. file(GLOB dep_files
  595. ${dep_files}
  596. "${CMAKE_SYSROOT}/bin/*.dll"
  597. "${CMAKE_SYSROOT}/lib/*.dll"
  598. "${CONAN_SYSTEM_LIBRARY_LOCATION}/*.dll")
  599. else()
  600. file(GLOB dep_files
  601. ${dep_files}
  602. "${CMAKE_FIND_ROOT_PATH}/bin/*.dll")
  603. endif()
  604. if(CMAKE_BUILD_TYPE MATCHES Debug)
  605. # Copy debug versions of libraries if build type is debug
  606. set(debug_postfix d)
  607. endif()
  608. if(ENABLE_LAUNCHER OR ENABLE_EDITOR)
  609. get_target_property(QtCore_location Qt${QT_VERSION_MAJOR}::Core LOCATION)
  610. get_filename_component(Qtbin_folder ${QtCore_location} PATH)
  611. file(GLOB dep_files
  612. ${dep_files}
  613. ${Qtbin_folder}/Qt5Core${debug_postfix}.dll
  614. ${Qtbin_folder}/Qt5Gui${debug_postfix}.dll
  615. ${Qtbin_folder}/Qt5Widgets${debug_postfix}.dll
  616. ${Qtbin_folder}/Qt5Network${debug_postfix}.dll
  617. ${Qtbin_folder}/icu*.dll)
  618. get_target_property(integration_type Qt${QT_VERSION_MAJOR}::QWindowsIntegrationPlugin TYPE)
  619. if(NOT(integration_type STREQUAL "INTERFACE_LIBRARY"))
  620. get_target_property(integration_loc Qt${QT_VERSION_MAJOR}::QWindowsIntegrationPlugin LOCATION)
  621. install(
  622. FILES ${integration_loc}
  623. DESTINATION ${BIN_DIR}/platforms
  624. )
  625. install(
  626. FILES "$<TARGET_FILE:Qt${QT_VERSION_MAJOR}::QWindowsVistaStylePlugin>"
  627. DESTINATION ${BIN_DIR}/styles)
  628. endif()
  629. endif()
  630. install(FILES ${dep_files} DESTINATION ${BIN_DIR})
  631. endif(WIN32)
  632. #######################################
  633. # Packaging section #
  634. #######################################
  635. if(MSVC)
  636. SET(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ${BIN_DIR})
  637. Include(InstallRequiredSystemLibraries)
  638. endif()
  639. set(CPACK_PACKAGE_VERSION_MAJOR ${VCMI_VERSION_MAJOR})
  640. set(CPACK_PACKAGE_VERSION_MINOR ${VCMI_VERSION_MINOR})
  641. set(CPACK_PACKAGE_VERSION_PATCH ${VCMI_VERSION_PATCH})
  642. # vcmi does not have "patch version" in version string
  643. set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
  644. #TODO: remove version from Global.h and use this one as define?
  645. set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
  646. if("${PACKAGE_NAME_SUFFIX}" STREQUAL "")
  647. set(CPACK_PACKAGE_NAME "VCMI")
  648. else()
  649. set(CPACK_PACKAGE_NAME "VCMI ${PACKAGE_NAME_SUFFIX}")
  650. endif()
  651. if("${PACKAGE_FILE_NAME}" STREQUAL "")
  652. set(CPACK_PACKAGE_FILE_NAME "vcmi-${CPACK_PACKAGE_VERSION}")
  653. else()
  654. set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME}")
  655. endif()
  656. set(CPACK_PACKAGE_VENDOR "VCMI team")
  657. if(WIN32)
  658. # Note: due to NSI script generation process all of the backward slashes here are useful
  659. set(CPACK_MONOLITHIC_INSTALL 1)
  660. set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/license.txt")
  661. set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
  662. if("${PACKAGE_NAME_SUFFIX}" STREQUAL "")
  663. set(CPACK_NSIS_PACKAGE_NAME "VCMI ${CPACK_PACKAGE_VERSION}")
  664. else()
  665. set(CPACK_NSIS_PACKAGE_NAME "VCMI ${CPACK_PACKAGE_VERSION} ${PACKAGE_NAME_SUFFIX} ")
  666. endif()
  667. if(CMAKE_SYSTEM_PROCESSOR MATCHES ".*64")
  668. set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
  669. else()
  670. set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
  671. endif()
  672. if(ENABLE_LAUNCHER)
  673. set(VCMI_MAIN_EXECUTABLE "VCMI_launcher")
  674. else()
  675. set(VCMI_MAIN_EXECUTABLE "VCMI_client")
  676. endif()
  677. set(CPACK_PACKAGE_EXECUTABLES "${VCMI_MAIN_EXECUTABLE};VCMI")
  678. set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
  679. CreateShortCut \\\"$DESKTOP\\\\VCMI.lnk\\\" \\\"$INSTDIR\\\\${VCMI_MAIN_EXECUTABLE}.exe\\\"
  680. ExecShell '' 'netsh' 'advfirewall firewall add rule name=vcmi_server dir=in action=allow program=\\\"$INSTDIR\\\\vcmi_server.exe\\\" enable=yes profile=public,private' SW_HIDE
  681. ")
  682. set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
  683. Delete \\\"$DESKTOP\\\\VCMI.lnk\\\"
  684. ExecShell '' 'netsh' 'advfirewall firewall delete rule name=vcmi_server' SW_HIDE
  685. ")
  686. # Strip MinGW CPack target if build configuration without debug info
  687. if(MINGW)
  688. if(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug") OR (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
  689. set(CPACK_STRIP_FILES ON)
  690. endif()
  691. endif()
  692. # set the install/unistall icon used for the installer itself
  693. # There is a bug in NSI that does not handle full unix paths properly.
  694. set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/client\\\\vcmi.ico")
  695. set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/client\\\\vcmi.ico")
  696. # set the package header icon for MUI
  697. set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/client\\\\vcmi.ico")
  698. set(CPACK_NSIS_MENU_LINKS "http://vcmi.eu/" "VCMI Web Site")
  699. set(CPACK_NSIS_INSTALLED_ICON_NAME "VCMI_client.exe")
  700. set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
  701. set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_PACKAGE_NAME}, open-source engine for Heroes of Might and Magic III ")
  702. set(CPACK_NSIS_HELP_LINK "http://vcmi.eu/")
  703. set(CPACK_NSIS_URL_INFO_ABOUT "http://vcmi.eu/")
  704. set(CPACK_NSIS_CONTACT @CPACK_PACKAGE_CONTACT@)
  705. set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
  706. # Use BundleUtilities to fix build when Vcpkg is used and disable it for mingw
  707. if(NOT (${CMAKE_CROSSCOMPILING}))
  708. add_subdirectory(win)
  709. endif()
  710. elseif(APPLE_MACOS AND NOT ENABLE_MONOLITHIC_INSTALL)
  711. set(CPACK_MONOLITHIC_INSTALL 1)
  712. set(CPACK_GENERATOR "DragNDrop")
  713. set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/osx/dmg_background.png")
  714. # Workaround for this issue:
  715. # CPack Error: Error executing: /usr/bin/hdiutil detach "/Volumes/VCMI"
  716. # https://github.com/actions/runner-images/issues/7522#issuecomment-1564467252
  717. set(CPACK_COMMAND_HDIUTIL "/usr/bin/sudo /usr/bin/hdiutil")
  718. # CMake code for CPACK_DMG_DS_STORE executed before DS_STORE_SETUP_SCRIPT
  719. # So we can keep both enabled and this shouldn't hurt
  720. # set(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/osx/dmg_DS_Store")
  721. set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_SOURCE_DIR}/osx/DS_Store_Setup.scpt")
  722. # Always use "VCMI" as volume name so full path will be /Volumes/VCMI/
  723. # Otherwise DMG background image wouldn't work
  724. # Pre-generated DS_Store use absolute path to background image
  725. set(CPACK_DMG_VOLUME_NAME "${CMAKE_PROJECT_NAME}")
  726. include(GetGitRevisionDescription)
  727. get_git_head_revision(GIT_REFSPEC GIT_SHA1)
  728. string(TIMESTAMP CURRENT_YEAR "%Y")
  729. set(MACOSX_BUNDLE_NAME "${CMAKE_PROJECT_NAME}")
  730. set(MACOSX_BUNDLE_BUNDLE_NAME "${CMAKE_PROJECT_NAME}")
  731. set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2007-${CURRENT_YEAR} VCMI team")
  732. set(MACOSX_BUNDLE_GUI_IDENTIFIER "eu.vcmi.vcmi")
  733. set(MACOSX_BUNDLE_BUNDLE_VERSION ${GIT_SHA1})
  734. set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${APP_SHORT_VERSION})
  735. if(ENABLE_LAUNCHER)
  736. set(MACOSX_BUNDLE_EXECUTABLE_NAME "vcmilauncher")
  737. else()
  738. set(MACOSX_BUNDLE_EXECUTABLE_NAME "vcmiclient")
  739. endif()
  740. set(MACOSX_BUNDLE_ICON_FILE "vcmi.icns")
  741. install(FILES "${CMAKE_SOURCE_DIR}/osx/vcmi.icns" DESTINATION ${APP_BUNDLE_RESOURCES_DIR})
  742. configure_file("${CMAKE_SOURCE_DIR}/osx/Info.plist.in" "${CMAKE_BINARY_DIR}/Info.plist")
  743. install(FILES "${CMAKE_BINARY_DIR}/Info.plist" DESTINATION ${APP_BUNDLE_CONTENTS_DIR})
  744. # Bundle fixing code must be in separate directory to be executed after all other install code
  745. add_subdirectory(osx)
  746. elseif(APPLE_IOS)
  747. set(CPACK_GENERATOR ZIP)
  748. set(CPACK_ARCHIVE_FILE_EXTENSION ipa)
  749. set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
  750. set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_CURRENT_BINARY_DIR};${CMAKE_PROJECT_NAME};app;/")
  751. else()
  752. set(CPACK_GENERATOR TGZ)
  753. endif()
  754. include(CPack)