-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathCMakeLists.txt
291 lines (247 loc) · 9.36 KB
/
CMakeLists.txt
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
#
# Copyright (C) 2016 Splash authors
#
# This file is part of Splash.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Splash is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Splash. If not, see <http://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 3.16)
# Force the installation prefix, as under certain circumstances on Windows it defaults
# to "C:\Program Files (x86)", which is not correct and conflicts the installation path
# of NSIS.
# Note that this has to be set BEFORE the call to project(...), otherwise it will have
# no effect
if (WIN32)
set(CMAKE_INSTALL_PREFIX "C:\\Program Files\\splash" CACHE PATH "Default directory for Splash installation on Windows")
endif()
project(
splash
VERSION 0.10.20
LANGUAGES C CXX
)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
# Set default build type to Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
enable_testing()
#
# Package information
#
set(API_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
set(PACKAGE_VERSION ${PROJECT_VERSION})
#
# Build options
#
set(BUILD_GENERIC_ARCH OFF CACHE BOOL "Enable building generic binaries, without more modern extensions")
set(BUILD_CODE ON CACHE BOOL "Enable building the code")
set(DEBUG_OPENGL OFF CACHE BOOL "Enable OpenGL debugging")
set(PROFILE OFF CACHE BOOL "Enable profiling")
set(PROFILE_OPENGL OFF CACHE BOOL "Enable OpenGL profiling")
set(USE_SYSTEM_LIBS OFF CACHE BOOL "Enable using system libraries instead of bundle ones")
set(TEST_COVERAGE OFF CACHE BOOL "Enable test coverage")
set(WITH_LTO OFF CACHE BOOL "Activate link time optimization (LTO)")
set(WITH_SANITIZE OFF CACHE BOOL "Enable sanitize compile options")
include(CheckIPOSupported)
include(set_icon)
check_ipo_supported(RESULT IPO_SUPPORTED)
if (NOT IPO_SUPPORTED)
set(WITH_LTO FALSE)
endif()
# Force color output (useful when building with Ninja)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options (-fdiagnostics-color=always)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options (-fcolor-diagnostics)
endif ()
#
# Find the various libraries
#
if (NOT USE_SYSTEM_LIBS)
set(ENV{PKG_CONFIG_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/external/third_parties/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}")
endif()
find_package(PkgConfig REQUIRED)
find_package(Threads)
if (BUILD_CODE)
# Mandatory dependencies
pkg_search_module(JSONCPP REQUIRED jsoncpp)
pkg_search_module(GSL REQUIRED gsl)
pkg_search_module(ZMQ REQUIRED libzmq)
pkg_check_modules(FFMPEG REQUIRED libavformat libavcodec libavutil libswscale)
# Optional dependencies
find_package (Python3 COMPONENTS Interpreter Development)
find_package(OpenCV)
pkg_search_module(GPHOTO libgphoto2)
pkg_search_module(JACK jack)
pkg_search_module(PORTAUDIO portaudio-2.0)
pkg_search_module(SH4LT sh4lt-0.1)
pkg_search_module(SHMDATA shmdata-1.3)
pkg_search_module(CALIMIRO calimiro-0.2)
endif()
find_program(ZIP zip)
find_package(Doxygen)
#
# Configuration
#
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLM_FORCE_RADIANS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDATADIR=\"\\\"${CMAKE_INSTALL_PREFIX}/share/splash/\\\"\"")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSPLASHPREFIX=\"\\\"${CMAKE_INSTALL_PREFIX}\\\"\"")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
if (TEST_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 --coverage")
endif()
set(HAVE_GPHOTO ${GPHOTO_FOUND})
set(HAVE_OPENCV ${OPENCV_FOUND})
set(HAVE_PORTAUDIO ${PORTAUDIO_FOUND})
set(HAVE_SH4LT ${SH4LT_FOUND})
set(HAVE_SHMDATA ${SHMDATA_FOUND})
set(HAVE_PYTHON ${Python3_FOUND})
set(HAVE_CALIMIRO ${CALIMIRO_FOUND})
if (FFMPEG_libavformat_VERSION LESS 57)
message(WARNING "FFmpeg version is older than 3.1, support disabled")
set(FFMPEG_FOUND 0)
endif()
if (UNIX)
set(HAVE_LINUX 1)
elseif (WIN32)
set(HAVE_WINDOWS 1)
endif()
if (DEBUG_OPENGL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUGGL")
endif()
if (PROFILE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTRACY_ENABLE")
endif()
if (PROFILE_OPENGL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROFILE_GPU")
endif()
if ("${JACK_LIBRARIES}" STREQUAL "")
set(HAVE_JACK 0)
else()
set(HAVE_JACK 1)
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/src/config.h")
#
# Generic compilation flags
#
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE AND NOT BUILD_GENERIC_ARCH)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
#
# Sources
#
add_subdirectory(addons)
add_subdirectory(docs)
if (BUILD_CODE)
add_subdirectory(data)
add_subdirectory(external)
add_subdirectory(src)
add_subdirectory(tests)
endif()
# Uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake)
#
# CPack related info
# Creates package on Linux.
#
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Splash, a modular multi-projector video-mapping software")
set(CPACK_PACKAGE_VENDOR "Splash authors")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/License.md")
if (UNIX)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-mapper")
set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
set(CPACK_DEBIAN_PROJECT_HOMEPAGE "https://splashmapper.xyz")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR} <[email protected]>")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Splash is a free (as in GPL) modular mapping software. Provided that the user creates a 3D model with UV mapping of the projection surface, Splash will take care of calibrating the videoprojectors (intrinsic and extrinsic parameters, blending), and feed them with the input video sources. Splash can handle multiple inputs, mapped on multiple 3D models, and has been tested with up to eight outputs on two graphic cards. It currently runs on a single computer but support for multiple computers is planned.")
set(CPACK_DEBIAN_PACKAGE_SECTION "video")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
elseif (WIN32)
set(CPACK_GENERATOR "NSIS")
set(CPACK_PACKAGE_EXECUTABLES "splash" "Splash")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_PROJECT_NAME}")
set(CPACK_NSIS_DISPLAY_NAME "splash")
set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/data/share/icons/splash.ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/data/share/icons/splash.ico")
set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\${CMAKE_PROJECT_NAME}.exe")
set(CPACK_NSIS_HELP_LINK "https://splashmapper.xyz/en/contents.html")
set(CPACK_NSIS_URL_INFO_ABOUT "https://splashmapper.xyz")
set(CPACK_NSIS_MODIFY_PATH OFF)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_PACKAGING_INSTALL_PREFIX "/")
endif()
include(CPack)
#
# Summary
#
set(_config_msg "\nSplash Configuration\n=====================")
function(info_cfg_option
_setting
)
set(_msg " - ${_setting}")
string(LENGTH "${_msg}" _len)
while("32" GREATER "${_len}")
set(_msg "${_msg} ")
math(EXPR _len "${_len} + 1")
endwhile()
set(_config_msg "${_config_msg}\n${_msg}${${_setting}}" PARENT_SCOPE)
endfunction()
function(info_cfg_text
_text
)
set(_config_msg "${_config_msg}\n\n ${_text}" PARENT_SCOPE)
endfunction()
info_cfg_option(USE_SYSTEM_LIBS)
info_cfg_option(GPHOTO_VERSION)
info_cfg_option(FFMPEG_libavformat_VERSION)
info_cfg_option(FFMPEG_libavcodec_VERSION)
info_cfg_option(FFMPEG_libavutil_VERSION)
info_cfg_option(FFMPEG_libswscale_VERSION)
info_cfg_option(OpenCV_VERSION)
info_cfg_option(PORTAUDIO_VERSION)
info_cfg_option(JACK_VERSION)
info_cfg_option(Python3_VERSION)
info_cfg_option(JSONCPP_VERSION)
info_cfg_option(SH4LT_VERSION)
info_cfg_option(SHMDATA_VERSION)
info_cfg_option(CALIMIRO_VERSION)
info_cfg_option(ZMQ_VERSION)
info_cfg_option(DOXYGEN_FOUND)
info_cfg_option(ZIP)
info_cfg_option(DEBUG_OPENGL)
info_cfg_option(PROFILE)
info_cfg_option(PROFILE_OPENGL)
info_cfg_option(WITH_LTO)
info_cfg_text("")
message("${_config_msg}")