2019-07-17 15:19:43 -04:00
|
|
|
|
# CMAKE project for openrct2
|
2019-01-26 12:41:56 -05:00
|
|
|
|
cmake_minimum_required(VERSION 3.9)
|
2016-03-27 17:29:45 -04:00
|
|
|
|
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
|
2017-01-10 07:09:48 -05:00
|
|
|
|
message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt")
|
2016-03-27 17:29:45 -04:00
|
|
|
|
endif()
|
2017-06-14 18:08:41 -04:00
|
|
|
|
|
2018-02-14 14:06:21 -05:00
|
|
|
|
project(openrct2 CXX)
|
2017-07-26 07:12:54 -04:00
|
|
|
|
|
2019-02-05 14:16:51 -05:00
|
|
|
|
include(cmake/platform.cmake)
|
2019-08-13 15:04:08 -04:00
|
|
|
|
include(CMakeDependentOption)
|
2019-02-05 14:16:51 -05:00
|
|
|
|
|
2018-04-12 18:07:18 -04:00
|
|
|
|
if (NOT MSVC)
|
|
|
|
|
include(FindPkgConfig)
|
|
|
|
|
endif ()
|
2017-06-14 18:08:41 -04:00
|
|
|
|
include(CheckCXXCompilerFlag)
|
2017-07-26 04:24:03 -04:00
|
|
|
|
include(GNUInstallDirs)
|
2017-06-14 18:08:41 -04:00
|
|
|
|
|
2018-06-30 09:13:25 -04:00
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
2017-05-08 12:35:15 -04:00
|
|
|
|
set(ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}")
|
2017-05-23 10:37:03 -04:00
|
|
|
|
set(CMAKE_MACOSX_RPATH 1)
|
2015-09-24 16:47:14 -04:00
|
|
|
|
|
2019-08-11 14:03:29 -04:00
|
|
|
|
set(TITLE_SEQUENCE_URL "https://github.com/OpenRCT2/title-sequences/releases/download/v0.1.2c/title-sequences.zip")
|
|
|
|
|
set(TITLE_SEQUENCE_SHA1 "304d13a126c15bf2c86ff13b81a2f2cc1856ac8d")
|
2017-05-08 12:51:04 -04:00
|
|
|
|
|
2019-08-18 05:54:06 -04:00
|
|
|
|
set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v1.0.12/objects.zip")
|
|
|
|
|
set(OBJECTS_SHA1 "56b5d22ed7da0afa750b3dcb5ac22de61e3597c2")
|
2018-02-10 10:24:20 -05:00
|
|
|
|
|
2020-02-15 03:48:45 -05:00
|
|
|
|
set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.8/replays.zip")
|
|
|
|
|
set(REPLAYS_SHA1 "3309db1a932709312150124b1e3bbe57c7fb45d0")
|
2019-07-15 13:50:52 -04:00
|
|
|
|
|
2017-05-08 12:35:15 -04:00
|
|
|
|
option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.")
|
|
|
|
|
option(WITH_TESTS "Build tests")
|
2017-05-30 17:34:13 -04:00
|
|
|
|
option(PORTABLE "Create a portable build (-rpath=$ORIGIN)" OFF)
|
2017-02-07 04:20:20 -05:00
|
|
|
|
option(DOWNLOAD_TITLE_SEQUENCES "Download title sequences during installation." ON)
|
2018-02-10 10:24:20 -05:00
|
|
|
|
option(DOWNLOAD_OBJECTS "Download objects during installation." ON)
|
2019-08-13 15:04:08 -04:00
|
|
|
|
CMAKE_DEPENDENT_OPTION(DOWNLOAD_REPLAYS "Download replays during installation." ON
|
|
|
|
|
"WITH_TESTS" OFF)
|
2017-05-08 12:35:15 -04:00
|
|
|
|
|
2018-02-14 14:06:21 -05:00
|
|
|
|
# Options
|
|
|
|
|
option(STATIC "Create a static build.")
|
|
|
|
|
option(USE_MMAP "Use mmap to try loading rct2's data segment into memory.")
|
|
|
|
|
|
2019-11-09 15:20:16 -05:00
|
|
|
|
option(DISABLE_DISCORD_RPC "Disable Discord-RPC support." OFF)
|
|
|
|
|
option(DISABLE_GOOGLE_BENCHMARK "Disable Google Benchmarks support." OFF)
|
2018-02-14 14:06:21 -05:00
|
|
|
|
option(DISABLE_HTTP_TWITCH "Disable HTTP and Twitch support.")
|
|
|
|
|
option(DISABLE_NETWORK "Disable multiplayer functionality. Mainly for testing.")
|
|
|
|
|
option(DISABLE_TTF "Disable support for TTF provided by freetype2.")
|
|
|
|
|
option(ENABLE_LIGHTFX "Enable lighting effects." ON)
|
|
|
|
|
|
2019-01-07 00:08:31 -05:00
|
|
|
|
option(DISABLE_GUI "Don't build GUI. (Headless only.)")
|
|
|
|
|
|
2017-11-14 10:47:13 -05:00
|
|
|
|
if (FORCE32)
|
|
|
|
|
set(TARGET_M "-m32")
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_M}")
|
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M}")
|
|
|
|
|
endif ()
|
|
|
|
|
|
2017-11-16 16:51:41 -05:00
|
|
|
|
if (PORTABLE OR WIN32)
|
|
|
|
|
set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_BINDIR}")
|
|
|
|
|
set(CMAKE_INSTALL_RPATH "$ORIGIN")
|
|
|
|
|
endif ()
|
|
|
|
|
|
2019-02-03 17:32:51 -05:00
|
|
|
|
# LIST of supported flags, use SET_CHECK_CXX_FLAGS() to apply to target.
|
|
|
|
|
# Use ADD_CHECK_CXX_COMPILER_FLAG() to add to list.
|
|
|
|
|
list(APPEND SUPPORTED_CHECK_CXX_COMPILER_FLAGS)
|
|
|
|
|
|
2019-01-27 06:56:36 -05:00
|
|
|
|
include(cmake/ipo.cmake)
|
2019-01-27 07:44:16 -05:00
|
|
|
|
list(APPEND IPO_ENABLED_BUILDS RELEASE RELWITHDEBINFO MINSIZEREL)
|
2019-01-27 06:56:36 -05:00
|
|
|
|
ipo_enable("${IPO_ENABLED_BUILDS}")
|
|
|
|
|
|
2018-06-11 18:25:04 -04:00
|
|
|
|
# Describe current version in terms of closest tag
|
|
|
|
|
execute_process(
|
|
|
|
|
COMMAND git describe HEAD
|
|
|
|
|
COMMAND sed -E "s/-g.+$//"
|
|
|
|
|
WORKING_DIRECTORY ${ROOT_DIR}
|
|
|
|
|
OUTPUT_VARIABLE OPENRCT2_VERSION_TAG
|
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
|
ERROR_QUIET
|
|
|
|
|
)
|
|
|
|
|
|
2017-05-08 12:35:15 -04:00
|
|
|
|
# Define current git branch
|
2016-07-30 19:22:51 -04:00
|
|
|
|
execute_process(
|
2017-01-10 07:09:48 -05:00
|
|
|
|
COMMAND git rev-parse --abbrev-ref HEAD
|
2017-05-08 12:35:15 -04:00
|
|
|
|
WORKING_DIRECTORY ${ROOT_DIR}
|
2017-01-10 07:09:48 -05:00
|
|
|
|
OUTPUT_VARIABLE OPENRCT2_BRANCH
|
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
|
ERROR_QUIET
|
2016-07-30 19:22:51 -04:00
|
|
|
|
)
|
|
|
|
|
|
2017-05-08 12:35:15 -04:00
|
|
|
|
# Define short commit hash
|
2016-07-30 19:22:51 -04:00
|
|
|
|
execute_process(
|
2017-01-10 07:09:48 -05:00
|
|
|
|
COMMAND git rev-parse --short HEAD
|
2017-05-08 12:35:15 -04:00
|
|
|
|
WORKING_DIRECTORY ${ROOT_DIR}
|
2017-01-10 07:09:48 -05:00
|
|
|
|
OUTPUT_VARIABLE OPENRCT2_COMMIT_SHA1_SHORT
|
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
|
ERROR_QUIET
|
2016-07-30 19:22:51 -04:00
|
|
|
|
)
|
2017-05-08 12:35:15 -04:00
|
|
|
|
|
2018-02-14 14:06:21 -05:00
|
|
|
|
|
|
|
|
|
# Defines
|
|
|
|
|
if (USE_MMAP)
|
|
|
|
|
add_definitions(-DUSE_MMAP)
|
|
|
|
|
endif ()
|
|
|
|
|
if (DISABLE_NETWORK)
|
|
|
|
|
add_definitions(-DDISABLE_NETWORK)
|
|
|
|
|
endif ()
|
|
|
|
|
if (DISABLE_HTTP_TWITCH)
|
|
|
|
|
add_definitions(-DDISABLE_HTTP)
|
|
|
|
|
add_definitions(-DDISABLE_TWITCH)
|
|
|
|
|
endif ()
|
|
|
|
|
if (DISABLE_TTF)
|
|
|
|
|
add_definitions(-DNO_TTF)
|
|
|
|
|
endif ()
|
|
|
|
|
if (ENABLE_LIGHTFX)
|
|
|
|
|
add_definitions(-D__ENABLE_LIGHTFX__)
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
if (CXX_WARN_SUGGEST_FINAL_TYPES)
|
|
|
|
|
# Disable -Wsuggest-final-types via pragmas where due.
|
|
|
|
|
add_definitions(-D__WARN_SUGGEST_FINAL_TYPES__)
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
if (CXX_WARN_SUGGEST_FINAL_METHODS)
|
|
|
|
|
# Disable -Wsuggest-final-methods via pragmas where due.
|
|
|
|
|
add_definitions(-D__WARN_SUGGEST_FINAL_METHODS__)
|
|
|
|
|
endif ()
|
|
|
|
|
|
2019-11-09 15:20:16 -05:00
|
|
|
|
if (NOT DISABLE_DISCORD_RPC)
|
|
|
|
|
if(EXISTS "${ROOT_DIR}/discord-rpc")
|
|
|
|
|
# Don't build discord's examples, some of which are in C and do not honour
|
|
|
|
|
# the flags we set for C++. Also we don't use the provided examples.
|
|
|
|
|
set(BUILD_EXAMPLES OFF CACHE BOOL "Build example apps")
|
|
|
|
|
add_subdirectory("${ROOT_DIR}/discord-rpc")
|
|
|
|
|
add_definitions(-D__ENABLE_DISCORD__)
|
|
|
|
|
include_directories("${ROOT_DIR}/discord-rpc/include")
|
|
|
|
|
set(HAVE_DISCORD_RPC TRUE)
|
|
|
|
|
message("Building with discord-rpc support")
|
|
|
|
|
else()
|
|
|
|
|
message("No discord-rpc detected, to enable clone discord-rpc to root directory: ${ROOT_DIR}")
|
|
|
|
|
endif()
|
2017-11-12 16:11:39 -05:00
|
|
|
|
endif()
|
2017-06-14 18:08:41 -04:00
|
|
|
|
|
2017-12-19 17:02:04 -05:00
|
|
|
|
# Copied from https://github.com/opencv/opencv/blob/dcdd6af5a856826fe62c95322145731e702e54c5/cmake/OpenCVDetectCXXCompiler.cmake#L63-L70
|
|
|
|
|
if(MSVC64 OR MINGW64)
|
|
|
|
|
set(X86_64 1)
|
|
|
|
|
elseif(MINGW OR (MSVC AND NOT CMAKE_CROSSCOMPILING))
|
|
|
|
|
set(X86 1)
|
|
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
|
|
|
|
|
set(X86_64 1)
|
|
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*")
|
|
|
|
|
set(X86 1)
|
|
|
|
|
endif()
|
|
|
|
|
|
2019-02-03 17:32:51 -05:00
|
|
|
|
# Check if a flag exists and add it to the list of compiler (so, not linker) options
|
2019-01-26 12:41:56 -05:00
|
|
|
|
function (ADD_CHECK_CXX_COMPILER_FLAG _CXXFLAGS _CACHE_VAR _FLAG)
|
|
|
|
|
CHECK_CXX_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
|
|
|
|
|
if (${_CACHE_VAR})
|
2019-02-03 17:32:51 -05:00
|
|
|
|
list(APPEND SUPPORTED_CHECK_CXX_COMPILER_FLAGS "${_FLAG}")
|
2019-01-26 12:41:56 -05:00
|
|
|
|
else ()
|
|
|
|
|
message(STATUS "Unsupported CXXFLAG: ${_FLAG}")
|
|
|
|
|
endif ()
|
|
|
|
|
endfunction ()
|
|
|
|
|
|
2019-02-03 17:32:51 -05:00
|
|
|
|
# Add check flags to a compile TARGET
|
|
|
|
|
function (SET_CHECK_CXX_FLAGS _TARGET)
|
|
|
|
|
target_compile_options("${_TARGET}" PRIVATE "${SUPPORTED_CHECK_CXX_COMPILER_FLAGS}")
|
|
|
|
|
endfunction()
|
|
|
|
|
|
2019-01-26 12:41:56 -05:00
|
|
|
|
# Check if a flag exists and add it to the compiler and the linker options
|
|
|
|
|
function (ADD_CHECK_CXX_FLAG _CXXFLAGS _CACHE_VAR _FLAG)
|
|
|
|
|
CHECK_CXX_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
|
|
|
|
|
if (${_CACHE_VAR})
|
|
|
|
|
set(${_CXXFLAGS} "${${_CXXFLAGS}} ${_FLAG}" PARENT_SCOPE)
|
|
|
|
|
else ()
|
|
|
|
|
message(STATUS "Unsupported CXXFLAG: ${_FLAG}")
|
|
|
|
|
endif ()
|
|
|
|
|
endfunction ()
|
|
|
|
|
|
|
|
|
|
if (MSVC)
|
2020-01-25 17:42:27 -05:00
|
|
|
|
# CMAKE does not have a built-in option for setting the CRT, so override the default flags.
|
|
|
|
|
# NOTE: doing it this way avoids a linker warning about one directive overriding another
|
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "/MTd /Zi /Ob0 /Od /RTC1")
|
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG")
|
|
|
|
|
|
2019-02-05 10:12:58 -05:00
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /permissive- /Zc:externConstexpr /EHsc /WX")
|
2019-01-26 12:41:56 -05:00
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244") # C4244: 'conversion_type': conversion from 'type1' to 'type2', possible loss of data
|
2019-02-05 10:12:58 -05:00
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4068") # C4068: unknown pragma
|
2019-01-26 12:41:56 -05:00
|
|
|
|
|
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
|
|
|
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
|
2020-01-25 17:42:27 -05:00
|
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")
|
2019-10-15 17:14:00 -04:00
|
|
|
|
add_definitions(-D__SSE4_1__)
|
|
|
|
|
add_definitions(-D__AVX2__)
|
|
|
|
|
endif ()
|
2019-02-05 10:12:58 -05:00
|
|
|
|
add_definitions(-DNOMINMAX)
|
2019-01-26 12:41:56 -05:00
|
|
|
|
else ()
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_NULL_DEREFERENCE -Wnull-dereference)
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_FINAL_TYPES -Wsuggest-final-types)
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_FINAL_METHODS -Wsuggest-final-methods)
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_OVERRIDE -Wsuggest-override)
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_DUPLICATED_COND -Wduplicated-cond)
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_NON_VIRTUAL_DTOR -Wnon-virtual-dtor)
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_MISSING_VARIABLE_DECLARATIONS -Wmissing-variable-declarations)
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_DUPLICATED_BRANCHES -Wduplicated-branches)
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_RESTRICT -Wrestrict)
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_MISSING_FIELD_INITIALIZERS -Wmissing-field-initializers)
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_UNREACHABLE_CODE_BREAK -Wunreachable-code-break)
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_LOGICAL_OP -Wlogical-op)
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_RANGE_LOOP_ANALYSIS -Wrange-loop-analysis)
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_TAUTOLOGICAL_ZERO_COMPARE -Wtautological-unsigned-zero-compare)
|
|
|
|
|
ADD_CHECK_CXX_FLAG(CMAKE_CXX_FLAGS CXX_WNO_CLOBBERED -Wno-clobbered)
|
|
|
|
|
# Disabled due to problems compiling OpenSSL on macOS.
|
|
|
|
|
# ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_DOCUMENTATION -Wdocumentation)
|
|
|
|
|
|
|
|
|
|
# Items below are not supported by ICC
|
|
|
|
|
if (NOT MINGW)
|
|
|
|
|
# Do not enable for MinGW, as its headers contain redundant declarations of builtin functions
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls)
|
|
|
|
|
endif ()
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_IGNORED_QUALIFIERS -Wignored-qualifiers)
|
|
|
|
|
|
|
|
|
|
# -Wstrict-overflow is only active when -fstrict-overflow is enabled, but -fstrict-overflow
|
|
|
|
|
# is enabled on -O2, -O3, -Os. This should help catch bugs locally before they reach Travis
|
|
|
|
|
# As of 2a435bf -Wstrict-overflow=1 passes, but higher values do not.
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstrict-overflow")
|
|
|
|
|
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_STRICT_OVERFLOW -Wstrict-overflow=1)
|
|
|
|
|
|
|
|
|
|
# Compiler flags
|
|
|
|
|
set(DEBUG_LEVEL 0 CACHE STRING "Select debug level for compilation. Use value in range 0–3.")
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstrict-aliasing -Werror -Wundef -Wmissing-declarations -Winit-self -Wall -Wextra -Wshadow")
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas -Wno-missing-braces -Wno-comment -Wnonnull -Wno-unused-parameter")
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG=${DEBUG_LEVEL}")
|
|
|
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=objc-method-access")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# On mingw all code is already PIC, this will avoid compiler error on redefining this option
|
|
|
|
|
if (NOT MINGW)
|
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
if (APPLE AND NOT USE_MMAP)
|
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
|
|
|
|
|
else ()
|
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
endif ()
|
|
|
|
|
endif ()
|
|
|
|
|
|
2019-02-03 17:32:51 -05:00
|
|
|
|
# Include sub-projects
|
|
|
|
|
include("${ROOT_DIR}/src/openrct2/CMakeLists.txt" NO_POLICY_SCOPE)
|
|
|
|
|
include("${ROOT_DIR}/src/openrct2-cli/CMakeLists.txt" NO_POLICY_SCOPE)
|
|
|
|
|
if(NOT DISABLE_GUI)
|
|
|
|
|
include("${ROOT_DIR}/src/openrct2-ui/CMakeLists.txt" NO_POLICY_SCOPE)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# g2
|
|
|
|
|
add_custom_command(
|
|
|
|
|
OUTPUT g2.dat
|
|
|
|
|
COMMAND ./openrct2-cli sprite build \"${CMAKE_BINARY_DIR}/g2.dat\" \"${ROOT_DIR}/resources/g2/sprites.json\"
|
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
|
|
|
)
|
|
|
|
|
add_custom_target(g2 DEPENDS ${PROJECT} g2.dat)
|
|
|
|
|
|
|
|
|
|
# Include tests
|
|
|
|
|
if (WITH_TESTS)
|
|
|
|
|
enable_testing()
|
|
|
|
|
if (UNIX AND (NOT USE_MMAP))
|
|
|
|
|
include("${ROOT_DIR}/test/testpaint/CMakeLists.txt" NO_POLICY_SCOPE)
|
|
|
|
|
endif ()
|
|
|
|
|
include("${ROOT_DIR}/test/tests/CMakeLists.txt" NO_POLICY_SCOPE)
|
|
|
|
|
endif ()
|
2019-01-26 12:41:56 -05:00
|
|
|
|
|
2017-05-08 12:51:04 -04:00
|
|
|
|
# Install
|
|
|
|
|
# Don't recurse, grab all *.txt and *.md files
|
|
|
|
|
file(GLOB DOC_FILES "${ROOT_DIR}/distribution/*.txt")
|
|
|
|
|
list(APPEND DOC_FILES "${ROOT_DIR}/contributors.md"
|
|
|
|
|
"${ROOT_DIR}/licence.txt")
|
|
|
|
|
|
|
|
|
|
# CMake does not allow specifying a dependency chain which includes built-in
|
|
|
|
|
# targets, like `install`, so we have to trick it and execute dependency ourselves.
|
|
|
|
|
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" --build \"${CMAKE_CURRENT_BINARY_DIR}\" --target g2)")
|
2018-02-15 17:57:26 -05:00
|
|
|
|
if (DOWNLOAD_TITLE_SEQUENCES)
|
2018-02-16 09:14:52 -05:00
|
|
|
|
# If openrct2.parkseq or data/title/ exists, assume all the title sequences are already present
|
2018-02-15 17:57:26 -05:00
|
|
|
|
install(CODE
|
2020-01-25 17:42:27 -05:00
|
|
|
|
"if (EXISTS \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT}/title/openrct2.parkseq\" OR EXISTS ${CMAKE_SOURCE_DIR}/data/title/)\n\
|
2018-02-16 09:14:52 -05:00
|
|
|
|
message(\"Using cached title sequences\")\n\
|
2018-02-15 17:57:26 -05:00
|
|
|
|
else () \n\
|
|
|
|
|
file(DOWNLOAD ${TITLE_SEQUENCE_URL} \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT}/title/title-sequences.zip EXPECTED_HASH SHA1=${TITLE_SEQUENCE_SHA1} SHOW_PROGRESS)\n\
|
2018-05-29 17:58:07 -04:00
|
|
|
|
execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT}/title/ \"${CMAKE_COMMAND}\" -E tar xf title-sequences.zip)\n\
|
2018-02-15 17:57:26 -05:00
|
|
|
|
file(REMOVE \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT}/title/title-sequences.zip)\n\
|
|
|
|
|
endif ()")
|
2017-02-07 04:20:20 -05:00
|
|
|
|
endif ()
|
2018-02-10 10:24:20 -05:00
|
|
|
|
if (DOWNLOAD_OBJECTS)
|
2018-03-28 17:25:45 -04:00
|
|
|
|
# If rct2.wtrcyan.json or data/object/ exists, assume all the objects are already present
|
|
|
|
|
install(CODE
|
2020-01-25 17:42:27 -05:00
|
|
|
|
"if (EXISTS \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT}/object/rct2/water/rct2.wtrcyan.json\" OR EXISTS ${CMAKE_SOURCE_DIR}/data/object/)\n\
|
2018-03-28 17:25:45 -04:00
|
|
|
|
message(\"Using cached objects\")\n\
|
|
|
|
|
else () \n\
|
2020-01-25 17:42:27 -05:00
|
|
|
|
file(DOWNLOAD ${OBJECTS_URL} \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT}/object/objects.zip EXPECTED_HASH SHA1=${OBJECTS_SHA1} SHOW_PROGRESS)\n\
|
|
|
|
|
execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT}/object/ \"${CMAKE_COMMAND}\" -E tar xf objects.zip)\n\
|
|
|
|
|
file(REMOVE \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT}/object/objects.zip)\n\
|
2018-03-28 17:25:45 -04:00
|
|
|
|
endif ()")
|
2018-02-10 10:24:20 -05:00
|
|
|
|
endif ()
|
2019-07-15 13:50:52 -04:00
|
|
|
|
if (DOWNLOAD_REPLAYS)
|
2019-07-17 15:19:43 -04:00
|
|
|
|
install(CODE
|
2019-08-08 16:15:21 -04:00
|
|
|
|
"if (EXISTS \${CMAKE_CURRENT_BINARY_DIR}/testdata/replays/)\n\
|
2019-07-17 15:19:43 -04:00
|
|
|
|
message(\"Using cached replays\")\n\
|
|
|
|
|
else () \n\
|
2019-08-08 16:15:21 -04:00
|
|
|
|
file(DOWNLOAD ${REPLAYS_URL} \${CMAKE_CURRENT_BINARY_DIR}/testdata/replays/replays.zip EXPECTED_HASH SHA1=${REPLAYS_SHA1} SHOW_PROGRESS)\n\
|
|
|
|
|
execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \${CMAKE_CURRENT_BINARY_DIR}/testdata/replays/ \"${CMAKE_COMMAND}\" -E tar xf replays.zip)\n\
|
|
|
|
|
file(REMOVE \${CMAKE_CURRENT_BINARY_DIR}/testdata/replays/replays.zip)\n\
|
2019-07-17 15:19:43 -04:00
|
|
|
|
endif ()")
|
2019-07-15 13:50:52 -04:00
|
|
|
|
endif ()
|
2017-11-16 16:51:41 -05:00
|
|
|
|
install(TARGETS "libopenrct2" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
2019-01-07 00:08:31 -05:00
|
|
|
|
if(NOT DISABLE_GUI)
|
|
|
|
|
install(TARGETS "openrct2" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
|
|
|
|
endif()
|
2017-07-26 04:24:03 -04:00
|
|
|
|
install(TARGETS "openrct2-cli" OPTIONAL RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/g2.dat" DESTINATION "${CMAKE_INSTALL_DATADIR}/openrct2")
|
|
|
|
|
install(DIRECTORY "data/" DESTINATION "${CMAKE_INSTALL_DATADIR}/openrct2")
|
|
|
|
|
install(FILES ${DOC_FILES} DESTINATION "${CMAKE_INSTALL_DOCDIR}")
|
2017-08-12 06:21:32 -04:00
|
|
|
|
install(FILES "distribution/linux/openrct2.appdata.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo")
|
2019-11-10 14:05:51 -05:00
|
|
|
|
if (NOT DISABLE_GUI)
|
|
|
|
|
install(FILES "resources/logo/icon_x16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "openrct2.png")
|
|
|
|
|
install(FILES "resources/logo/icon_x24.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/24x24/apps" RENAME "openrct2.png")
|
|
|
|
|
install(FILES "resources/logo/icon_x32.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps" RENAME "openrct2.png")
|
|
|
|
|
install(FILES "resources/logo/icon_x48.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" RENAME "openrct2.png")
|
|
|
|
|
install(FILES "resources/logo/icon_x64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/64x64/apps" RENAME "openrct2.png")
|
|
|
|
|
install(FILES "resources/logo/icon_x96.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/96x96/apps" RENAME "openrct2.png")
|
|
|
|
|
install(FILES "resources/logo/icon_x128.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps" RENAME "openrct2.png")
|
|
|
|
|
install(FILES "resources/logo/icon_x256.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps" RENAME "openrct2.png")
|
|
|
|
|
install(FILES "resources/logo/icon_flag.svg" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps" RENAME "openrct2.svg")
|
|
|
|
|
install(FILES "distribution/linux/openrct2.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
|
|
|
|
install(FILES "distribution/linux/openrct2-savegame.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
|
|
|
|
install(FILES "distribution/linux/openrct2-scenario.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
|
|
|
|
install(FILES "distribution/linux/openrct2-uri.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
|
|
|
|
endif()
|
2017-08-12 05:49:09 -04:00
|
|
|
|
install(FILES "distribution/linux/openrct2-mimeinfo.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages/" RENAME "openrct2.xml")
|
2017-07-26 04:24:03 -04:00
|
|
|
|
install(DIRECTORY "distribution/man/" DESTINATION "${CMAKE_INSTALL_MANDIR}/man6" FILES_MATCHING PATTERN "*.6")
|