-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
133 lines (111 loc) · 4.15 KB
/
Copy pathCMakeLists.txt
File metadata and controls
133 lines (111 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(openblok LANGUAGES CXX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
include(ProjectVersion)
# Default to release build
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
# Portable install
set(INSTALL_PORTABLE_DEFAULT OFF)
if(WIN32 OR CYGWIN)
set(INSTALL_PORTABLE_DEFAULT ON)
endif()
option(INSTALL_PORTABLE "The installation step should put the data directory next to the runtime" ${INSTALL_PORTABLE_DEFAULT})
option(USE_BUNDLED_SDL2 "Download and build SDL2 libraries" OFF)
option(USE_BUNDLED_SDL2PP "Download and build libSDL2pp" ON)
option(USE_BUNDLED_UNITTESTPP "Download and build UnitTest++" ON)
option(ENABLE_MP3 "Enable MP3 music support" ON)
option(ENABLE_MOD "Enable MOD music support" ON)
option(ENABLE_FLAC "Enable FLAC music support" ON)
# Currently unit tests only work only in Debug
set(BUILD_TESTS_DEFAULT OFF)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(BUILD_TESTS_DEFAULT ON)
endif()
option(BUILD_TESTS "Build the unit tests" ${BUILD_TESTS_DEFAULT})
option(BUILD_TEST_COVERAGE "Build the test coverage report" OFF)
# Intallation locations
if(INSTALL_PORTABLE)
set(EXEDIR "." CACHE STRING "Install location of the runtime executable")
set(DATADIR "./data" CACHE STRING "Install location of the data files")
set(CMAKE_INSTALL_RPATH "$ORIGIN")
else()
set(SHAREDIR "share" CACHE STRING "Base directory of installed data files")
set(EXEDIR "games" CACHE STRING "Install location of the runtime executable")
set(DATADIR "${SHAREDIR}/openblok" CACHE STRING "Install location of the data files")
if(UNIX AND NOT APPLE AND NOT CYGWIN)
option(INSTALL_DESKTOPICON "Install desktop shortcut and icon" ON)
option(INSTALL_APPSTREAM "Install AppStream metainfo" ON)
set(ICONDIR "${SHAREDIR}/pixmaps" CACHE STRING "Install location of the icon file")
set(DESKTOPDIR "${SHAREDIR}/applications" CACHE STRING "Install location of the desktop shortcut")
set(APPSTREAMDIR "${SHAREDIR}/metainfo" CACHE STRING "Install location of the AppStream metainfo")
endif()
endif()
# Localization
option(ENABLE_LOCALES "Enable localization support" ON)
if(ENABLE_LOCALES)
add_subdirectory(locale)
endif()
# Global compiler settings
# Build coverage report if requested
if(BUILD_TEST_COVERAGE)
include(CodeCoverage)
setup_target_for_coverage(openblok_coverage openblok_test coverage)
endif()
include(BundledDependencies)
# The main game source
include_directories(src)
add_subdirectory(src)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
# Install
install(DIRECTORY data/ DESTINATION ${DATADIR} PATTERN "*.txt" EXCLUDE)
if(INSTALL_DESKTOPICON)
install(FILES etc/linux/hu.mmatyas.openblok.desktop DESTINATION ${DESKTOPDIR})
install(FILES data/icon.png DESTINATION ${ICONDIR} RENAME openblok.png)
endif()
if(INSTALL_APPSTREAM)
install(FILES etc/linux/hu.mmatyas.openblok.metainfo.xml DESTINATION ${APPSTREAMDIR})
endif()
if(USE_BUNDLED_SDL2)
if(INSTALL_PORTABLE)
install(TARGETS SDL2 SDL2_mixer SDL2_image SDL2_ttf DESTINATION ${EXEDIR})
else()
install(TARGETS SDL2 SDL2_mixer SDL2_image SDL2_ttf DESTINATION "lib")
endif()
endif()
# Package
include(CPackConfig)
include(CPack)
# Display settings
set(MSG_BUILDTYPE ${CMAKE_BUILD_TYPE})
set(MSG_TESTS "do not build")
if(BUILD_TESTS)
set(MSG_TESTS "build, tests only")
if(BUILD_TEST_COVERAGE)
set(MSG_TESTS "build, with coverage")
endif()
endif()
set(MSG_INSTALL "install to ${CMAKE_INSTALL_PREFIX}")
if(INSTALL_PORTABLE)
set(MSG_INSTALL "portable, default ${MSG_INSTALL}")
endif()
message(STATUS "|")
message(STATUS "| Build type: ${MSG_BUILDTYPE}")
message(STATUS "| Tests: ${MSG_TESTS}")
message(STATUS "| Install: ${MSG_INSTALL}")
message(STATUS "| - runtime dir: ${EXEDIR}")
message(STATUS "| - data dir: ${DATADIR}")
if(INSTALL_DESKTOPICON)
message(STATUS "| - shortcut, icon: yes")
endif()
if(INSTALL_APPSTREAM)
message(STATUS "| - appstream: yes")
endif()
if(ENABLE_LOCALES)
message(STATUS "| - localization: yes")
endif()
message(STATUS "|")