2017-08-15 20:18:02 +02:00
|
|
|
# Minimum required version greatly affect CMake behavior
|
|
|
|
# So cmake_minimum_required must be called before the project()
|
2024-06-24 03:23:26 +02:00
|
|
|
# 3.16.0 is used since it's used by our currently oldest supported system: Ubuntu-20.04
|
2023-01-31 18:21:49 +02:00
|
|
|
cmake_minimum_required(VERSION 3.16.0)
|
2017-08-15 20:18:02 +02:00
|
|
|
|
2017-08-15 20:17:00 +02:00
|
|
|
project(VCMI)
|
2017-08-12 20:58:09 +02:00
|
|
|
# TODO
|
2017-08-16 13:52:39 +02:00
|
|
|
# Vckpg:
|
|
|
|
# - Improve install code once there is better way to deploy DLLs and Qt plugins
|
|
|
|
#
|
2017-08-15 20:18:02 +02:00
|
|
|
# Other:
|
|
|
|
# - Cleanup remove_directory copy_directory if performance will be a problem.
|
|
|
|
# We can use some macro over copy_if_different since it's only work for single file.
|
|
|
|
# - Find a way to move add_custom_command for assets deploy out of "lib/CMakeLists.txt"
|
|
|
|
# - Consider to remove M_DATA_DIR, DM_BIN_DIR, DM_LIB_DIR and not use them in code as well
|
|
|
|
# - Try to get rid of FOLDER override with define_property
|
|
|
|
# It's used currently to make sure that 3rd-party dependencies in git submodules get proper FOLDER property
|
2017-08-16 02:44:34 +02:00
|
|
|
# - Make FindFuzzyLite check for the right version and disable FORCE_BUNDLED_FL by default
|
2017-08-15 20:18:02 +02:00
|
|
|
|
2021-03-01 10:38:21 +02:00
|
|
|
if(APPLE)
|
2024-02-06 00:36:35 +02:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
2021-03-02 02:56:54 +02:00
|
|
|
set(APPLE_MACOS 1)
|
|
|
|
else()
|
|
|
|
set(APPLE_IOS 1)
|
|
|
|
endif()
|
2022-08-15 09:44:45 +02:00
|
|
|
endif()
|
2021-03-01 10:38:21 +02:00
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
############################################
|
|
|
|
# User-provided options #
|
|
|
|
############################################
|
2012-07-01 17:27:41 +03:00
|
|
|
|
2017-08-15 20:17:00 +02:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
|
|
|
|
"Choose the type of build, options are: Debug Release RelWithDebInfo. Default is RelWithDebInfo."
|
|
|
|
FORCE)
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo)
|
|
|
|
endif()
|
2012-07-01 17:27:41 +03:00
|
|
|
|
2024-02-10 19:57:23 +02:00
|
|
|
# Platform-independent options
|
2023-02-25 09:15:09 +02:00
|
|
|
|
2024-03-27 16:49:19 +02:00
|
|
|
option(ENABLE_CLIENT "Enable compilation of game client" ON)
|
2022-09-21 16:47:57 +02:00
|
|
|
option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
|
|
|
|
option(ENABLE_LUA "Enable compilation of LUA scripting module" OFF)
|
2022-12-25 23:09:15 +02:00
|
|
|
option(ENABLE_TRANSLATIONS "Enable generation of translations for launcher and editor" ON)
|
2022-12-15 02:18:17 +02:00
|
|
|
option(ENABLE_NULLKILLER_AI "Enable compilation of Nullkiller AI library" ON)
|
2024-03-27 19:30:07 +02:00
|
|
|
option(ENABLE_MINIMAL_LIB "Build only core parts of vcmi library that are required for game lobby" OFF)
|
2024-04-25 17:52:25 +02:00
|
|
|
option(ENABLE_GOLDMASTER "Build in public release mode in which some debug routines are disabled" OFF)
|
2024-02-10 19:57:23 +02:00
|
|
|
|
|
|
|
# Compilation options
|
|
|
|
|
|
|
|
option(ENABLE_PCH "Enable compilation using precompiled headers" ON)
|
|
|
|
option(ENABLE_DEBUG_CONSOLE "Enable debug console for Windows builds" ON)
|
|
|
|
option(ENABLE_STRICT_COMPILATION "Treat all compiler warnings as errors" OFF)
|
|
|
|
option(ENABLE_MULTI_PROCESS_BUILDS "Enable /MP flag for MSVS solution" ON)
|
|
|
|
option(ENABLE_COLORIZED_COMPILER_OUTPUT "Colorize compilation output (Clang/GNU)." ON)
|
|
|
|
option(ENABLE_CCACHE "Speed up recompilation by caching previous compilations" OFF)
|
|
|
|
|
|
|
|
# Platform-specific options
|
|
|
|
|
|
|
|
if(ANDROID)
|
2024-07-04 16:44:25 +02:00
|
|
|
set(ANDROID_TARGET_SDK_VERSION "34" CACHE STRING "Android target SDK version")
|
2024-03-02 23:24:00 +02:00
|
|
|
set(ANDROIDDEPLOYQT_OPTIONS "" CACHE STRING "Additional androiddeployqt options separated by semi-colon")
|
|
|
|
set(ANDROID_GRADLE_PROPERTIES "" CACHE STRING "Additional Gradle properties separated by semi-colon")
|
|
|
|
|
2024-02-11 00:00:58 +02:00
|
|
|
set(ENABLE_STATIC_LIBS ON)
|
2024-03-02 23:24:00 +02:00
|
|
|
set(ENABLE_LAUNCHER ON)
|
2024-02-10 19:57:23 +02:00
|
|
|
else()
|
2024-02-11 00:00:58 +02:00
|
|
|
option(ENABLE_STATIC_LIBS "Build library and all components such as AI statically" OFF)
|
2024-02-10 19:57:23 +02:00
|
|
|
option(ENABLE_LAUNCHER "Enable compilation of launcher" ON)
|
|
|
|
endif()
|
2022-12-25 23:10:52 +02:00
|
|
|
|
2024-03-02 23:24:00 +02:00
|
|
|
if(APPLE_IOS)
|
|
|
|
set(BUNDLE_IDENTIFIER_PREFIX "" CACHE STRING "Bundle identifier prefix")
|
|
|
|
set(APP_DISPLAY_NAME "VCMI" CACHE STRING "App name on the home screen")
|
|
|
|
endif()
|
|
|
|
|
2024-02-10 19:57:23 +02:00
|
|
|
if(APPLE_IOS OR ANDROID)
|
2024-02-11 00:00:58 +02:00
|
|
|
set(ENABLE_MONOLITHIC_INSTALL OFF)
|
2023-03-02 11:14:01 +02:00
|
|
|
set(ENABLE_SINGLE_APP_BUILD ON)
|
2024-02-10 19:57:23 +02:00
|
|
|
set(ENABLE_EDITOR OFF)
|
2024-02-10 23:56:02 +02:00
|
|
|
set(ENABLE_TEST OFF)
|
|
|
|
set(ENABLE_LOBBY OFF)
|
2024-02-11 00:46:47 +02:00
|
|
|
set(ENABLE_SERVER OFF)
|
2024-02-10 19:57:23 +02:00
|
|
|
set(COPY_CONFIG_ON_BUILD OFF)
|
2021-03-10 09:57:07 +02:00
|
|
|
else()
|
2024-02-11 00:00:58 +02:00
|
|
|
option(ENABLE_MONOLITHIC_INSTALL "Install everything in single directory on Linux and Mac" OFF) # Used for Snap packages and also useful for debugging
|
2024-02-10 19:57:23 +02:00
|
|
|
option(COPY_CONFIG_ON_BUILD "Copies config folder into output directory at building phase" ON)
|
2024-02-11 00:46:47 +02:00
|
|
|
option(ENABLE_SERVER "Enable compilation of dedicated server" ON)
|
2024-02-10 19:57:23 +02:00
|
|
|
option(ENABLE_EDITOR "Enable compilation of map editor" ON)
|
|
|
|
option(ENABLE_SINGLE_APP_BUILD "Builds client and launcher as single executable" OFF)
|
2022-11-03 10:33:17 +02:00
|
|
|
option(ENABLE_TEST "Enable compilation of unit tests" OFF)
|
2024-02-10 23:56:02 +02:00
|
|
|
option(ENABLE_LOBBY "Enable compilation of lobby server" OFF)
|
2021-03-01 10:38:21 +02:00
|
|
|
endif()
|
2023-01-31 18:21:49 +02:00
|
|
|
|
2024-02-11 00:00:58 +02:00
|
|
|
# ERM depends on LUA implicitly
|
|
|
|
if(ENABLE_ERM AND NOT ENABLE_LUA)
|
|
|
|
set(ENABLE_LUA ON)
|
|
|
|
endif()
|
|
|
|
|
2024-04-01 02:31:33 +02:00
|
|
|
include(CMakeDependentOption)
|
|
|
|
cmake_dependent_option(ENABLE_INNOEXTRACT "Enable innoextract for GOG file extraction in launcher" ON "ENABLE_LAUNCHER" OFF)
|
2024-04-25 17:52:25 +02:00
|
|
|
cmake_dependent_option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON "NOT ENABLE_GOLDMASTER" OFF)
|
2024-04-01 02:31:33 +02:00
|
|
|
|
2024-02-11 00:00:58 +02:00
|
|
|
############################################
|
|
|
|
# Miscellaneous options #
|
|
|
|
############################################
|
|
|
|
|
2024-02-11 00:46:47 +02:00
|
|
|
if (ENABLE_STATIC_LIBS AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
endif()
|
|
|
|
|
2024-01-02 12:14:27 +02:00
|
|
|
if(ENABLE_COLORIZED_COMPILER_OUTPUT)
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
2024-01-02 02:52:57 +02:00
|
|
|
add_compile_options(-fcolor-diagnostics)
|
2024-01-02 12:14:27 +02:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
2024-01-02 02:52:57 +02:00
|
|
|
add_compile_options(-fdiagnostics-color=always)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2023-12-27 22:10:56 +02:00
|
|
|
if(ENABLE_CCACHE)
|
2023-12-29 22:54:58 +02:00
|
|
|
find_program(CCACHE ccache REQUIRED)
|
2023-12-27 22:10:56 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# The XCode and MSVC builds each require some more configuration further down.
|
2024-01-04 17:00:00 +02:00
|
|
|
if(ENABLE_CCACHE)
|
2023-12-27 22:10:56 +02:00
|
|
|
set(CMAKE_C_COMPILER_LAUNCHER "ccache")
|
|
|
|
set(CMAKE_CXX_COMPILER_LAUNCHER "ccache")
|
2023-10-05 23:29:41 +02:00
|
|
|
endif()
|
|
|
|
|
2023-10-06 19:55:40 +02:00
|
|
|
if(ENABLE_CCACHE AND (CMAKE_GENERATOR STREQUAL "Xcode"))
|
2023-12-27 22:12:52 +02:00
|
|
|
# https://stackoverflow.com/a/36515503/2278742
|
|
|
|
# Set up wrapper scripts
|
|
|
|
configure_file(xcode/launch-c.in xcode/launch-c)
|
|
|
|
configure_file(xcode/launch-cxx.in xcode/launch-cxx)
|
|
|
|
execute_process(COMMAND chmod a+rx
|
|
|
|
"${CMAKE_BINARY_DIR}/xcode/launch-c"
|
|
|
|
"${CMAKE_BINARY_DIR}/xcode/launch-cxx")
|
|
|
|
# Set Xcode project attributes to route compilation through our scripts
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/xcode/launch-c")
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/xcode/launch-cxx")
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/xcode/launch-c")
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/xcode/launch-cxx")
|
2023-10-06 19:39:32 +02:00
|
|
|
endif()
|
|
|
|
|
2017-08-15 20:17:00 +02:00
|
|
|
# Allow to pass package name from Travis CI
|
|
|
|
set(PACKAGE_NAME_SUFFIX "" CACHE STRING "Suffix for CPack package name")
|
|
|
|
set(PACKAGE_FILE_NAME "" CACHE STRING "Override for CPack package filename")
|
|
|
|
|
2021-07-05 19:04:17 +02:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules ${PROJECT_SOURCE_DIR}/CI)
|
2017-08-15 20:18:02 +02:00
|
|
|
# Contains custom functions and macros, but don't altering any options
|
2022-10-22 18:54:09 +02:00
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
include(VCMIUtils)
|
2022-10-22 18:54:09 +02:00
|
|
|
include(VersionDefinition)
|
|
|
|
|
2017-09-06 11:24:39 +02:00
|
|
|
vcmi_print_important_variables()
|
2017-08-15 20:18:02 +02:00
|
|
|
|
|
|
|
# Options to enable folders in CMake generated projects for Visual Studio, Xcode, etc
|
|
|
|
# Very useful to put 3rd-party libraries such as Minizip, GoogleTest and FuzzyLite in their own folders
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS TRUE)
|
|
|
|
# Make FOLDER property inheritable
|
|
|
|
# So when we set FOLDER property on AI directory all and targets inside will inherit it
|
|
|
|
#
|
|
|
|
# Important! This trick depend on undefined behavior since we override CMake own property.
|
|
|
|
# In same time define_property documentation states it's function for custom properties.
|
|
|
|
define_property(
|
|
|
|
TARGET
|
|
|
|
PROPERTY FOLDER
|
|
|
|
INHERITED
|
|
|
|
BRIEF_DOCS "Set the folder name."
|
|
|
|
FULL_DOCS "Use to organize targets in an IDE."
|
|
|
|
)
|
|
|
|
|
|
|
|
# Generate Version.cpp
|
2017-08-16 02:44:34 +02:00
|
|
|
if(ENABLE_GITVERSION)
|
2018-02-09 18:45:50 +02:00
|
|
|
add_custom_target(update_version ALL
|
2022-07-20 15:56:17 +02:00
|
|
|
BYPRODUCTS "Version.cpp"
|
2021-07-05 19:04:17 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND} -DGIT_SHA1="${GIT_SHA1}" -P "${PROJECT_SOURCE_DIR}/cmake_modules/Version.cmake"
|
2018-02-09 18:45:50 +02:00
|
|
|
)
|
2017-08-16 02:44:34 +02:00
|
|
|
else()
|
|
|
|
add_definitions(-DVCMI_NO_EXTRA_VERSION)
|
|
|
|
endif(ENABLE_GITVERSION)
|
2017-08-15 20:18:02 +02:00
|
|
|
|
2023-01-07 18:01:39 +02:00
|
|
|
if(ENABLE_PCH)
|
2022-06-16 22:02:36 +02:00
|
|
|
macro(enable_pch name)
|
|
|
|
target_precompile_headers(${name} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:<StdInc.h$<ANGLE-R>>)
|
|
|
|
endmacro(enable_pch)
|
2023-01-07 18:01:39 +02:00
|
|
|
else()
|
2022-06-16 22:02:36 +02:00
|
|
|
macro(enable_pch ignore)
|
|
|
|
endmacro(enable_pch)
|
2023-01-07 18:01:39 +02:00
|
|
|
endif()
|
2017-08-12 20:58:09 +02:00
|
|
|
|
2015-08-22 18:49:27 +02:00
|
|
|
############################################
|
|
|
|
# Documentation section #
|
|
|
|
############################################
|
|
|
|
|
|
|
|
include(UseDoxygen OPTIONAL)
|
|
|
|
|
2012-10-05 15:38:17 +03:00
|
|
|
############################################
|
2017-08-15 20:18:02 +02:00
|
|
|
# Compile and linking options #
|
2012-10-05 15:38:17 +03:00
|
|
|
############################################
|
|
|
|
|
2023-04-10 22:32:54 +02:00
|
|
|
#Enable C++17 Globally
|
2023-04-10 16:23:21 +02:00
|
|
|
set (CMAKE_CXX_STANDARD 17)
|
2022-05-19 14:14:50 +02:00
|
|
|
#General visibility options
|
|
|
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
|
|
|
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
|
|
|
|
|
2022-05-26 07:55:20 +02:00
|
|
|
#Global fallback mapping
|
2023-01-25 17:08:40 +02:00
|
|
|
# RelWithDebInfo falls back to Release, then MinSizeRel, and then to None (tbb in 22.04 requires it)
|
|
|
|
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO RelWithDebInfo Release MinSizeRel None "")
|
|
|
|
# MinSizeRel falls back to Release, then RelWithDebInfo, and then to None (tbb in 22.04 requires it)
|
|
|
|
set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL MinSizeRel Release RelWithDebInfo None "")
|
|
|
|
# Release falls back to RelWithDebInfo, then MinSizeRel, and then to None (tbb in 22.04 requires it)
|
|
|
|
set(CMAKE_MAP_IMPORTED_CONFIG_RELEASE Release RelWithDebInfo MinSizeRel None "")
|
2022-05-26 07:55:20 +02:00
|
|
|
|
2022-09-30 10:44:13 +02:00
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_APP_DISPLAY_NAME ${APP_DISPLAY_NAME})
|
2022-08-08 16:38:57 +02:00
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Debug] dwarf)
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE NO)
|
2022-08-16 11:25:36 +02:00
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_NS_ASSERTIONS NO)
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_NS_ASSERTIONS[variant=Debug] YES)
|
2022-08-09 12:35:05 +02:00
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION NO)
|
2022-08-08 16:38:57 +02:00
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_MARKETING_VERSION ${APP_SHORT_VERSION})
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO)
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH[variant=Debug] YES)
|
|
|
|
|
2023-02-02 22:40:00 +02:00
|
|
|
#Check for endian
|
|
|
|
if(${CMAKE_VERSION} VERSION_LESS "3.20.0")
|
|
|
|
include(TestBigEndian)
|
|
|
|
test_big_endian(VCMI_ENDIAN_BIG)
|
|
|
|
if(VCMI_ENDIAN_BIG)
|
|
|
|
add_definitions(-DVCMI_ENDIAN_BIG)
|
|
|
|
endif()
|
|
|
|
elseif(${CMAKE_CXX_BYTE_ORDER} EQUAL "BIG_ENDIAN")
|
|
|
|
add_definitions(-DVCMI_ENDIAN_BIG)
|
|
|
|
endif()
|
|
|
|
|
2022-12-28 22:20:04 +02:00
|
|
|
if(ENABLE_LAUNCHER)
|
|
|
|
add_definitions(-DENABLE_LAUNCHER)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_EDITOR)
|
|
|
|
add_definitions(-DENABLE_EDITOR)
|
|
|
|
endif()
|
|
|
|
|
2022-12-06 00:00:56 +02:00
|
|
|
if(ENABLE_SINGLE_APP_BUILD)
|
2024-02-10 23:56:02 +02:00
|
|
|
add_definitions(-DENABLE_SINGLE_APP_BUILD)
|
2022-09-16 15:43:21 +02:00
|
|
|
endif()
|
|
|
|
|
2024-03-27 19:30:07 +02:00
|
|
|
if(ENABLE_MINIMAL_LIB)
|
|
|
|
add_definitions(-DENABLE_MINIMAL_LIB)
|
|
|
|
endif()
|
|
|
|
|
2024-04-25 17:52:25 +02:00
|
|
|
if(ENABLE_GOLDMASTER)
|
|
|
|
add_definitions(-DENABLE_GOLDMASTER)
|
|
|
|
endif()
|
|
|
|
|
2021-03-01 10:38:21 +02:00
|
|
|
if(APPLE_IOS)
|
2021-03-12 12:31:05 +02:00
|
|
|
set(CMAKE_MACOSX_RPATH 1)
|
2022-09-27 05:31:06 +02:00
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0)
|
2022-08-08 16:38:57 +02:00
|
|
|
|
2022-10-13 12:04:32 +02:00
|
|
|
if(NOT USING_CONAN)
|
|
|
|
list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_PREFIX_PATH}") # required for Boost
|
|
|
|
set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH FALSE)
|
|
|
|
set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE)
|
|
|
|
endif()
|
2022-08-08 16:38:57 +02:00
|
|
|
|
2021-03-12 13:01:00 +02:00
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED NO)
|
2021-12-02 14:02:34 +02:00
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED_FOR_APPS YES)
|
2021-03-13 22:23:20 +02:00
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${BUNDLE_IDENTIFIER_PREFIX}.$(PRODUCT_NAME)")
|
2022-08-08 16:38:57 +02:00
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2")
|
2022-08-15 09:44:45 +02:00
|
|
|
endif()
|
2021-03-01 10:38:21 +02:00
|
|
|
|
2023-04-10 22:32:54 +02:00
|
|
|
if(APPLE_MACOS)
|
2023-04-11 00:30:08 +02:00
|
|
|
# Not supported by standard library of our current minimal target - macOS 10.14 or newer required
|
2023-04-10 22:32:54 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-aligned-allocation")
|
|
|
|
endif()
|
|
|
|
|
2021-07-27 20:26:17 +02:00
|
|
|
if(MINGW OR MSVC)
|
2017-07-11 13:08:00 +02:00
|
|
|
# Windows Vista or newer for FuzzyLite 6 to compile
|
2023-12-15 18:58:03 +02:00
|
|
|
# Except for conan which already has this definition in its preset
|
|
|
|
if(NOT USING_CONAN)
|
|
|
|
add_definitions(-D_WIN32_WINNT=0x0600)
|
|
|
|
endif()
|
2014-07-11 00:23:06 +03:00
|
|
|
|
2014-10-12 16:38:53 +03:00
|
|
|
#delete lib prefix for dlls (libvcmi -> vcmi)
|
2017-07-06 08:09:30 +02:00
|
|
|
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
2014-07-11 17:29:46 +03:00
|
|
|
|
2014-10-12 16:38:53 +03:00
|
|
|
if(MSVC)
|
2023-10-05 23:29:41 +02:00
|
|
|
if(ENABLE_CCACHE)
|
2023-10-02 01:12:32 +02:00
|
|
|
# https://github.com/ccache/ccache/discussions/1154#discussioncomment-3611387
|
2023-12-27 22:12:52 +02:00
|
|
|
file(COPY_FILE
|
|
|
|
${CCACHE} ${CMAKE_BINARY_DIR}/cl.exe
|
|
|
|
ONLY_IF_DIFFERENT)
|
|
|
|
|
|
|
|
set(CMAKE_VS_GLOBALS
|
|
|
|
"CLToolExe=cl.exe"
|
|
|
|
"CLToolPath=${CMAKE_BINARY_DIR}"
|
|
|
|
"TrackFileAccess=false"
|
|
|
|
"UseMultiToolTask=true"
|
|
|
|
)
|
2023-10-02 01:12:32 +02:00
|
|
|
endif()
|
|
|
|
|
2014-10-12 16:38:53 +03:00
|
|
|
add_definitions(-DBOOST_ALL_NO_LIB)
|
2017-08-18 22:11:11 +02:00
|
|
|
add_definitions(-DBOOST_ALL_DYN_LINK)
|
2017-08-03 01:56:25 +02:00
|
|
|
set(Boost_USE_STATIC_LIBS OFF)
|
2014-10-12 16:38:53 +03:00
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
# Don't link with SDLMain
|
2017-08-16 15:29:18 +02:00
|
|
|
if(ENABLE_DEBUG_CONSOLE)
|
|
|
|
set(SDL2_BUILDING_LIBRARY ON)
|
|
|
|
add_definitions(-DVCMI_WITH_DEBUG_CONSOLE)
|
|
|
|
endif()
|
2014-10-12 16:38:53 +03:00
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
# Suppress warnings
|
2014-10-12 16:38:53 +03:00
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
|
|
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
|
2023-07-01 11:34:13 +02:00
|
|
|
add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) # Fix gtest and gmock build
|
2022-12-07 18:08:13 +02:00
|
|
|
|
2023-04-19 22:08:21 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
|
2022-12-07 18:08:13 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
|
2022-12-08 23:20:42 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250") # 4250: 'class1' : inherits 'class2::member' via dominance
|
2022-12-07 18:08:13 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") # 4251: class 'xxx' needs to have dll-interface to be used by clients of class 'yyy'
|
2022-12-08 23:20:42 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244") # 4244: conversion from 'xxx' to 'yyy', possible loss of data
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") # 4267: conversion from 'xxx' to 'yyy', possible loss of data
|
2022-12-07 18:08:13 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4275") # 4275: non dll-interface class 'xxx' used as base for dll-interface class
|
|
|
|
|
2022-12-07 23:35:57 +02:00
|
|
|
if(ENABLE_STRICT_COMPILATION)
|
2023-01-15 23:55:24 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") # Treats all compiler warnings as errors
|
2022-12-07 23:35:57 +02:00
|
|
|
endif()
|
2018-02-28 15:08:36 +02:00
|
|
|
|
|
|
|
if(ENABLE_MULTI_PROCESS_BUILDS)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
|
|
|
endif()
|
2018-03-28 21:02:00 +02:00
|
|
|
|
2018-03-29 06:05:48 +02:00
|
|
|
# Workaround: Visual Studio has issues with exports of classes that inherit templates
|
2018-03-28 21:02:00 +02:00
|
|
|
# https://stackoverflow.com/questions/44960760/msvc-dll-exporting-class-that-inherits-from-template-cause-lnk2005-already-defin
|
2018-03-29 06:05:48 +02:00
|
|
|
# Reported to Microsoft here:
|
|
|
|
# https://developercommunity.visualstudio.com/content/problem/224597/linker-failing-because-of-multiple-definitions-of.html
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /FORCE:MULTIPLE")
|
2018-08-27 21:19:11 +02:00
|
|
|
|
|
|
|
# Required at least for compatibility with Boost 1.68 on Vcpkg
|
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} bcrypt)
|
2017-08-16 02:44:34 +02:00
|
|
|
endif(MSVC)
|
|
|
|
|
|
|
|
if(MINGW)
|
2023-08-03 14:25:36 +02:00
|
|
|
|
|
|
|
# Temporary (?) workaround for failing builds on MinGW CI due to bug in TBB
|
|
|
|
set(CMAKE_CXX_EXTENSIONS ON)
|
|
|
|
|
2020-01-23 19:50:13 +02:00
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} ole32 oleaut32 ws2_32 mswsock dbghelp bcrypt)
|
2017-08-16 02:44:34 +02:00
|
|
|
|
|
|
|
# Check for iconv (may be needed for Boost.Locale)
|
|
|
|
include(CheckLibraryExists)
|
|
|
|
check_library_exists(iconv libiconv_open "" ICONV_FOUND)
|
|
|
|
if(ICONV_FOUND)
|
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} iconv)
|
|
|
|
endif()
|
|
|
|
endif(MINGW)
|
2021-07-27 20:26:17 +02:00
|
|
|
endif(MINGW OR MSVC)
|
2017-08-15 20:17:00 +02:00
|
|
|
|
2023-02-25 09:15:09 +02:00
|
|
|
if(ANDROID)
|
|
|
|
if(ANDROID_NDK_MAJOR LESS 23 AND ANDROID_ABI MATCHES "^armeabi")
|
|
|
|
# libunwind must come before other shared libs:
|
|
|
|
# https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Unwinding
|
|
|
|
list(APPEND SYSTEM_LIBS unwind)
|
|
|
|
endif()
|
|
|
|
list(APPEND SYSTEM_LIBS log)
|
|
|
|
endif()
|
|
|
|
|
2023-03-06 11:00:04 +02:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR NOT WIN32)
|
2022-12-07 23:35:57 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuninitialized")
|
2017-08-15 20:18:02 +02:00
|
|
|
|
2022-11-28 23:05:36 +02:00
|
|
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0 OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmismatched-tags")
|
|
|
|
endif()
|
|
|
|
|
2022-12-07 18:08:13 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") # low chance of valid reports, a lot of emitted warnings
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch") # large number of false-positives, disabled
|
2022-12-07 23:35:57 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder") # large number of noise, low chance of any significant issues
|
2022-12-07 18:08:13 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare") # low chance of any significant issues
|
2022-12-07 21:50:45 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-varargs") # emitted in fuzzylite headers, disabled
|
2022-12-07 18:08:13 +02:00
|
|
|
|
2022-12-07 23:35:57 +02:00
|
|
|
if(ENABLE_STRICT_COMPILATION)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=array-bounds") # false positives in boost::multiarray during release build, keep as warning-only
|
2017-08-15 20:18:02 +02:00
|
|
|
endif()
|
|
|
|
|
2024-05-12 19:06:46 +02:00
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2024-05-12 17:10:01 +02:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT WIN32)
|
|
|
|
# For gcc 14+ we can use -fhardened instead
|
2024-08-26 18:27:14 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_ASSERTIONS -fstack-protector-strong -fstack-clash-protection")
|
|
|
|
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcf-protection=full")
|
|
|
|
endif()
|
2024-05-12 17:10:01 +02:00
|
|
|
endif()
|
2024-04-11 12:37:46 +02:00
|
|
|
endif()
|
2024-04-11 10:43:43 +02:00
|
|
|
|
2023-03-06 11:00:04 +02:00
|
|
|
# Fix string inspection with lldb
|
|
|
|
# https://stackoverflow.com/questions/58578615/cannot-inspect-a-stdstring-variable-in-lldb
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstandalone-debug")
|
|
|
|
endif()
|
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
if(UNIX)
|
2018-02-18 09:15:19 +02:00
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} ${CMAKE_DL_LIBS})
|
2017-08-15 20:18:02 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Check if some platform-specific libraries are needed for linking
|
2021-03-04 16:21:45 +02:00
|
|
|
if(NOT WIN32 AND NOT APPLE_IOS)
|
2017-08-12 20:58:09 +02:00
|
|
|
include(CheckLibraryExists)
|
2014-07-10 00:41:31 +03:00
|
|
|
|
2017-08-16 02:44:34 +02:00
|
|
|
# Shared memory functions used by Boost.Interprocess
|
2017-08-15 20:18:02 +02:00
|
|
|
# FindBoost handle linking with pthreads, but doesn't handle this
|
2014-07-10 00:41:31 +03:00
|
|
|
CHECK_LIBRARY_EXISTS(rt shm_open "" HAVE_RT_LIB)
|
|
|
|
if(HAVE_RT_LIB)
|
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} rt)
|
|
|
|
endif()
|
2023-03-26 18:42:08 +02:00
|
|
|
if(HAIKU)
|
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} network)
|
|
|
|
endif()
|
2014-07-09 01:43:13 +03:00
|
|
|
endif()
|
|
|
|
|
2022-09-21 18:31:14 +02:00
|
|
|
if(ENABLE_LUA)
|
2022-12-06 01:33:00 +02:00
|
|
|
add_definitions(-DSCRIPTING_ENABLED=1)
|
2022-09-21 18:31:14 +02:00
|
|
|
endif()
|
|
|
|
|
2023-01-22 23:53:23 +02:00
|
|
|
if(USING_CONAN AND (MINGW AND CMAKE_HOST_UNIX))
|
|
|
|
# Hack for workaround https://github.com/conan-io/conan-center-index/issues/15405
|
|
|
|
# Remove once it will be fixed
|
|
|
|
execute_process(COMMAND
|
|
|
|
bash -c "grep -rl Mf ${CONAN_INSTALL_FOLDER} | xargs sed -i 's/Mf/mf/g'"
|
|
|
|
)
|
|
|
|
# Hack for workaround ffmpeg broken linking (conan ffmpeg forgots to link to ws2_32)
|
|
|
|
# Remove once it will be fixed
|
|
|
|
execute_process(COMMAND
|
|
|
|
bash -c "grep -rl secur32 ${CONAN_INSTALL_FOLDER} | xargs sed -i 's/secur32)/secur32 ws2_32)/g'"
|
|
|
|
)
|
|
|
|
execute_process(COMMAND
|
|
|
|
bash -c "grep -rl secur32 ${CONAN_INSTALL_FOLDER} | xargs sed -i 's/secur32 mfplat/secur32 ws2_32 mfplat/g'"
|
|
|
|
)
|
|
|
|
# Fixup tbb for cross-compiling on Conan
|
|
|
|
# Remove once it will be fixed
|
|
|
|
execute_process(COMMAND
|
|
|
|
bash -c "grep -rl tbb12 ${CONAN_INSTALL_FOLDER} | xargs sed -i 's/tbb tbb12/tbb12/g'"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
############################################
|
|
|
|
# Finding packages #
|
|
|
|
############################################
|
2015-04-09 12:19:44 +02:00
|
|
|
|
2024-04-01 02:31:33 +02:00
|
|
|
set(BOOST_COMPONENTS date_time filesystem locale program_options system thread)
|
|
|
|
if(ENABLE_INNOEXTRACT)
|
|
|
|
list(APPEND BOOST_COMPONENTS iostreams)
|
|
|
|
endif()
|
|
|
|
find_package(Boost 1.48.0 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
2022-08-30 16:29:00 +02:00
|
|
|
|
2012-07-01 17:27:41 +03:00
|
|
|
find_package(ZLIB REQUIRED)
|
2022-08-30 16:29:00 +02:00
|
|
|
# Conan compatibility
|
|
|
|
if(TARGET zlib::zlib)
|
|
|
|
add_library(ZLIB::ZLIB ALIAS zlib::zlib)
|
|
|
|
endif()
|
|
|
|
|
2022-05-26 07:55:20 +02:00
|
|
|
option(FORCE_BUNDLED_MINIZIP "Force bundled Minizip library" OFF)
|
|
|
|
if(NOT FORCE_BUNDLED_MINIZIP)
|
|
|
|
find_package(minizip)
|
|
|
|
if(TARGET minizip::minizip)
|
|
|
|
add_definitions(-DUSE_SYSTEM_MINIZIP)
|
|
|
|
endif()
|
2014-10-12 16:50:39 +03:00
|
|
|
endif()
|
2014-05-24 16:52:43 +03:00
|
|
|
|
2024-03-27 19:03:05 +02:00
|
|
|
if (ENABLE_CLIENT)
|
2024-10-01 17:25:58 +02:00
|
|
|
find_package(ffmpeg COMPONENTS avutil swscale avformat avcodec swresample)
|
2024-03-27 19:03:05 +02:00
|
|
|
|
|
|
|
find_package(SDL2 REQUIRED)
|
|
|
|
find_package(SDL2_image REQUIRED)
|
|
|
|
if(TARGET SDL2_image::SDL2_image)
|
|
|
|
add_library(SDL2::Image ALIAS SDL2_image::SDL2_image)
|
|
|
|
endif()
|
2024-09-06 18:57:37 +02:00
|
|
|
if(TARGET SDL2_image::SDL2_image-static)
|
|
|
|
add_library(SDL2::Image ALIAS SDL2_image::SDL2_image-static)
|
|
|
|
endif()
|
2024-03-27 19:03:05 +02:00
|
|
|
find_package(SDL2_mixer REQUIRED)
|
|
|
|
if(TARGET SDL2_mixer::SDL2_mixer)
|
|
|
|
add_library(SDL2::Mixer ALIAS SDL2_mixer::SDL2_mixer)
|
|
|
|
endif()
|
2024-09-06 18:57:37 +02:00
|
|
|
if(TARGET SDL2_mixer::SDL2_mixer-static)
|
|
|
|
add_library(SDL2::Mixer ALIAS SDL2_mixer::SDL2_mixer-static)
|
|
|
|
endif()
|
2024-03-27 19:03:05 +02:00
|
|
|
find_package(SDL2_ttf REQUIRED)
|
|
|
|
if(TARGET SDL2_ttf::SDL2_ttf)
|
|
|
|
add_library(SDL2::TTF ALIAS SDL2_ttf::SDL2_ttf)
|
|
|
|
endif()
|
2024-09-06 18:57:37 +02:00
|
|
|
if(TARGET SDL2_ttf::SDL2_ttf-static)
|
|
|
|
add_library(SDL2::TTF ALIAS SDL2_ttf::SDL2_ttf-static)
|
|
|
|
endif()
|
2022-05-26 07:55:20 +02:00
|
|
|
endif()
|
2015-06-21 00:54:36 +02:00
|
|
|
|
2023-11-11 16:43:58 +02:00
|
|
|
if(ENABLE_LOBBY)
|
|
|
|
find_package(SQLite3 REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2022-09-18 01:23:17 +02:00
|
|
|
if(ENABLE_LAUNCHER OR ENABLE_EDITOR)
|
2013-02-17 00:14:36 +03:00
|
|
|
# Widgets finds its own dependencies (QtGui and QtCore).
|
2023-01-07 18:01:39 +02:00
|
|
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network)
|
|
|
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network)
|
2022-12-25 23:09:15 +02:00
|
|
|
|
2022-12-27 12:28:05 +02:00
|
|
|
if(ENABLE_TRANSLATIONS)
|
2023-01-16 18:02:11 +02:00
|
|
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS LinguistTools)
|
2022-12-25 23:42:06 +02:00
|
|
|
add_definitions(-DENABLE_QT_TRANSLATIONS)
|
|
|
|
endif()
|
2013-08-19 14:50:53 +03:00
|
|
|
endif()
|
|
|
|
|
2024-07-25 16:41:37 +02:00
|
|
|
if(NOT ENABLE_MINIMAL_LIB)
|
2022-12-15 02:21:44 +02:00
|
|
|
find_package(TBB REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
if(ENABLE_LUA)
|
2022-05-26 07:55:20 +02:00
|
|
|
find_package(luajit)
|
2023-01-31 18:21:49 +02:00
|
|
|
|
2022-05-26 07:55:20 +02:00
|
|
|
if(TARGET luajit::luajit)
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
message(STATUS "Using LuaJIT provided by system")
|
|
|
|
else()
|
|
|
|
message(STATUS "Cannot find LuaJIT! Fallback to using usual Lua.")
|
|
|
|
find_package(Lua REQUIRED)
|
2022-05-26 07:55:20 +02:00
|
|
|
if(Lua_FOUND)
|
|
|
|
add_library(luajit::luajit UNKNOWN IMPORTED)
|
|
|
|
set_target_properties(luajit::luajit PROPERTIES
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}")
|
|
|
|
set_target_properties(luajit::luajit PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${LUA_LIBRARIES}")
|
|
|
|
endif()
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
############################################
|
|
|
|
# Output directories #
|
|
|
|
############################################
|
2012-07-15 19:05:41 +03:00
|
|
|
|
2012-10-05 15:38:17 +03:00
|
|
|
if(WIN32) # on Win everything goes into H3 root directory
|
2014-07-07 23:21:59 +03:00
|
|
|
set(BIN_DIR "." CACHE STRING "Where to install binaries")
|
|
|
|
set(LIB_DIR "." CACHE STRING "Where to install main library")
|
|
|
|
set(DATA_DIR "." CACHE STRING "Where to install data files")
|
2012-12-01 09:30:52 +03:00
|
|
|
elseif(APPLE)
|
|
|
|
# includes lib path which determines where to install shared libraries (either /lib or /lib64)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2022-08-30 16:29:00 +02:00
|
|
|
set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks")
|
2017-08-12 20:58:09 +02:00
|
|
|
if(ENABLE_MONOLITHIC_INSTALL)
|
|
|
|
set(BIN_DIR "." CACHE STRING "Where to install binaries")
|
|
|
|
set(LIB_DIR "." CACHE STRING "Where to install main library")
|
|
|
|
set(DATA_DIR "." CACHE STRING "Where to install data files")
|
|
|
|
else()
|
2021-03-02 02:56:54 +02:00
|
|
|
if(APPLE_MACOS)
|
2021-03-11 10:52:09 +02:00
|
|
|
set(APP_BUNDLE_DIR "${CMAKE_PROJECT_NAME}.app")
|
2021-03-02 02:56:54 +02:00
|
|
|
set(APP_BUNDLE_CONTENTS_DIR "${APP_BUNDLE_DIR}/Contents")
|
|
|
|
set(APP_BUNDLE_BINARY_DIR "${APP_BUNDLE_CONTENTS_DIR}/MacOS")
|
2021-03-11 10:52:09 +02:00
|
|
|
set(APP_BUNDLE_RESOURCES_DIR "${APP_BUNDLE_CONTENTS_DIR}/Resources")
|
|
|
|
|
|
|
|
set(BIN_DIR "${APP_BUNDLE_BINARY_DIR}" CACHE STRING "Where to install binaries")
|
|
|
|
set(LIB_DIR "${APP_BUNDLE_CONTENTS_DIR}/Frameworks" CACHE STRING "Where to install main library")
|
|
|
|
set(DATA_DIR "${APP_BUNDLE_RESOURCES_DIR}/Data" CACHE STRING "Where to install data files")
|
2021-03-02 02:56:54 +02:00
|
|
|
else()
|
2021-03-11 10:52:09 +02:00
|
|
|
set(LIB_DIR "Frameworks")
|
|
|
|
set(DATA_DIR ".")
|
2022-08-15 09:44:45 +02:00
|
|
|
endif()
|
2017-08-12 20:58:09 +02:00
|
|
|
endif()
|
2023-02-25 09:15:09 +02:00
|
|
|
elseif(ANDROID)
|
|
|
|
include(GNUInstallDirs)
|
2024-03-02 23:24:00 +02:00
|
|
|
set(LIB_DIR "libs/${ANDROID_ABI}")
|
|
|
|
|
|
|
|
# required by Qt
|
|
|
|
set(androidPackageSourceDir "${CMAKE_SOURCE_DIR}/android")
|
|
|
|
set(androidQtBuildDir "${CMAKE_BINARY_DIR}/android-build")
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${androidQtBuildDir}/${LIB_DIR}")
|
2012-10-05 15:38:17 +03:00
|
|
|
else()
|
2012-10-06 19:09:20 +03:00
|
|
|
# includes lib path which determines where to install shared libraries (either /lib or /lib64)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2017-08-12 20:58:09 +02:00
|
|
|
if(ENABLE_MONOLITHIC_INSTALL)
|
|
|
|
set(BIN_DIR "." CACHE STRING "Where to install binaries")
|
|
|
|
set(LIB_DIR "." CACHE STRING "Where to install main library")
|
|
|
|
set(DATA_DIR "." CACHE STRING "Where to install data files")
|
2022-12-16 11:39:32 +02:00
|
|
|
|
|
|
|
# following constants only used for platforms using XDG (Linux, BSD, etc)
|
|
|
|
add_definitions(-DM_DATA_DIR="${DATA_DIR}")
|
|
|
|
add_definitions(-DM_BIN_DIR="${BIN_DIR}")
|
|
|
|
add_definitions(-DM_LIB_DIR="${LIB_DIR}")
|
2022-12-23 14:17:18 +02:00
|
|
|
|
2022-12-08 12:46:40 +02:00
|
|
|
set(CMAKE_INSTALL_RPATH "$ORIGIN/")
|
2017-08-12 20:58:09 +02:00
|
|
|
else()
|
|
|
|
if(NOT BIN_DIR)
|
2022-12-08 12:46:40 +02:00
|
|
|
set(BIN_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING "Where to install binaries")
|
2017-08-12 20:58:09 +02:00
|
|
|
endif()
|
|
|
|
if(NOT LIB_DIR)
|
|
|
|
set(LIB_DIR "${CMAKE_INSTALL_LIBDIR}/vcmi" CACHE STRING "Where to install main library")
|
|
|
|
endif()
|
|
|
|
if(NOT DATA_DIR)
|
2022-12-08 12:46:40 +02:00
|
|
|
set(DATA_DIR "${CMAKE_INSTALL_DATAROOTDIR}/vcmi" CACHE STRING "Where to install data files")
|
2017-08-12 20:58:09 +02:00
|
|
|
endif()
|
2017-08-25 07:32:14 +02:00
|
|
|
|
2022-12-16 11:39:32 +02:00
|
|
|
# following constants only used for platforms using XDG (Linux, BSD, etc)
|
|
|
|
add_definitions(-DM_DATA_DIR="${CMAKE_INSTALL_PREFIX}/${DATA_DIR}")
|
|
|
|
add_definitions(-DM_BIN_DIR="${CMAKE_INSTALL_PREFIX}/${BIN_DIR}")
|
|
|
|
add_definitions(-DM_LIB_DIR="${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
|
2022-12-08 12:46:40 +02:00
|
|
|
|
2022-12-23 14:17:18 +02:00
|
|
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
|
2022-12-16 11:39:32 +02:00
|
|
|
endif()
|
2012-07-01 17:27:41 +03:00
|
|
|
endif()
|
|
|
|
|
2023-02-25 09:15:09 +02:00
|
|
|
# iOS/Android have flat libs directory structure
|
|
|
|
if(APPLE_IOS OR ANDROID)
|
2022-10-01 11:36:48 +02:00
|
|
|
set(AI_LIB_DIR "${LIB_DIR}")
|
|
|
|
set(SCRIPTING_LIB_DIR "${LIB_DIR}")
|
|
|
|
else()
|
|
|
|
set(AI_LIB_DIR "${LIB_DIR}/AI")
|
|
|
|
set(SCRIPTING_LIB_DIR "${LIB_DIR}/scripting")
|
|
|
|
endif()
|
2012-10-05 15:38:17 +03:00
|
|
|
|
2024-03-02 23:24:00 +02:00
|
|
|
# common Qt paths
|
|
|
|
if(ENABLE_LAUNCHER OR ENABLE_EDITOR)
|
|
|
|
get_target_property(qmakePath Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
|
|
|
|
get_filename_component(qtDir "${qmakePath}/../../" ABSOLUTE)
|
|
|
|
set(qtBinDir "${qtDir}/bin")
|
|
|
|
endif()
|
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
#######################################
|
|
|
|
# Add subdirectories #
|
|
|
|
#######################################
|
2014-02-05 23:25:36 +03:00
|
|
|
|
2022-08-15 15:29:11 +02:00
|
|
|
if(APPLE_IOS)
|
|
|
|
add_subdirectory(ios)
|
|
|
|
endif()
|
|
|
|
|
2024-03-27 16:49:19 +02:00
|
|
|
if (ENABLE_CLIENT)
|
|
|
|
add_subdirectory_with_folder("AI" AI)
|
|
|
|
endif()
|
2023-02-26 09:39:36 +02:00
|
|
|
|
2022-12-05 22:57:43 +02:00
|
|
|
add_subdirectory(lib)
|
2024-03-27 16:49:19 +02:00
|
|
|
|
|
|
|
if (ENABLE_CLIENT OR ENABLE_SERVER)
|
|
|
|
add_subdirectory(server)
|
|
|
|
endif()
|
2022-08-15 13:38:03 +02:00
|
|
|
|
2017-08-15 20:17:00 +02:00
|
|
|
if(ENABLE_ERM)
|
|
|
|
add_subdirectory(scripting/erm)
|
2013-11-03 15:07:23 +03:00
|
|
|
endif()
|
2024-02-10 19:57:23 +02:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
if(ENABLE_LUA)
|
|
|
|
add_subdirectory(scripting/lua)
|
|
|
|
endif()
|
2024-02-10 19:57:23 +02:00
|
|
|
|
2022-05-26 07:55:20 +02:00
|
|
|
if(NOT TARGET minizip::minizip)
|
2017-08-07 18:43:32 +02:00
|
|
|
add_subdirectory_with_folder("3rdparty" lib/minizip)
|
2022-05-26 07:55:20 +02:00
|
|
|
add_library(minizip::minizip ALIAS minizip)
|
2014-09-02 16:20:34 +03:00
|
|
|
endif()
|
2022-07-27 11:23:37 +02:00
|
|
|
|
2024-10-07 07:47:00 +02:00
|
|
|
if(ENABLE_LAUNCHER OR ENABLE_EDITOR)
|
|
|
|
add_subdirectory(vcmiqt)
|
|
|
|
endif()
|
|
|
|
|
2017-08-15 20:17:00 +02:00
|
|
|
if(ENABLE_LAUNCHER)
|
2013-08-19 14:50:53 +03:00
|
|
|
add_subdirectory(launcher)
|
|
|
|
endif()
|
2024-02-10 19:57:23 +02:00
|
|
|
|
2022-09-18 01:23:17 +02:00
|
|
|
if(ENABLE_EDITOR)
|
|
|
|
add_subdirectory(mapeditor)
|
|
|
|
endif()
|
2024-02-10 19:57:23 +02:00
|
|
|
|
2023-11-11 16:43:58 +02:00
|
|
|
if(ENABLE_LOBBY)
|
|
|
|
add_subdirectory(lobby)
|
|
|
|
endif()
|
2024-02-10 19:57:23 +02:00
|
|
|
|
2024-03-27 16:49:19 +02:00
|
|
|
if (ENABLE_CLIENT)
|
|
|
|
add_subdirectory(client)
|
2024-08-14 17:36:42 +02:00
|
|
|
add_subdirectory(clientapp)
|
2024-03-27 16:49:19 +02:00
|
|
|
endif()
|
2024-02-10 19:57:23 +02:00
|
|
|
|
|
|
|
if(ENABLE_SERVER)
|
|
|
|
add_subdirectory(serverapp)
|
|
|
|
endif()
|
|
|
|
|
2013-04-22 17:49:28 +03:00
|
|
|
if(ENABLE_TEST)
|
2018-04-15 13:02:31 +02:00
|
|
|
enable_testing()
|
2013-04-22 17:49:28 +03:00
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
2012-07-19 21:52:44 +03:00
|
|
|
|
2012-10-05 15:38:17 +03:00
|
|
|
#######################################
|
2017-08-12 20:58:09 +02:00
|
|
|
# Installation section #
|
2012-10-05 15:38:17 +03:00
|
|
|
#######################################
|
|
|
|
|
2023-02-25 09:15:09 +02:00
|
|
|
if(ANDROID)
|
2024-03-02 23:24:00 +02:00
|
|
|
string(REPLACE ";" "\n" ANDROID_GRADLE_PROPERTIES_MULTILINE "${ANDROID_GRADLE_PROPERTIES}")
|
|
|
|
file(WRITE "${androidPackageSourceDir}/vcmi-app/gradle.properties" "signingRoot=${CMAKE_SOURCE_DIR}/CI/android\n${ANDROID_GRADLE_PROPERTIES_MULTILINE}")
|
|
|
|
|
2023-02-25 09:15:09 +02:00
|
|
|
if(ANDROID_STL MATCHES "_shared$")
|
|
|
|
set(stlLibName "${CMAKE_SHARED_LIBRARY_PREFIX}${ANDROID_STL}${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
|
|
|
install(FILES "${CMAKE_SYSROOT}/usr/lib/${ANDROID_SYSROOT_LIB_SUBDIR}/${stlLibName}"
|
|
|
|
DESTINATION ${LIB_DIR}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
install(DIRECTORY config DESTINATION ${DATA_DIR})
|
2024-03-27 16:49:19 +02:00
|
|
|
if (ENABLE_CLIENT OR ENABLE_SERVER)
|
|
|
|
install(DIRECTORY Mods DESTINATION ${DATA_DIR})
|
|
|
|
endif()
|
2023-02-25 09:15:09 +02:00
|
|
|
endif()
|
2022-09-22 16:16:24 +02:00
|
|
|
if(ENABLE_LUA)
|
|
|
|
install(DIRECTORY scripts DESTINATION ${DATA_DIR})
|
|
|
|
endif()
|
2012-10-05 15:38:17 +03:00
|
|
|
|
2023-02-25 09:15:09 +02:00
|
|
|
# that script is useless for Windows / iOS / Android
|
|
|
|
if(NOT WIN32 AND NOT APPLE_IOS AND NOT ANDROID)
|
2017-08-12 20:58:09 +02:00
|
|
|
install(FILES vcmibuilder DESTINATION ${BIN_DIR} PERMISSIONS
|
|
|
|
OWNER_WRITE OWNER_READ OWNER_EXECUTE
|
|
|
|
GROUP_READ GROUP_EXECUTE
|
|
|
|
WORLD_READ WORLD_EXECUTE)
|
2012-10-05 15:38:17 +03:00
|
|
|
endif()
|
|
|
|
|
2021-07-27 20:26:17 +02:00
|
|
|
|
|
|
|
if(WIN32)
|
2024-07-25 16:41:37 +02:00
|
|
|
if(TBB_FOUND AND MSVC)
|
2024-09-06 18:57:37 +02:00
|
|
|
install_vcpkg_imported_tgt(TBB::tbb)
|
2024-07-25 16:41:37 +02:00
|
|
|
endif()
|
|
|
|
|
2023-01-22 23:53:23 +02:00
|
|
|
if(USING_CONAN)
|
|
|
|
#Conan imports enabled
|
|
|
|
vcmi_install_conan_deps("\${CMAKE_INSTALL_PREFIX}")
|
|
|
|
file(GLOB dep_files
|
|
|
|
${dep_files}
|
|
|
|
"${CMAKE_SYSROOT}/bin/*.dll"
|
|
|
|
"${CMAKE_SYSROOT}/lib/*.dll"
|
2024-09-19 19:59:37 +02:00
|
|
|
"${CONAN_SYSTEM_LIBRARY_LOCATION}/libgcc_s_dw2-1.dll" # for 32-bit only?
|
|
|
|
"${CONAN_SYSTEM_LIBRARY_LOCATION}/libgcc_s_seh-1.dll" # for 64-bit only?
|
2024-09-06 18:57:37 +02:00
|
|
|
"${CONAN_SYSTEM_LIBRARY_LOCATION}/libstdc++-6.dll")
|
2023-01-22 23:53:23 +02:00
|
|
|
else()
|
|
|
|
file(GLOB dep_files
|
|
|
|
${dep_files}
|
|
|
|
"${CMAKE_FIND_ROOT_PATH}/bin/*.dll")
|
|
|
|
endif()
|
2017-08-16 02:44:34 +02:00
|
|
|
|
2024-05-12 19:06:46 +02:00
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2017-08-16 02:44:34 +02:00
|
|
|
# Copy debug versions of libraries if build type is debug
|
|
|
|
set(debug_postfix d)
|
|
|
|
endif()
|
|
|
|
|
2022-09-18 01:23:17 +02:00
|
|
|
if(ENABLE_LAUNCHER OR ENABLE_EDITOR)
|
2022-05-28 15:32:20 +02:00
|
|
|
get_target_property(QtCore_location Qt${QT_VERSION_MAJOR}::Core LOCATION)
|
2017-08-16 02:44:34 +02:00
|
|
|
get_filename_component(Qtbin_folder ${QtCore_location} PATH)
|
|
|
|
file(GLOB dep_files
|
|
|
|
${dep_files}
|
|
|
|
${Qtbin_folder}/Qt5Core${debug_postfix}.dll
|
|
|
|
${Qtbin_folder}/Qt5Gui${debug_postfix}.dll
|
|
|
|
${Qtbin_folder}/Qt5Widgets${debug_postfix}.dll
|
2022-05-26 07:55:20 +02:00
|
|
|
${Qtbin_folder}/Qt5Network${debug_postfix}.dll
|
2017-08-16 02:44:34 +02:00
|
|
|
${Qtbin_folder}/icu*.dll)
|
2022-05-28 15:32:20 +02:00
|
|
|
get_target_property(integration_type Qt${QT_VERSION_MAJOR}::QWindowsIntegrationPlugin TYPE)
|
2022-05-26 07:55:20 +02:00
|
|
|
if(NOT(integration_type STREQUAL "INTERFACE_LIBRARY"))
|
2022-05-28 15:32:20 +02:00
|
|
|
get_target_property(integration_loc Qt${QT_VERSION_MAJOR}::QWindowsIntegrationPlugin LOCATION)
|
2022-05-26 07:55:20 +02:00
|
|
|
install(
|
|
|
|
FILES ${integration_loc}
|
|
|
|
DESTINATION ${BIN_DIR}/platforms
|
|
|
|
)
|
2023-01-08 14:11:08 +02:00
|
|
|
install(
|
|
|
|
FILES "$<TARGET_FILE:Qt${QT_VERSION_MAJOR}::QWindowsVistaStylePlugin>"
|
|
|
|
DESTINATION ${BIN_DIR}/styles)
|
2022-05-26 07:55:20 +02:00
|
|
|
endif()
|
2017-08-16 02:44:34 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
install(FILES ${dep_files} DESTINATION ${BIN_DIR})
|
2021-07-27 20:26:17 +02:00
|
|
|
endif(WIN32)
|
2017-08-16 02:44:34 +02:00
|
|
|
|
2012-10-05 15:38:17 +03:00
|
|
|
#######################################
|
|
|
|
# Packaging section #
|
|
|
|
#######################################
|
|
|
|
|
2023-12-03 20:20:59 +02:00
|
|
|
if(MSVC)
|
|
|
|
SET(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ${BIN_DIR})
|
|
|
|
Include(InstallRequiredSystemLibraries)
|
|
|
|
endif()
|
|
|
|
|
2013-02-21 20:32:50 +03:00
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR ${VCMI_VERSION_MAJOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR ${VCMI_VERSION_MINOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH ${VCMI_VERSION_PATCH})
|
2012-10-05 15:38:17 +03:00
|
|
|
|
|
|
|
# vcmi does not have "patch version" in version string
|
|
|
|
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
|
|
|
#TODO: remove version from Global.h and use this one as define?
|
|
|
|
|
|
|
|
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
|
|
|
|
|
2017-06-12 17:17:10 +02:00
|
|
|
if("${PACKAGE_NAME_SUFFIX}" STREQUAL "")
|
|
|
|
set(CPACK_PACKAGE_NAME "VCMI")
|
|
|
|
else()
|
|
|
|
set(CPACK_PACKAGE_NAME "VCMI ${PACKAGE_NAME_SUFFIX}")
|
|
|
|
endif()
|
|
|
|
if("${PACKAGE_FILE_NAME}" STREQUAL "")
|
|
|
|
set(CPACK_PACKAGE_FILE_NAME "vcmi-${CPACK_PACKAGE_VERSION}")
|
|
|
|
else()
|
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME}")
|
|
|
|
endif()
|
|
|
|
set(CPACK_PACKAGE_VENDOR "VCMI team")
|
|
|
|
|
2012-10-05 15:38:17 +03:00
|
|
|
if(WIN32)
|
2017-08-16 13:52:39 +02:00
|
|
|
# Note: due to NSI script generation process all of the backward slashes here are useful
|
2014-07-14 01:23:57 +03:00
|
|
|
set(CPACK_MONOLITHIC_INSTALL 1)
|
2017-08-15 20:18:02 +02:00
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/license.txt")
|
2014-07-14 01:23:57 +03:00
|
|
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
|
2017-06-12 17:17:10 +02:00
|
|
|
if("${PACKAGE_NAME_SUFFIX}" STREQUAL "")
|
|
|
|
set(CPACK_NSIS_PACKAGE_NAME "VCMI ${CPACK_PACKAGE_VERSION}")
|
|
|
|
else()
|
|
|
|
set(CPACK_NSIS_PACKAGE_NAME "VCMI ${CPACK_PACKAGE_VERSION} ${PACKAGE_NAME_SUFFIX} ")
|
|
|
|
endif()
|
2023-01-26 17:29:38 +02:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES ".*64")
|
|
|
|
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
|
|
|
|
else()
|
|
|
|
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
|
|
|
|
endif()
|
2023-10-08 16:28:23 +02:00
|
|
|
|
2017-08-12 20:58:09 +02:00
|
|
|
if(ENABLE_LAUNCHER)
|
2023-10-08 16:28:23 +02:00
|
|
|
set(VCMI_MAIN_EXECUTABLE "VCMI_launcher")
|
2017-08-12 20:58:09 +02:00
|
|
|
else()
|
2023-10-08 16:28:23 +02:00
|
|
|
set(VCMI_MAIN_EXECUTABLE "VCMI_client")
|
2017-08-12 20:58:09 +02:00
|
|
|
endif()
|
2023-10-08 16:28:23 +02:00
|
|
|
set(CPACK_PACKAGE_EXECUTABLES "${VCMI_MAIN_EXECUTABLE};VCMI")
|
|
|
|
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
|
|
|
|
CreateShortCut \\\"$DESKTOP\\\\VCMI.lnk\\\" \\\"$INSTDIR\\\\${VCMI_MAIN_EXECUTABLE}.exe\\\"
|
|
|
|
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
|
2024-02-24 16:51:36 +02:00
|
|
|
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
|
2023-10-08 16:28:23 +02:00
|
|
|
")
|
2023-10-08 14:02:49 +02:00
|
|
|
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
|
|
|
|
Delete \\\"$DESKTOP\\\\VCMI.lnk\\\"
|
|
|
|
ExecShell '' 'netsh' 'advfirewall firewall delete rule name=vcmi_server' SW_HIDE
|
2024-02-24 16:51:36 +02:00
|
|
|
ExecShell '' 'netsh' 'advfirewall firewall delete rule name=vcmi_client' SW_HIDE
|
2023-10-08 14:02:49 +02:00
|
|
|
")
|
2017-07-06 08:09:30 +02:00
|
|
|
|
2023-01-25 17:09:36 +02:00
|
|
|
# Strip MinGW CPack target if build configuration without debug info
|
|
|
|
if(MINGW)
|
|
|
|
if(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug") OR (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
|
|
|
|
set(CPACK_STRIP_FILES ON)
|
|
|
|
endif()
|
|
|
|
endif()
|
2017-08-15 20:18:02 +02:00
|
|
|
# set the install/unistall icon used for the installer itself
|
|
|
|
# There is a bug in NSI that does not handle full unix paths properly.
|
2024-09-14 13:48:53 +02:00
|
|
|
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/clientapp/icons\\\\vcmi.ico")
|
|
|
|
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/clientapp/icons\\\\vcmi.ico")
|
2017-08-15 20:18:02 +02:00
|
|
|
# set the package header icon for MUI
|
2024-09-14 13:48:53 +02:00
|
|
|
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/clientapp/icons\\\\vcmi.ico")
|
2017-08-15 20:18:02 +02:00
|
|
|
|
|
|
|
set(CPACK_NSIS_MENU_LINKS "http://vcmi.eu/" "VCMI Web Site")
|
|
|
|
|
|
|
|
set(CPACK_NSIS_INSTALLED_ICON_NAME "VCMI_client.exe")
|
|
|
|
set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
|
|
|
|
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_PACKAGE_NAME}, open-source engine for Heroes of Might and Magic III ")
|
|
|
|
set(CPACK_NSIS_HELP_LINK "http://vcmi.eu/")
|
|
|
|
set(CPACK_NSIS_URL_INFO_ABOUT "http://vcmi.eu/")
|
|
|
|
set(CPACK_NSIS_CONTACT @CPACK_PACKAGE_CONTACT@)
|
|
|
|
set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
|
2023-01-31 18:21:49 +02:00
|
|
|
# Use BundleUtilities to fix build when Vcpkg is used and disable it for mingw
|
2017-08-16 13:52:39 +02:00
|
|
|
if(NOT (${CMAKE_CROSSCOMPILING}))
|
2022-09-20 10:50:47 +02:00
|
|
|
add_subdirectory(win)
|
2017-08-16 13:52:39 +02:00
|
|
|
endif()
|
2021-03-01 10:38:21 +02:00
|
|
|
elseif(APPLE_MACOS AND NOT ENABLE_MONOLITHIC_INSTALL)
|
2017-08-07 18:43:32 +02:00
|
|
|
set(CPACK_MONOLITHIC_INSTALL 1)
|
|
|
|
set(CPACK_GENERATOR "DragNDrop")
|
2012-12-27 12:21:30 +03:00
|
|
|
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/osx/dmg_background.png")
|
2024-01-15 15:00:41 +02:00
|
|
|
# Workaround for this issue:
|
|
|
|
# CPack Error: Error executing: /usr/bin/hdiutil detach "/Volumes/VCMI"
|
|
|
|
# https://github.com/actions/runner-images/issues/7522#issuecomment-1564467252
|
|
|
|
set(CPACK_COMMAND_HDIUTIL "/usr/bin/sudo /usr/bin/hdiutil")
|
2017-08-21 14:45:33 +02:00
|
|
|
# CMake code for CPACK_DMG_DS_STORE executed before DS_STORE_SETUP_SCRIPT
|
|
|
|
# So we can keep both enabled and this shouldn't hurt
|
|
|
|
# set(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/osx/dmg_DS_Store")
|
|
|
|
set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_SOURCE_DIR}/osx/DS_Store_Setup.scpt")
|
|
|
|
|
|
|
|
# Always use "VCMI" as volume name so full path will be /Volumes/VCMI/
|
|
|
|
# Otherwise DMG background image wouldn't work
|
|
|
|
# Pre-generated DS_Store use absolute path to background image
|
|
|
|
set(CPACK_DMG_VOLUME_NAME "${CMAKE_PROJECT_NAME}")
|
2017-08-07 18:43:32 +02:00
|
|
|
|
2022-09-30 12:25:14 +02:00
|
|
|
include(GetGitRevisionDescription)
|
|
|
|
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
|
2022-10-22 15:52:47 +02:00
|
|
|
string(TIMESTAMP CURRENT_YEAR "%Y")
|
2022-09-30 12:25:14 +02:00
|
|
|
|
2017-08-12 20:58:09 +02:00
|
|
|
set(MACOSX_BUNDLE_NAME "${CMAKE_PROJECT_NAME}")
|
|
|
|
set(MACOSX_BUNDLE_BUNDLE_NAME "${CMAKE_PROJECT_NAME}")
|
2022-10-22 15:52:47 +02:00
|
|
|
set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2007-${CURRENT_YEAR} VCMI team")
|
2022-10-22 15:52:27 +02:00
|
|
|
set(MACOSX_BUNDLE_GUI_IDENTIFIER "eu.vcmi.vcmi")
|
2022-09-30 12:25:14 +02:00
|
|
|
set(MACOSX_BUNDLE_BUNDLE_VERSION ${GIT_SHA1})
|
|
|
|
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${APP_SHORT_VERSION})
|
2017-08-07 18:43:32 +02:00
|
|
|
if(ENABLE_LAUNCHER)
|
|
|
|
set(MACOSX_BUNDLE_EXECUTABLE_NAME "vcmilauncher")
|
|
|
|
else()
|
|
|
|
set(MACOSX_BUNDLE_EXECUTABLE_NAME "vcmiclient")
|
|
|
|
endif()
|
|
|
|
set(MACOSX_BUNDLE_ICON_FILE "vcmi.icns")
|
|
|
|
|
2017-08-12 20:58:09 +02:00
|
|
|
install(FILES "${CMAKE_SOURCE_DIR}/osx/vcmi.icns" DESTINATION ${APP_BUNDLE_RESOURCES_DIR})
|
2017-08-07 18:43:32 +02:00
|
|
|
|
2017-08-12 20:58:09 +02:00
|
|
|
configure_file("${CMAKE_SOURCE_DIR}/osx/Info.plist.in" "${CMAKE_BINARY_DIR}/Info.plist")
|
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/Info.plist" DESTINATION ${APP_BUNDLE_CONTENTS_DIR})
|
2017-08-07 18:43:32 +02:00
|
|
|
|
2017-08-12 20:58:09 +02:00
|
|
|
# Bundle fixing code must be in separate directory to be executed after all other install code
|
|
|
|
add_subdirectory(osx)
|
2022-08-11 11:12:33 +02:00
|
|
|
elseif(APPLE_IOS)
|
|
|
|
set(CPACK_GENERATOR ZIP)
|
2022-08-11 14:15:20 +02:00
|
|
|
set(CPACK_ARCHIVE_FILE_EXTENSION ipa)
|
2022-08-11 11:12:33 +02:00
|
|
|
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
|
|
|
|
set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_CURRENT_BINARY_DIR};${CMAKE_PROJECT_NAME};app;/")
|
2012-10-05 15:38:17 +03:00
|
|
|
else()
|
|
|
|
set(CPACK_GENERATOR TGZ)
|
|
|
|
endif()
|
|
|
|
|
2017-08-12 20:58:09 +02:00
|
|
|
include(CPack)
|