1 |
cmake_minimum_required(VERSION 3.10) |
2 |
|
3 |
project(qsampler |
4 |
VERSION 0.9.3 |
5 |
DESCRIPTION "A LinuxSampler Qt GUI Interface" |
6 |
LANGUAGES C CXX) |
7 |
|
8 |
set (CONFIG_VERSION ${PROJECT_VERSION}) |
9 |
execute_process ( |
10 |
COMMAND git describe --tags --dirty --abbrev=6 |
11 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
12 |
OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT |
13 |
RESULT_VARIABLE GIT_DESCRIBE_RESULT |
14 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
15 |
if (GIT_DESCRIBE_RESULT EQUAL 0) |
16 |
set (VERSION "${GIT_DESCRIBE_OUTPUT}") |
17 |
string (REGEX REPLACE "^[^0-9]+" "" VERSION "${VERSION}") |
18 |
string (REGEX REPLACE "-g" "git." VERSION "${VERSION}") |
19 |
string (REGEX REPLACE "[_|-]+" "." VERSION "${VERSION}") |
20 |
execute_process ( |
21 |
COMMAND git rev-parse --abbrev-ref HEAD |
22 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
23 |
OUTPUT_VARIABLE GIT_REVPARSE_OUTPUT |
24 |
RESULT_VARIABLE GIT_REVPARSE_RESULT |
25 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
26 |
if (GIT_REVPARSE_RESULT EQUAL 0 AND NOT GIT_REVPARSE_OUTPUT STREQUAL "master") |
27 |
set (VERSION "${VERSION} [${GIT_REVPARSE_OUTPUT}]") |
28 |
endif () |
29 |
else () |
30 |
set (VERSION "${PROJECT_VERSION}") |
31 |
endif () |
32 |
|
33 |
set (PACKAGE_NAME "Qsampler") |
34 |
set (PACKAGE_VERSION "${VERSION}") |
35 |
set (PACKAGE_BUGREPORT "rncbc@rncbc.org") |
36 |
set (PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") |
37 |
set (PACKAGE_TARNAME "qsampler") |
38 |
|
39 |
set (ac_version "${PROJECT_VERSION}") |
40 |
set (ac_prefix "${CMAKE_INSTALL_PREFIX}") |
41 |
|
42 |
set (CONFIG_BUILD_VERSION "${PACKAGE_VERSION}") |
43 |
|
44 |
if (CMAKE_BUILD_TYPE) |
45 |
set (CONFIG_BUILD_TYPE ${CMAKE_BUILD_TYPE}) |
46 |
else () |
47 |
set (CONFIG_BUILD_TYPE "release") |
48 |
endif () |
49 |
|
50 |
set (CONFIG_DEBUG 0) |
51 |
if (CONFIG_BUILD_TYPE MATCHES "debug") |
52 |
set (CONFIG_DEBUG 1) |
53 |
endif () |
54 |
|
55 |
set (CONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}") |
56 |
|
57 |
include (GNUInstallDirs) |
58 |
set (CONFIG_BINDIR "${CONFIG_PREFIX}/${CMAKE_INSTALL_BINDIR}") |
59 |
set (CONFIG_LIBDIR "${CONFIG_PREFIX}/${CMAKE_INSTALL_LIBDIR}") |
60 |
set (CONFIG_DATADIR "${CONFIG_PREFIX}/${CMAKE_INSTALL_DATADIR}") |
61 |
set (CONFIG_MANDIR "${CONFIG_PREFIX}/${CMAKE_INSTALL_MANDIR}") |
62 |
|
63 |
|
64 |
# Enable libgig availability. |
65 |
option (CONFIG_LIBGIG "Enable libgig interface (default=yes)" 1) |
66 |
|
67 |
# Enable unique/single instance. |
68 |
option (CONFIG_XUNIQUE "Enable unique/single instance (default=yes)" 1) |
69 |
|
70 |
# Enable debugger stack-trace option (assumes --enable-debug). |
71 |
option (CONFIG_STACKTRACE "Enable debugger stack-trace (default=no)" 0) |
72 |
|
73 |
|
74 |
# Enable Qt6 build preference. |
75 |
option (CONFIG_QT6 "Enable Qt6 build (default=no)" 0) |
76 |
|
77 |
|
78 |
# Fix for new CMAKE_REQUIRED_LIBRARIES policy. |
79 |
if (POLICY CMP0075) |
80 |
cmake_policy (SET CMP0075 NEW) |
81 |
endif () |
82 |
|
83 |
# Check for Qt... |
84 |
if (CONFIG_QT6) |
85 |
find_package (Qt6 QUIET) |
86 |
if (NOT Qt6_FOUND) |
87 |
set (CONFIG_QT6 0) |
88 |
endif () |
89 |
endif () |
90 |
|
91 |
if (CONFIG_QT6) |
92 |
find_package (QT QUIET NAMES Qt6) |
93 |
else () |
94 |
find_package (QT QUIET NAMES Qt5) |
95 |
endif () |
96 |
|
97 |
find_package (Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets) |
98 |
|
99 |
if (CONFIG_XUNIQUE) |
100 |
find_package (Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Network) |
101 |
endif () |
102 |
|
103 |
find_package (Qt${QT_VERSION_MAJOR}LinguistTools) |
104 |
|
105 |
include (CheckIncludeFile) |
106 |
include (CheckIncludeFiles) |
107 |
include (CheckIncludeFileCXX) |
108 |
include (CheckFunctionExists) |
109 |
include (CheckLibraryExists) |
110 |
|
111 |
# Checks for libraries. |
112 |
if (WIN32) |
113 |
check_function_exists (lroundf CONFIG_ROUND) |
114 |
else () |
115 |
find_library (MATH_LIBRARY m) |
116 |
# Check for round math function. |
117 |
if (MATH_LIBRARY) |
118 |
set (CMAKE_REQUIRED_LIBRARIES "${MATH_LIBRARY};${CMAKE_REQUIRED_LIBRARIES}") |
119 |
check_function_exists (lroundf CONFIG_ROUND) |
120 |
else () |
121 |
message (FATAL_ERROR "*** math library not found.") |
122 |
endif () |
123 |
endif () |
124 |
|
125 |
# Checks for header files. |
126 |
if (UNIX AND NOT APPLE) |
127 |
check_include_files ("fcntl.h;unistd.h;signal.h" HAVE_SIGNAL_H) |
128 |
endif () |
129 |
|
130 |
|
131 |
# Find package modules |
132 |
find_package (PkgConfig REQUIRED) |
133 |
|
134 |
# Check for LSCP libraries. |
135 |
pkg_check_modules (LSCP REQUIRED IMPORTED_TARGET lscp) |
136 |
if (LSCP_FOUND) |
137 |
set (CONFIG_LIBLSCP 1) |
138 |
include_directories (${LSCP_INCLUDE_DIRS}) |
139 |
link_directories (${LSCP_LIBRARY_DIRS}) |
140 |
# link_libraries (${LSCP_LIBRARIES}) |
141 |
set (CMAKE_REQUIRED_LIBRARIES "${LSCP_LIBRARIES};${CMAKE_REQUIRED_LIBRARIES}") |
142 |
# Check for for instrument_name in lscp_channel_info_t. |
143 |
check_include_file (lscp/client.h HAVE_LSCP_CLIENT_H) |
144 |
if (NOT HAVE_LSCP_CLIENT_H) |
145 |
set (CONFIG_INSTRUMENT_NAME 0) |
146 |
else () |
147 |
set (CONFIG_INSTRUMENT_NAME 1) |
148 |
endif () |
149 |
# Check for mute/solo in lscp_channel_info_t. |
150 |
if (NOT HAVE_LSCP_CLIENT_H) |
151 |
set (CONFIG_MUTE_SOLO 0) |
152 |
else () |
153 |
set (CONFIG_MUTE_SOLO 1) |
154 |
endif () |
155 |
if (CONFIG_MUTE_SOLO) |
156 |
check_function_exists (lscp_set_channel_mute CONFIG_MUTE_SOLO) |
157 |
endif () |
158 |
if (CONFIG_MUTE_SOLO) |
159 |
check_function_exists (lscp_set_channel_solo CONFIG_MUTE_SOLO) |
160 |
endif () |
161 |
# Check if MIDI instrument mapping is available. |
162 |
check_function_exists (lscp_map_midi_instrument CONFIG_MIDI_INSTRUMENT) |
163 |
# Check if FX sends is available. |
164 |
check_function_exists (lscp_create_fxsend CONFIG_FXSEND) |
165 |
# Check for FX send level in lscp_fxsend_info_t |
166 |
if (CONFIG_FXSEND) |
167 |
if (NOT HAVE_LSCP_CLIENT_H) |
168 |
set (CONFIG_FXSEND_LEVEL 0) |
169 |
else () |
170 |
set (CONFIG_FXSEND_LEVEL 1) |
171 |
endif () |
172 |
endif () |
173 |
# Check if FX send rename is available. |
174 |
if (CONFIG_FXSEND) |
175 |
check_function_exists (lscp_set_fxsend_name CONFIG_FXSEND_RENAME) |
176 |
endif () |
177 |
# Check for audio_routing array type |
178 |
if (NOT HAVE_LSCP_CLIENT_H) |
179 |
set (CONFIG_AUDIO_ROUTING 0) |
180 |
else () |
181 |
set (CONFIG_AUDIO_ROUTING 1) |
182 |
endif () |
183 |
# Check if global volume is available. |
184 |
check_function_exists (lscp_set_volume CONFIG_VOLUME) |
185 |
# Check if instrument editing is available. |
186 |
check_function_exists (lscp_edit_channel_instrument CONFIG_EDIT_INSTRUMENT) |
187 |
# Check for CHANNEL_MIDI LSCP event support in liblscp], |
188 |
check_include_file (lscp/event.h HAVE_LSCP_EVENT_H) |
189 |
if (NOT HAVE_LSCP_EVENT_H) |
190 |
set (CONFIG_EVENT_CHANNEL_MIDI 0) |
191 |
else () |
192 |
set (CONFIG_EVENT_CHANNEL_MIDI 1) |
193 |
endif () |
194 |
# Check for DEVICE_MIDI LSCP event support in liblscp], |
195 |
if (NOT HAVE_LSCP_EVENT_H) |
196 |
set (CONFIG_EVENT_DEVICE_MIDI 0) |
197 |
else () |
198 |
set (CONFIG_EVENT_DEVICE_MIDI 1) |
199 |
endif () |
200 |
# Check if max. voices / streams is available. |
201 |
check_function_exists (lscp_get_voices CONFIG_MAX_VOICES) |
202 |
else () |
203 |
message (FATAL_ERROR "*** LSCP library not found.") |
204 |
set (CONFIG_LIBLSCP 0) |
205 |
endif () |
206 |
|
207 |
# Check for GIG libraries. |
208 |
if (CONFIG_LIBGIG) |
209 |
pkg_check_modules (GIG IMPORTED_TARGET gig>=3.3.0) |
210 |
if (GIG_FOUND) |
211 |
include_directories (${GIG_INCLUDE_DIRS}) |
212 |
link_directories (${GIG_LIBRARY_DIRS}) |
213 |
link_libraries (${GIG_LIBRARIES}) |
214 |
# set (CMAKE_REQUIRED_LIBRARIES "${GIG_LIBRARIES};${CMAKE_REQUIRED_LIBRARIES}") |
215 |
# liggig supports fast information retrieval. |
216 |
set (CONFIG_LIBGIG_SETAUTOLOAD 1) |
217 |
# Check if libgig/SF.h is available. |
218 |
check_include_file_cxx (libgig/SF.h HAVE_LIBGIG_SF_H) |
219 |
if (NOT HAVE_LIBGIG_SF_H) |
220 |
set (CONFIG_LIBGIG_SF2 0) |
221 |
else () |
222 |
set (CONFIG_LIBGIG_SF2 1) |
223 |
endif () |
224 |
else () |
225 |
message (WARNING "*** GIG library not found.") |
226 |
set (CONFIG_LIBGIG 0) |
227 |
endif () |
228 |
endif () |
229 |
|
230 |
|
231 |
add_subdirectory (src) |
232 |
|
233 |
configure_file (qsampler.spec.in qsampler.spec IMMEDIATE @ONLY) |
234 |
|
235 |
install (FILES qsampler.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) |
236 |
install (FILES qsampler.fr.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/fr/man1 RENAME qsampler.1) |
237 |
|
238 |
# Configuration status |
239 |
macro (SHOW_OPTION text value) |
240 |
if (${value}) |
241 |
message ("${text}: yes") |
242 |
else () |
243 |
message ("${text}: no") |
244 |
endif () |
245 |
endmacro () |
246 |
|
247 |
|
248 |
message ("\n ${PACKAGE_NAME} ${PACKAGE_VERSION} (Qt ${QT_VERSION})") |
249 |
message ("\n Build target . . . . . . . . . . . . . . . . . . .: ${CONFIG_BUILD_TYPE}\n") |
250 |
show_option (" LSCP instrument name support . . . . . . . . . . ." CONFIG_INSTRUMENT_NAME) |
251 |
show_option (" LSCP mute/solo support . . . . . . . . . . . . . ." CONFIG_MUTE_SOLO) |
252 |
show_option (" LSCP MIDI instrument support . . . . . . . . . . ." CONFIG_MIDI_INSTRUMENT) |
253 |
show_option (" LSCP FX send support . . . . . . . . . . . . . . ." CONFIG_FXSEND) |
254 |
show_option (" LSCP FX send level support . . . . . . . . . . . ." CONFIG_FXSEND_LEVEL) |
255 |
show_option (" LSCP FX send rename support . . . . . . . . . . ." CONFIG_FXSEND_RENAME) |
256 |
show_option (" LSCP audio routing support . . . . . . . . . . . ." CONFIG_AUDIO_ROUTING) |
257 |
show_option (" LSCP volume support . . . . . . . . . . . . . . ." CONFIG_VOLUME) |
258 |
show_option (" LSCP edit instrument support . . . . . . . . . . ." CONFIG_EDIT_INSTRUMENT) |
259 |
show_option (" GigaSampler instrument file support (libgig) . . ." CONFIG_LIBGIG) |
260 |
if (CONFIG_LIBGIG) |
261 |
show_option (" libgig supports fast information retrieval . . . ." CONFIG_LIBGIG_SETAUTOLOAD) |
262 |
show_option (" libgig supports SoundFont2 instruments files . . ." CONFIG_LIBGIG_SF2) |
263 |
endif () |
264 |
show_option (" LSCP channel MIDI event support . . . . . . . . ." CONFIG_EVENT_CHANNEL_MIDI) |
265 |
show_option (" LSCP device MIDI event support . . . . . . . . . ." CONFIG_EVENT_DEVICE_MIDI) |
266 |
show_option (" LSCP runtime max. voices / disk streams support ." CONFIG_MAX_VOICES) |
267 |
message ("") |
268 |
show_option (" Unique/Single instance support . . . . . . . . . ." CONFIG_XUNIQUE) |
269 |
show_option (" Debugger stack-trace (gdb) . . . . . . . . . . . ." CONFIG_STACKTRACE) |
270 |
message ("\n Install prefix . . . . . . . . . . . . . . . . . .: ${CMAKE_INSTALL_PREFIX}") |
271 |
message ("\nNow type 'make', followed by 'make install' as root.\n") |