CMakeLists.txt 31 KB

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