2017-05-08 12:35:15 -04:00
|
|
|
# CMAKE project for openrct2
|
2014-05-20 12:35:27 -04:00
|
|
|
cmake_minimum_required(VERSION 2.6)
|
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-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
|
|
|
|
2017-05-08 12:51:04 -04:00
|
|
|
set(TITLE_SEQUENCE_URL "https://github.com/OpenRCT2/title-sequences/releases/download/v0.0.5/title-sequence-v0.0.5.zip")
|
|
|
|
set(TITLE_SEQUENCE_SHA1 "79ffb2585d12abcbfce205d7696e3472a504b005")
|
|
|
|
|
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)
|
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
|
|
|
)
|
|
|
|
add_definitions(-DOPENRCT2_BRANCH="${OPENRCT2_BRANCH}")
|
|
|
|
|
2017-05-08 12:35:15 -04:00
|
|
|
# Define commit hash
|
2016-07-30 19:22:51 -04:00
|
|
|
execute_process(
|
2017-01-10 07:09:48 -05:00
|
|
|
COMMAND git rev-parse 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
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
ERROR_QUIET
|
2016-07-30 19:22:51 -04:00
|
|
|
)
|
|
|
|
add_definitions(-DOPENRCT2_COMMIT_SHA1="${OPENRCT2_COMMIT_SHA1}")
|
|
|
|
|
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
|
|
|
|
2017-01-29 16:49:17 -05:00
|
|
|
# Tagged builds are not meant to display commit info
|
|
|
|
if (NOT OPENRCT2_COMMIT_SHA1_SHORT STREQUAL "HEAD")
|
|
|
|
add_definitions(-DOPENRCT2_COMMIT_SHA1_SHORT="${OPENRCT2_COMMIT_SHA1_SHORT}")
|
|
|
|
endif()
|
2016-07-30 19:22:51 -04:00
|
|
|
|
2017-05-08 12:35:15 -04:00
|
|
|
# Include sub-projects
|
|
|
|
include("${ROOT_DIR}/src/openrct2/CMakeLists.txt" NO_POLICY_SCOPE)
|
2017-05-29 16:13:46 -04:00
|
|
|
include("${ROOT_DIR}/src/openrct2-cli/CMakeLists.txt" NO_POLICY_SCOPE)
|
|
|
|
include("${ROOT_DIR}/src/openrct2-ui/CMakeLists.txt" NO_POLICY_SCOPE)
|
2015-10-03 17:55:23 -04:00
|
|
|
|
2017-05-08 12:35:15 -04:00
|
|
|
# g2
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT g2.dat
|
|
|
|
COMMAND ./openrct2 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)
|
2016-10-28 06:33:37 -04:00
|
|
|
|
2017-05-08 12:35:15 -04:00
|
|
|
# Include tests
|
2016-11-28 08:37:27 -05:00
|
|
|
if (WITH_TESTS)
|
2017-01-10 07:09:48 -05:00
|
|
|
enable_testing()
|
2017-05-08 12:56:04 -04:00
|
|
|
if (UNIX AND (NOT USE_MMAP) AND (NOT DISABLE_RCT2) AND (FORCE32))
|
|
|
|
include("${ROOT_DIR}/test/testpaint/CMakeLists.txt" NO_POLICY_SCOPE)
|
|
|
|
endif ()
|
2017-05-08 12:35:15 -04:00
|
|
|
include("${ROOT_DIR}/test/tests/CMakeLists.txt" NO_POLICY_SCOPE)
|
2016-11-28 08:37:27 -05:00
|
|
|
endif ()
|
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)")
|
2017-02-07 04:20:20 -05:00
|
|
|
IF (DOWNLOAD_TITLE_SEQUENCES)
|
|
|
|
install(CODE "file(DOWNLOAD ${TITLE_SEQUENCE_URL} \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/share/${PROJECT}/title/title-sequences.zip EXPECTED_HASH SHA1=${TITLE_SEQUENCE_SHA1} SHOW_PROGRESS)")
|
|
|
|
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/share/${PROJECT}/title/ \"${CMAKE_COMMAND}\" -E tar xvf title-sequences.zip)")
|
|
|
|
install(CODE "file(REMOVE \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/share/${PROJECT}/title/title-sequences.zip)")
|
|
|
|
endif ()
|
2017-05-20 17:34:13 -04:00
|
|
|
if (WIN32)
|
2017-05-30 17:34:13 -04:00
|
|
|
install(TARGETS "libopenrct2" RUNTIME DESTINATION "bin")
|
|
|
|
else ()
|
|
|
|
if (PORTABLE)
|
|
|
|
install(TARGETS "libopenrct2" LIBRARY DESTINATION "bin")
|
|
|
|
else ()
|
|
|
|
install(TARGETS "libopenrct2" LIBRARY DESTINATION "lib")
|
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
install(TARGETS "openrct2" RUNTIME DESTINATION "bin")
|
2017-05-08 13:43:40 -04:00
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/g2.dat" DESTINATION "share/openrct2")
|
|
|
|
install(DIRECTORY "data/" DESTINATION "share/openrct2")
|
|
|
|
install(FILES ${DOC_FILES} DESTINATION "share/doc/openrct2")
|
2017-06-03 05:16:43 -04:00
|
|
|
install(FILES "resources/logo/icon_x16.png" DESTINATION "share/icons/hicolor/16x16/apps" RENAME "openrct2.png")
|
|
|
|
install(FILES "resources/logo/icon_x32.png" DESTINATION "share/icons/hicolor/32x32/apps" RENAME "openrct2.png")
|
|
|
|
install(FILES "resources/logo/icon_x64.png" DESTINATION "share/icons/hicolor/64x64/apps" RENAME "openrct2.png")
|
|
|
|
install(FILES "resources/logo/icon_x128.png" DESTINATION "share/icons/hicolor/128x128/apps" RENAME "openrct2.png")
|
|
|
|
install(FILES "resources/logo/icon_x256.png" DESTINATION "share/icons/hicolor/256x256/apps" RENAME "openrct2.png")
|
|
|
|
install(FILES "resources/logo/icon_flag.svg" DESTINATION "share/icons/hicolor/scalable/apps" RENAME "openrct2.svg")
|
2017-05-08 13:43:40 -04:00
|
|
|
install(FILES "distribution/linux/openrct2.desktop" DESTINATION "share/applications")
|
2017-06-01 13:45:40 -04:00
|
|
|
install(DIRECTORY "distribution/man/" DESTINATION "share/man/man6" FILES_MATCHING PATTERN "*.6")
|
|
|
|
install(CODE "execute_process(COMMAND find \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/share/man/man6 -type f -exec gzip -f \"{}\" \;)")
|