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()
|
|
|
|
# 2.8.12 is used since it's present in Ubuntu 14.04 and Cotire require it
|
|
|
|
cmake_minimum_required(VERSION 2.8.12)
|
|
|
|
|
2017-08-15 20:17:00 +02:00
|
|
|
project(VCMI)
|
2017-08-12 20:58:09 +02:00
|
|
|
# TODO
|
2017-08-15 20:18:02 +02:00
|
|
|
# macOS:
|
|
|
|
# - There is problem with running fixup_bundle in main project after subdirectories.
|
2017-08-12 20:58:09 +02:00
|
|
|
# Cmake put them after all install code of main CMakelists in cmake_install.cmake
|
|
|
|
# Currently I just added extra add_subdirectory and CMakeLists.txt in osx directory to bypass that.
|
2017-08-15 20:18:02 +02:00
|
|
|
# - Try to fix build with RPATH.
|
2017-08-12 20:58:09 +02:00
|
|
|
# Currently if CMAKE_MACOSX_RPATH=1 then AI libs unable to find @rpath/libvcmi.dylib
|
|
|
|
# I tried to set few different INSTALL_RPATH for all targets in AI directory, but nothing worked.
|
2017-08-15 20:18:02 +02:00
|
|
|
#
|
|
|
|
# MXE:
|
|
|
|
# - Try to implement MXE support into BundleUtilities so we can deploy deps automatically
|
|
|
|
#
|
2017-08-16 13:52:39 +02:00
|
|
|
# Vckpg:
|
|
|
|
# - Improve install code once there is better way to deploy DLLs and Qt plugins
|
|
|
|
# - Move Vcpkg install BundleUtilities code from osx/CMakeLists.txt
|
|
|
|
#
|
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
|
|
|
|
|
|
|
############################################
|
|
|
|
# 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
|
|
|
|
2013-02-21 20:32:50 +03:00
|
|
|
set(VCMI_VERSION_MAJOR 0)
|
2016-11-01 19:45:50 +02:00
|
|
|
set(VCMI_VERSION_MINOR 99)
|
2013-02-21 20:32:50 +03:00
|
|
|
set(VCMI_VERSION_PATCH 0)
|
|
|
|
|
2013-06-29 16:05:48 +03:00
|
|
|
option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
|
2013-11-14 16:21:09 +03:00
|
|
|
option(ENABLE_LAUNCHER "Enable compilation of launcher" ON)
|
2018-07-29 22:38:43 +02:00
|
|
|
option(ENABLE_TEST "Enable compilation of unit tests" OFF)
|
2014-02-26 17:19:14 +03:00
|
|
|
option(ENABLE_PCH "Enable compilation using precompiled headers" ON)
|
2017-08-16 02:44:34 +02:00
|
|
|
option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON)
|
2017-08-16 15:29:18 +02:00
|
|
|
option(ENABLE_DEBUG_CONSOLE "Enable debug console for Windows builds" ON)
|
2018-02-28 15:08:36 +02:00
|
|
|
option(ENABLE_MULTI_PROCESS_BUILDS "Enable /MP flag for MSVS solution" ON)
|
2012-10-05 15:38:17 +03:00
|
|
|
|
2017-09-08 02:40:00 +02:00
|
|
|
# Used for Snap packages and also useful for debugging
|
2017-08-12 20:58:09 +02:00
|
|
|
option(ENABLE_MONOLITHIC_INSTALL "Install everything in single directory on Linux and Mac" OFF)
|
|
|
|
|
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")
|
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
############################################
|
|
|
|
# Miscellaneous options #
|
|
|
|
############################################
|
2017-08-15 20:17:00 +02:00
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules)
|
|
|
|
# Contains custom functions and macros, but don't altering any options
|
|
|
|
include(VCMIUtils)
|
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
|
|
|
|
COMMAND ${CMAKE_COMMAND} -DGIT_SHA1="${GIT_SHA1}" -P "${CMAKE_MODULE_PATH}/Version.cmake"
|
|
|
|
)
|
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
|
|
|
|
|
|
|
# Precompiled header configuration
|
2017-08-16 02:44:34 +02:00
|
|
|
if(ENABLE_PCH)
|
|
|
|
include(cotire)
|
|
|
|
set(PCH_PROPERTIES
|
|
|
|
COTIRE_ENABLE_PRECOMPILED_HEADER ${ENABLE_PCH}
|
|
|
|
COTIRE_ADD_UNITY_BUILD FALSE
|
|
|
|
COTIRE_CXX_PREFIX_HEADER_INIT "StdInc.h"
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
set(PCH_PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
|
|
|
|
macro(cotire ignore)
|
|
|
|
endmacro(cotire)
|
|
|
|
endif(ENABLE_PCH)
|
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
|
|
|
############################################
|
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
if(APPLE)
|
|
|
|
set(CMAKE_MACOSX_RPATH 0)
|
|
|
|
endif(APPLE)
|
|
|
|
|
2017-08-15 20:17:00 +02:00
|
|
|
if(WIN32)
|
2014-07-09 01:43:13 +03:00
|
|
|
add_definitions(-DBOOST_THREAD_USE_LIB)
|
2017-07-11 13:08:00 +02:00
|
|
|
# Windows Vista or newer for FuzzyLite 6 to compile
|
|
|
|
add_definitions(-D_WIN32_WINNT=0x0600)
|
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)
|
|
|
|
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)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /wd4251")
|
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)
|
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} ole32 oleaut32 ws2_32 mswsock dbghelp)
|
|
|
|
|
|
|
|
# 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()
|
|
|
|
|
|
|
|
# Prevent compiler issues when building Debug
|
|
|
|
# Assembler might fail with "too many sections"
|
|
|
|
# With big-obj or 64-bit build will take hours
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og")
|
|
|
|
endif()
|
|
|
|
endif(MINGW)
|
2017-08-15 20:17:00 +02:00
|
|
|
endif(WIN32)
|
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX OR NOT WIN32) #so far all *nix compilers support such parameters
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -Wpointer-arith -Wuninitialized")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-aliasing -Wno-switch -Wno-sign-compare -Wno-unused-local-typedefs")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-overloaded-virtual -Wno-type-limits -Wno-unknown-pragmas")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder")
|
|
|
|
|
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
2019-01-19 12:52:02 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-mismatched-tags -Wno-unknown-warning-option -Wno-missing-braces")
|
2017-08-15 20:18:02 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(UNIX)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
|
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
|
2014-07-10 00:41:31 +03:00
|
|
|
if(NOT WIN32)
|
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()
|
2014-07-09 01:43:13 +03:00
|
|
|
endif()
|
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
############################################
|
|
|
|
# Finding packages #
|
|
|
|
############################################
|
2015-04-09 12:19:44 +02:00
|
|
|
|
2014-07-11 12:43:24 +03:00
|
|
|
set(FFmpeg_FIND_COMPONENTS AVFORMAT SWSCALE)
|
2015-09-24 10:55:23 +02:00
|
|
|
find_package(Boost 1.48.0 COMPONENTS date_time filesystem locale program_options system thread REQUIRED)
|
2012-07-01 17:27:41 +03:00
|
|
|
find_package(ZLIB REQUIRED)
|
2014-07-11 12:43:24 +03:00
|
|
|
find_package(FFmpeg REQUIRED)
|
2014-10-12 16:50:39 +03:00
|
|
|
find_package(Minizip)
|
2017-08-15 20:17:00 +02:00
|
|
|
if(MINIZIP_FOUND)
|
2017-08-15 20:18:02 +02:00
|
|
|
add_definitions(-DUSE_SYSTEM_MINIZIP)
|
2014-10-12 16:50:39 +03:00
|
|
|
endif()
|
2014-05-24 16:52:43 +03:00
|
|
|
|
2015-06-21 00:54:36 +02:00
|
|
|
find_package(SDL2 REQUIRED)
|
|
|
|
find_package(SDL2_image REQUIRED)
|
|
|
|
find_package(SDL2_mixer REQUIRED)
|
|
|
|
find_package(SDL2_ttf REQUIRED)
|
|
|
|
|
2017-07-03 20:59:57 +02:00
|
|
|
if(ENABLE_LAUNCHER)
|
2013-02-17 00:14:36 +03:00
|
|
|
# Widgets finds its own dependencies (QtGui and QtCore).
|
|
|
|
find_package(Qt5Widgets REQUIRED)
|
2013-08-19 14:50:53 +03:00
|
|
|
find_package(Qt5Network REQUIRED)
|
|
|
|
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)
|
|
|
|
|
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()
|
|
|
|
set(APP_BUNDLE_DIR "${CMAKE_PROJECT_NAME}.app")
|
|
|
|
set(APP_BUNDLE_CONTENTS_DIR "${APP_BUNDLE_DIR}/Contents")
|
|
|
|
set(APP_BUNDLE_BINARY_DIR "${APP_BUNDLE_CONTENTS_DIR}/MacOS")
|
|
|
|
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_BINARY_DIR}" CACHE STRING "Where to install main library")
|
|
|
|
set(DATA_DIR "${APP_BUNDLE_RESOURCES_DIR}/Data" CACHE STRING "Where to install data files")
|
|
|
|
endif()
|
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)
|
2017-09-08 02:40:00 +02:00
|
|
|
set(CMAKE_INSTALL_RPATH "$ORIGIN/")
|
2017-08-12 20:58:09 +02: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")
|
|
|
|
else()
|
|
|
|
if(NOT BIN_DIR)
|
|
|
|
set(BIN_DIR "bin" CACHE STRING "Where to install binaries")
|
|
|
|
endif()
|
|
|
|
if(NOT LIB_DIR)
|
|
|
|
set(LIB_DIR "${CMAKE_INSTALL_LIBDIR}/vcmi" CACHE STRING "Where to install main library")
|
|
|
|
endif()
|
|
|
|
if(NOT DATA_DIR)
|
|
|
|
set(DATA_DIR "share/vcmi" CACHE STRING "Where to install data files")
|
|
|
|
endif()
|
2013-02-25 22:17:36 +03:00
|
|
|
endif()
|
2017-08-25 07:32:14 +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}")
|
2012-07-01 17:27:41 +03:00
|
|
|
endif()
|
|
|
|
|
2017-08-12 20:58:09 +02:00
|
|
|
set(AI_LIB_DIR "${LIB_DIR}/AI")
|
|
|
|
set(SCRIPTING_LIB_DIR "${LIB_DIR}/scripting")
|
2012-10-05 15:38:17 +03:00
|
|
|
|
2017-08-15 20:18:02 +02:00
|
|
|
#######################################
|
|
|
|
# Add subdirectories #
|
|
|
|
#######################################
|
2014-02-05 23:25:36 +03: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()
|
2017-08-15 20:17:00 +02:00
|
|
|
if(NOT MINIZIP_FOUND)
|
2017-08-07 18:43:32 +02:00
|
|
|
add_subdirectory_with_folder("3rdparty" lib/minizip)
|
2014-09-02 16:20:34 +03:00
|
|
|
set(MINIZIP_LIBRARIES minizip)
|
|
|
|
endif()
|
2012-07-01 17:27:41 +03:00
|
|
|
add_subdirectory(lib)
|
|
|
|
add_subdirectory(client)
|
|
|
|
add_subdirectory(server)
|
2017-08-15 20:17:00 +02:00
|
|
|
add_subdirectory_with_folder("AI" AI)
|
|
|
|
if(ENABLE_LAUNCHER)
|
2013-08-19 14:50:53 +03:00
|
|
|
add_subdirectory(launcher)
|
|
|
|
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
|
|
|
#######################################
|
|
|
|
|
2017-08-12 20:58:09 +02:00
|
|
|
install(DIRECTORY config DESTINATION ${DATA_DIR})
|
|
|
|
install(DIRECTORY Mods DESTINATION ${DATA_DIR})
|
2012-10-05 15:38:17 +03:00
|
|
|
|
2017-08-12 20:58:09 +02:00
|
|
|
# that script is useless for Windows
|
|
|
|
if(NOT WIN32)
|
|
|
|
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()
|
|
|
|
|
2017-08-16 02:44:34 +02:00
|
|
|
if(MINGW)
|
|
|
|
file(GLOB dep_files
|
|
|
|
${dep_files}
|
|
|
|
"${CMAKE_FIND_ROOT_PATH}/bin/*.dll")
|
|
|
|
|
|
|
|
if((${CMAKE_CROSSCOMPILING}) AND (DEFINED MSYS))
|
|
|
|
message(STATUS "Detected MXE build")
|
|
|
|
elseif(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
# Copy debug versions of libraries if build type is debug
|
|
|
|
set(debug_postfix d)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_LAUNCHER)
|
|
|
|
get_target_property(QtCore_location Qt5::Core LOCATION)
|
|
|
|
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
|
|
|
|
${Qtbin_folder}/icu*.dll)
|
|
|
|
file(GLOB dep_qwindows
|
|
|
|
${Qtbin_folder}/../plugins/platforms/qwindows${debug_postfix}.dll)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ENABLE_LAUNCHER)
|
|
|
|
file(GLOB dep_files
|
|
|
|
${dep_files}
|
|
|
|
${Qtbin_folder}/Qt5Network${debug_postfix}.dll)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
install(FILES ${dep_files} DESTINATION ${BIN_DIR})
|
|
|
|
install(FILES ${dep_qwindows} DESTINATION ${BIN_DIR}/platforms)
|
|
|
|
endif(MINGW)
|
|
|
|
|
2012-10-05 15:38:17 +03:00
|
|
|
#######################################
|
|
|
|
# Packaging section #
|
|
|
|
#######################################
|
|
|
|
|
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()
|
2014-07-14 01:23:57 +03:00
|
|
|
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
|
2017-08-12 20:58:09 +02:00
|
|
|
if(ENABLE_LAUNCHER)
|
2017-08-15 20:18:02 +02:00
|
|
|
set(CPACK_PACKAGE_EXECUTABLES "VCMI_launcher;VCMI")
|
2017-08-12 20:58:09 +02:00
|
|
|
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " CreateShortCut \\\"$DESKTOP\\\\VCMI.lnk\\\" \\\"$INSTDIR\\\\VCMI_launcher.exe\\\"")
|
|
|
|
else()
|
2017-08-15 20:18:02 +02:00
|
|
|
set(CPACK_PACKAGE_EXECUTABLES "VCMI_client;VCMI")
|
2017-08-12 20:58:09 +02:00
|
|
|
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " CreateShortCut \\\"$DESKTOP\\\\VCMI.lnk\\\" \\\"$INSTDIR\\\\VCMI_client.exe\\\"")
|
|
|
|
endif()
|
|
|
|
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " Delete \\\"$DESKTOP\\\\VCMI.lnk\\\" ")
|
2017-07-06 08:09:30 +02:00
|
|
|
|
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.
|
2017-08-16 13:52:39 +02:00
|
|
|
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/client\\\\vcmi.ico")
|
|
|
|
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/client\\\\vcmi.ico")
|
2017-08-15 20:18:02 +02:00
|
|
|
# set the package header icon for MUI
|
2017-08-16 13:52:39 +02:00
|
|
|
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/client\\\\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 ".")
|
2017-08-16 13:52:39 +02:00
|
|
|
# Use BundleUtilities to fix build when Vcpkg is used and disable it for MXE
|
|
|
|
if(NOT (${CMAKE_CROSSCOMPILING}))
|
|
|
|
add_subdirectory(osx)
|
|
|
|
endif()
|
2017-08-12 20:58:09 +02:00
|
|
|
elseif(APPLE 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")
|
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
|
|
|
|
2017-08-12 20:58:09 +02:00
|
|
|
set(MACOSX_BUNDLE_NAME "${CMAKE_PROJECT_NAME}")
|
|
|
|
set(MACOSX_BUNDLE_BUNDLE_NAME "${CMAKE_PROJECT_NAME}")
|
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)
|
2012-10-05 15:38:17 +03:00
|
|
|
else()
|
|
|
|
set(CPACK_GENERATOR TGZ)
|
|
|
|
endif()
|
|
|
|
|
2017-08-12 20:58:09 +02:00
|
|
|
include(CPack)
|