-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
233 lines (192 loc) · 7.8 KB
/
Copy pathCMakeLists.txt
File metadata and controls
233 lines (192 loc) · 7.8 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# CMakeLists.txt:jeff
#
# nomlib
#
# WARNING(JEFF): CMake v4.4.x is known to break MacOSX builds -- the
# framework bundles no longer accept our headers as they are specified. No
# known workaround.
cmake_minimum_required(VERSION 3.24...4.2.3)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
list(APPEND CMAKE_TEMPLATE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates")
include("${CMAKE_SOURCE_DIR}/cmake/project_version.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/policy.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/functions.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/macros.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/AppleBuild.cmake")
##
# Project Options
##
#
## architecture
#
option(ARCH_32 "Build target for 32-bit CPU" OFF)
option(ARCH_64 "Build target for 64-bit CPU" ON)
# Reserved for future implementation
option(AARCH_32 "Build target ARM CPU" OFF)
option(AARCH_64 "Build target ARM64 CPU" OFF)
# Debugging
option(DEBUG_ASSERT "Build with run-time assertion enabled" OFF)
option(HIDE_SYMBOL_VISIBILITY "Enforce symbol visibility - see NOM_EXPORT macros" OFF)
# Engine build configuration
option(BUILD_SHARED_LIBS "Build dynamic library targets" OFF)
option(BUILD_EXAMPLES "Build usage examples" OFF)
option(BUILD_TESTS "Build unit tests" OFF)
option(BUILD_DOCS "Build engine documentation" ON)
option(NOM_USE_CCACHE "Use ccache - a compiler cache for C/C++" OFF)
# EXPERIMENTAL(JEFF): This feature is a WIP and is not yet ready for general
# consumption. Your milage may vary.
option(NOM_USE_DISTCC "Use distcc - a free, fast distributed C/C++ compiler" OFF)
#
## DEPRECATED options handling
#
if(DEFINED UNIVERSAL)
message(DEPRECATION "Option 'UNIVERSAL' is deprecated. Use 'CMAKE_OSX_ARCHITECTURES' instead.")
endif(DEFINED UNIVERSAL)
if(DEFINED DEBUG)
message(DEPRECATION "Option 'DEBUG' is deprecated. Use 'CMAKE_BUILD_TYPE' instead.")
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE BOOL "Enable debugging features" FORCE)
endif(DEFINED DEBUG)
if(DEFINED EXAMPLES)
message(DEPRECATION "Option 'EXAMPLES' is deprecated. Use 'BUILD_EXAMPLES' instead.")
set(BUILD_EXAMPLES ${EXAMPLES} CACHE BOOL "Build usage examples" FORCE)
endif(DEFINED EXAMPLES)
if(DEFINED NOM_BUILD_TESTS)
message(DEPRECATION "Option 'NOM_BUILD_TESTS' is deprecated. Use 'BUILD_TESTS' instead.")
set(BUILD_TESTS ${NOM_BUILD_TESTS} CACHE BOOL "Build unit tests" FORCE)
endif(DEFINED NOM_BUILD_TESTS)
if(DEFINED NOM_BUILD_DOCS)
message(DEPRECATION "Option 'NOM_BUILD_DOCS' is deprecated. Use 'BUILD_DOCS' instead.")
set(BUILD_DOCS ${NOM_BUILD_DOCS} CACHE BOOL "Build engine documentation" FORCE)
endif(DEFINED NOM_BUILD_DOCS)
#
## Library units
#
option( NOM_BUILD_ACTIONS_UNIT "Animations subsystem" ON)
option( NOM_BUILD_CORE_UNIT "Engine core" ON)
option( NOM_BUILD_MATH_UNIT "Math utilities" ON)
option( NOM_BUILD_FILE_UNIT "Filesystem access" ON)
option( NOM_BUILD_AUDIO_UNIT "Audio subsystem" ON)
option( NOM_BUILD_GRAPHICS_UNIT "Graphics core" ON)
option( NOM_BUILD_EXTRA_RESCALE_ALGO_UNIT "Build with scale2x & hqx algorithms" ON)
option( NOM_BUILD_SYSTEM_UNIT "System unit" ON)
option( NOM_BUILD_PTREE_UNIT "Generic container for serialization" ON)
option( NOM_BUILD_SERIALIZERS_UNIT "Serialization for JSON, XML, HTML" ON)
option( NOM_BUILD_GUI_UNIT "GUI subsystem" ON)
#
## install and packaging
#
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" is_top_level)
option(NOM_INSTALL_CMAKE_PACKAGE "Install CMake export package for finding nomlib" "${is_top_level}")
option(NOM_INSTALL_PKGCONFIG_SUPPORT "Install pkg-config helper for finding nomlib" "${is_top_level}")
option(NOM_INSTALL_GCDB "gamecontroller_db vendor" OFF)
option(NOM_INSTALL_CMAKE_REGISTRY "Let other local projects find and use nomlib without a complete install" ON)
if(DEFINED nomlib_SHARED_LIBS)
set(BUILD_SHARED_LIBS "${nomlib_SHARED_LIBS}")
endif()
# IMPORTANT(JEFF): This initializes our engine versioning variables;
# `PROJECT_VERSION_MAJOR` & friends at `include/nomlib/version.hpp.in`
project(nomlib
VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
DESCRIPTION "C++11 2D game framework using SDL2"
HOMEPAGE_URL "https://github.com/i8degrees/nomlib"
#SPDX_LICENSE "BSD-2-Clause-FreeBSD"
LANGUAGES CXX
)
include("${CMAKE_SOURCE_DIR}/cmake/StandardProjectSettings.cmake")
# Adhere to a common hierarchy acording to the chosen platform
include(GNUInstallDirs)
# Link this "library" to use the warnings specified in CompilerWarnings.cmake.
add_library(project_warnings INTERFACE)
include("${CMAKE_SOURCE_DIR}/cmake/CompilerWarnings.cmake")
# Add cmake option WARNINGS_AS_ERRORS
set_project_warnings(project_warnings)
if(NOM_INSTALL_PKGCONFIG_SUPPORT)
# nomlib.pc.in -> nomlib.pc
include(PkgConfig)
endif(NOM_INSTALL_PKGCONFIG_SUPPORT)
#
## Project-wide env
#
# Public API headers base
set(HDR_BASE "${PROJECT_SOURCE_DIR}/include/nomlib")
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
# Unit testing resources path
set(NOM_TESTS_RESOURCES_DIR "${PROJECT_SOURCE_DIR}/Resources/tests")
# Files used with documentation generation
set(PROJECT_DOXYGEN_DIR "${NOMLIB_RESOURCES_DIR}/doxygen")
# Platform-specific implementations & dependencies
#
# See also: nomlib's third-party/README.md
include("${CMAKE_SOURCE_DIR}/vendor/CMakeLists.txt")
#
## Project-wide build settings
#
if(BUILD_SHARED_LIBS)
set(LIBRARY_OUTPUT_TYPE "SHARED")
else(NOT BUILD_SHARED_LIBS)
set(LIBRARY_OUTPUT_TYPE "STATIC")
endif(BUILD_SHARED_LIBS)
message(STATUS "Building nomlib as ${LIBRARY_OUTPUT_TYPE} library targets")
# CMAKE_SYSTEM_PREFIX_PATH is searched to find libraries when the find_package
# command is used.
message(STATUS "Library Search Prefix: ${CMAKE_SYSTEM_PREFIX_PATH}")
# Installation prefix path set for our project
message(STATUS "Installation Prefix: ${CMAKE_INSTALL_PREFIX}")
#
## Third-party dependencies
#
# Fallback to Release, then Debug if MinSizeRel/RelWithDebInfo are missing
# from the CMake import targets for the libraries in question. This is
# apparently an issue when using a multi-config CMake generator,
# (like Visual Studio) and an imported dependency (i.e.: libRocket) was only
# built in Debug or Release mode, leaving CMake unable to find the library
# files for the other configurations.
set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL Release Debug "")
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release Debug "")
# This is a hard requirement for GoogleTest (BUILD_TESTS=on)
find_package(Threads REQUIRED)
find_package(SDL2 CONFIG REQUIRED)
find_package(SDL2_image CONFIG REQUIRED)
find_package(SDL2_ttf CONFIG REQUIRED)
if(NOM_BUILD_GUI_UNIT)
find_package(OpenGL REQUIRED)
find_package(libRocket CONFIG REQUIRED)
endif()
if(NOM_BUILD_AUDIO_UNIT) # required dependencies
if(APPLE)
find_package(OpenAL REQUIRED)
else(NOT APPLE)
find_package(OpenAL CONFIG REQUIRED)
endif(APPLE)
find_package(SndFile CONFIG REQUIRED)
else(NOT NOM_BUILD_AUDIO_UNIT) # optional dependencies
if(APPLE)
find_package(OpenAL)
else(NOT APPLE)
find_package(OpenAL CONFIG)
endif(APPLE)
find_package(SndFile CONFIG)
endif(NOM_BUILD_AUDIO_UNIT)
if(BUILD_DOCS)
# Doxygen configuration
include("${PROJECT_SOURCE_DIR}/cmake/doxygen.cmake")
endif(BUILD_DOCS)
# >> src/<component>/CMakeLists.txt contains our NOM_BUILD_<component> options
add_subdirectory("src")
# nomlib examples configuration
if(BUILD_EXAMPLES)
add_subdirectory("examples")
endif()
if(BUILD_TESTS)
# TODO(JEFF): CTest setup goes here
enable_testing()
add_subdirectory("tests")
endif()
# Installation phase
# >> We will not be the top-level project if being included via CMake's FetchContent
# >> mechanism. If so, we should try not to assume that the end-user wants anything
# >> to be packaged (installed), and let them decide what they want to do themselves.
if(is_top_level)
add_subdirectory("src/packages")
endif(is_top_level)