-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
351 lines (282 loc) · 10.1 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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
#
# PSYCHOSYNTH
# ===========
#
# Copyright (C) 2007, 2008, 2016 by Juan Pedro Bolivar Puente
#
# 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
cmake_policy(SET CMP0048 NEW) # enable project VERSION
cmake_policy(SET CMP0056 NEW) # honor link flags in try_compile()
project(psychosynth VERSION 0.4.0)
cmake_minimum_required(VERSION 3.5.1)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED on)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-local-typedefs")
# Options
# =====================================================================
set(WITH_LOCAL_DATA off CACHE bool "use local data")
set(WITH_CCACHE auto CACHE string "enable ccache")
set(WITH_DOC auto CACHE string "add target to generate docs")
set(WITH_MAN auto CACHE string "add target to update man page")
set(WITH_PSYNTH auto CACHE string "build cli client")
set(WITH_PSYNTH3D auto CACHE string "build 3d gui client")
set(WITH_TESTS auto CACHE string "build unit tests")
set(WITH_OSC auto CACHE string "enable OSC")
set(WITH_XML auto CACHE string "enable XML config")
set(WITH_OGG auto CACHE string "enable ogg")
set(WITH_WAV auto CACHE string "enable other samples")
set(WITH_ALSA auto CACHE string "enable ALSA sound system")
set(WITH_OSS auto CACHE string "enable OSS sound system")
set(WITH_JACK auto CACHE string "enable Jack sound system")
# Required libraries
# =====================================================================
find_package(PkgConfig)
include(CheckIncludeFiles)
# Boost
# ---------------------------------------------------------------------
set(BOOST_COMPONENTS
system
filesystem
signals)
if(WITH_TESTS)
if(WITH_TESTS STREQUAL auto)
find_package(Boost 1.56 REQUIRED COMPONENTS unit_test_framework)
set(BOOST_TEST_FOUND ${Boost_FOUND})
else()
set(BOOST_TEST_FOUND 1)
endif()
endif()
if(BOOST_TEST_FOUND)
list(APPEND BOOST_COMPONENTS unit_test_framework)
endif()
find_package(Boost 1.56 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
set(BOOST_TEST_FOUND ${Boost_FOUND})
# SoundTouch
# ---------------------------------------------------------------------
pkg_check_modules(SOUNDTOUCH soundtouch REQUIRED)
# Optional libraries
# =====================================================================
function(optional_find_package cond tag package)
if (${cond})
if (NOT (${cond} STREQUAL auto))
set(is_required REQUIRED)
endif()
find_package(${package} ${is_required})
set(${tag}_FOUND ${${tag}_FOUND} PARENT_SCOPE)
endif()
endfunction(optional_find_package)
function(optional_pkg_check_modules cond name expr)
if (${cond})
if (NOT (${cond} STREQUAL auto))
set(is_required REQUIRED)
endif()
pkg_check_modules(${name} ${expr} ${is_required})
endif()
endfunction(optional_pkg_check_modules)
function(optional_check_include_files cond name expr)
if (${cond})
check_include_files(${expr} ${name}_FOUND)
if (NOT (${cond} STREQUAL auto) AND
NOT ${name}_FOUND)
message(SEND_ERROR
"Did not find header file ${expr} "
"as required by ${cond}" )
endif()
endif()
endfunction(optional_check_include_files)
function(optional_find_program cond name expr)
if (${cond})
find_program(${name} ${expr})
if (${name})
set(${name}_FOUND 1 PARENT_SCOPE)
else()
set(${name}_FOUND 0 PARENT_SCOPE)
endif()
if (NOT (${cond} STREQUAL auto) AND
NOT ${name}_FOUND)
message(SEND_ERROR
"Did not find program ${expr} "
"as required by ${cond}" )
endif()
endif()
endfunction(optional_find_program)
optional_pkg_check_modules(WITH_XML LIBXML libxml-2.0>=2.6)
optional_pkg_check_modules(WITH_OSC LIBLO liblo>=0.23)
optional_pkg_check_modules(WITH_WAV SNDFILE sndfile>=1.0.18)
optional_pkg_check_modules(WITH_OGG VORBIS vorbisfile)
optional_pkg_check_modules(WITH_ALSA ALSA alsa>=1.0.0)
optional_pkg_check_modules(WITH_JACK JACK jack>=0.100)
optional_check_include_files(WITH_OSS OSS sys/soundcard.h)
optional_pkg_check_modules(WITH_PSYNTH3D OGRE OGRE>=1.6)
optional_pkg_check_modules(WITH_PSYNTH3D CEGUI CEGUI-0>=0.7)
optional_pkg_check_modules(WITH_PSYNTH3D CEGUIOGRE CEGUI-0-OGRE>=0.7)
optional_pkg_check_modules(WITH_PSYNTH3D OIS OIS>=1.0)
if (OGRE_FOUND)
execute_process(
COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugindir OGRE
OUTPUT_VARIABLE OGRE_PLUGIN_DIR)
endif()
optional_find_program(WITH_CCACHE CCACHE ccache)
optional_find_package(WITH_DOC DOXYGEN Doxygen)
optional_find_program(WITH_MAN HELP2MAN help2man)
# Configure paths
# ===============
include(GNUInstallDirs)
set(PSYNTH_BINDIR "${CMAKE_INSTALL_FULL_BINDIR}")
set(PSYNTH_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
set(PSYNTH_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
set(PSYNTH_DATAROOTDIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}")
set(PSYNTH_DATADIR "${CMAKE_INSTALL_FULL_DATADIR}/psychosynth")
if (WITH_LOCAL_DATA)
set(PSYNTH_DATADIR "${CMAKE_CURRENT_SOURCE_DIR}/data")
endif()
# Define targets
# =====================================================================
function (set_yes_no variable)
if (${ARGN})
set(${variable} yes PARENT_SCOPE)
set(${variable}_P 1 PARENT_SCOPE)
else()
set(${variable} no PARENT_SCOPE)
set(${variable}_P 0 PARENT_SCOPE)
endif()
endfunction(set_yes_no)
set_yes_no(BUILD_PSYNTH LIBLO_FOUND)
set_yes_no(BUILD_PSYNTH3D
OGRE_FOUND AND CEGUI_FOUND AND
CEGUIOGRE_FOUND AND OIS_FOUND)
set_yes_no(BUILD_TESTS BOOST_TEST_FOUND)
set_yes_no(HAVE_OSC LIBLO_FOUND)
set_yes_no(HAVE_XML LIBXML_FOUND)
set_yes_no(HAVE_WAV SNDFILE_FOUND)
set_yes_no(HAVE_OGG VORBIS_FOUND)
set_yes_no(HAVE_SOUNDTOUCH SOUNDTOUCH_FOUND)
set_yes_no(HAVE_OSS OSS_FOUND)
set_yes_no(HAVE_ALSA ALSA_FOUND)
set_yes_no(HAVE_JACK JACK_FOUND)
set_yes_no(HAVE_CCACHE CCACHE_FOUND)
set_yes_no(HAVE_DOC DOXYGEN_FOUND)
set_yes_no(HAVE_MAN HELP2MAN_FOUND)
if(HAVE_CCACHE)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
endif()
enable_testing()
add_custom_target(check DEPENDS test)
add_subdirectory(src)
add_subdirectory(doc)
add_subdirectory(data)
# Uninstall target
# =====================================================================
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND}
-P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
# dist target
# =====================================================================
find_package(Git)
if (GIT_FOUND)
set(PSYNTH_ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION})
add_custom_target(dist
COMMAND ${GIT_EXECUTABLE} archive
--prefix=${PSYNTH_ARCHIVE_NAME}/ HEAD
-o ${CMAKE_BINARY_DIR}/${PSYNTH_ARCHIVE_NAME}.tar.bz2
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()
# Summary
# =====================================================================
message("
${PROJECT_NAME} ${PROJECT_VERSION}
Configuration summmary
")
message(" 3d client (psynth3d) ..... ${BUILD_PSYNTH3D}")
if (WITH_PSYNTH3D)
if (NOT OGRE_FOUND)
message(" > Ogre >= 1.6 not installed")
endif()
if (NOT CEGUI_FOUND)
message(" > Cegui >= 0.7 not installed")
endif()
if (NOT CEGUIOGRE_FOUND)
message(" > Cegui-Ogre >= 0.7 not installed")
endif()
if (NOT OIS_FOUND)
message(" > OIS >= 1.0 not installed")
endif()
endif()
message(" CLI client (psynth) ...... ${BUILD_PSYNTH}")
if (WITH_PSYNTH AND NOT LIBLO_FOUND)
message(" > liblo >= 0.26 not installed")
endif()
message("")
message(" OSC support: ............. ${HAVE_OSC}")
if (WITH_OSC AND NOT LIBLO_FOUND)
message(" > liblo >= 0.26 not installed")
endif()
message(" XML config support: ...... ${HAVE_XML}")
if (WITH_WAV AND NOT LIBXML_FOUND)
message(" > libxml >= 2.0 not installed")
endif()
message(" Time-stretch support: .... ${HAVE_SOUNDTOUCH}")
if (NOT SOUNDTOUCH_FOUND)
message(" > libSoundTouch not installed")
endif()
message(" Sampling support: ........ ${HAVE_WAV}")
if (WITH_WAV AND NOT SNDFILE_FOUND)
message(" > libsndfile >= 1.0.18 not installed")
endif()
message(" OSS support: ............. ${HAVE_OSS}")
if (WITH_OSS AND NOT OSS_FOUND)
message(" > no 'sys/soundcard.h' header")
endif()
message(" ALSA support: ............ ${HAVE_ALSA}")
if (WITH_ALSA AND NOT ALSA_FOUND)
message(" > ALSA >= 1.0 not installed")
endif()
message(" Jack support: ............ ${HAVE_JACK}")
if (WITH_JACK AND NOT JACK_FOUND)
message(" > Jack >= 0.100 not installed")
endif()
message("")
message(" Update man: .............. ${HAVE_DOC}")
if (WITH_MAN AND NOT HELP2MAN_FOUND)
message(" > help2man not installed")
endif()
message(" Reference docs: .......... ${HAVE_DOC}")
if (WITH_DOC AND NOT DOXYGEN_FOUND)
message(" > doxygen not installed")
endif()
message(" Use ccache: .............. ${HAVE_CCACHE}")
if (WITH_CCACHE AND NOT CCACHE_FOUND)
message(" > ccache not installed")
endif()
message(" Unit tests: .............. ${BUILD_TESTS}")
if (WITH_TESTS AND NOT BOOST_TEST_FOUND)
message(" > Boost.UTF not installed")
endif()
message("
Installation directories
Prefix: .......... ${CMAKE_INSTALL_PREFIX}
Programs: ........ ${PSYNTH_BINDIR}
Libraries: ....... ${PSYNTH_LIBDIR}
Headers: ......... ${PSYNTH_INCLUDEDIR}
Data: ............ ${PSYNTH_DATAROOTDIR}
Custom data: ..... ${PSYNTH_DATADIR}
")
message("
")