forked from clangen/musikcube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
350 lines (303 loc) · 13.5 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
#cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr .
#cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr .
#cmake -DGENERATE_DEB=1 -DDEB_ARCHITECTURE=i386|amd64|armhf -DDEB_PLATFORM=ubuntu -DDEB_DISTRO=eoan -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release .
#cmake -DCMAKE_BUILD_TYPE=Release -DLINK_STATICALLY=true .
cmake_minimum_required(VERSION 3.0)
project(musikcube)
set (musikcube_VERSION_MAJOR 0)
set (musikcube_VERSION_MINOR 96)
set (musikcube_VERSION_PATCH 5)
set (musikcube_VERSION "${musikcube_VERSION_MAJOR}.${musikcube_VERSION_MINOR}.${musikcube_VERSION_PATCH}")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake)
include(CMakeToolsHelpers OPTIONAL)
include(CheckDependencies)
include(CheckAtomic)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wno-unused-result -Wno-deprecated-declarations")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g -frtti -fexceptions")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
# enable for additional memory checking with fsanitize
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -fsanitize=address,undefined")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -frtti -fexceptions")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
# our include directories
include_directories (
"${musikcube_SOURCE_DIR}/src"
"${musikcube_SOURCE_DIR}/src/musikcore"
"${musikcube_SOURCE_DIR}/src/musikcube"
"${musikcube_SOURCE_DIR}/src/musikcube/cursespp"
"${musikcube_SOURCE_DIR}/src/3rdparty/include")
# our library directories
link_directories ("${musikcube_SOURCE_DIR}/bin/plugins")
# custom include/library directories for BSDs
if (CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
link_directories ("/usr/local/lib")
link_directories ("/usr/local/opt/openssl/lib")
link_directories ("/usr/local/opt/ncurses/lib")
include_directories("/usr/local/include")
include_directories("/usr/local/opt/openssl/include")
include_directories("/usr/local/opt/ncurses/include")
endif ()
if (${LINK_STATICALLY} MATCHES "true")
set(Boost_USE_STATIC_LIBS ON)
endif()
set (BOOST_LIBS system filesystem thread)
find_package(Boost 1.55.0 REQUIRED ${BOOST_LIBS})
add_definitions (-DHAVE_BOOST -D_FILE_OFFSET_BITS=64 -DSIGSLOT_USE_POSIX_THREADS)
set (BOOST_LINK_LIBS ${Boost_LIBRARIES})
#message(STATUS "boost libs: " ${BOOST_LINK_LIBS})
#message(STATUS "boost includes: " ${Boost_INCLUDE_DIRS})
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Modules)
# SET (CMAKE_BUILD_TYPE DEBUG)
set (LIBRARY_OUTPUT_PATH ${musikcube_SOURCE_DIR}/bin/plugins)
set (EXECUTABLE_OUTPUT_PATH ${musikcube_SOURCE_DIR}/bin)
ensure_library_exists(curl)
ensure_library_exists(pthread)
ensure_library_exists(ssl)
ensure_library_exists(crypto)
ensure_library_exists(z)
set(COMMON_LINK_LIBS ${BOOST_LINK_LIBS} curl pthread ssl crypto)
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
set (musikcube_LINK_LIBS ${COMMON_LINK_LIBS})
else()
set (musikcube_LINK_LIBS ${COMMON_LINK_LIBS} dl)
endif()
if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
message(STATUS "[build] libatomic required, adding to library list")
set (musikcube_LINK_LIBS ${musikcube_LINK_LIBS} atomic)
endif()
endif()
# we default to using a bundled version of taglib because the latest release
# is from 2016, and the upstream git repo is hundreds of commits ahead and
# has a number of important bugfixes.
if (NOT DEFINED ENABLE_BUNDLED_TAGLIB)
message(STATUS "[build] ENABLE_BUNDLED_TAGLIB not defined, setting to 'true'")
set(ENABLE_BUNDLED_TAGLIB "true")
else()
message(STATUS "[build] ENABLE_BUNDLED_TAGLIB specified as '${ENABLE_BUNDLED_TAGLIB}'")
endif()
message(STATUS "[build] link libraries are: ${musikcube_LINK_LIBS}")
# ensure the binaries can find libmusikcore.so, which lives in the
# same directory.
if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CMAKE_INSTALL_RPATH "$ORIGIN")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
endif()
if (EXISTS "/etc/arch-release" OR EXISTS "/etc/manjaro-release" OR NO_NCURSESW)
add_definitions (-DNO_NCURSESW)
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD" )
add_definitions (-DNO_NCURSESW)
endif()
add_subdirectory(src/musikcore)
add_subdirectory(src/core_c_demo)
add_subdirectory(src/musikcube)
add_subdirectory(src/musikcubed)
add_subdirectory(src/plugins/taglib_plugin)
add_subdirectory(src/plugins/nullout)
add_subdirectory(src/plugins/server)
add_subdirectory(src/plugins/httpdatastream)
add_subdirectory(src/plugins/stockencoders)
add_subdirectory(src/plugins/supereqdsp)
add_subdirectory(src/plugins/gmedecoder)
find_library(LIBOPENMPT NAMES openmpt)
if ("${LIBOPENMPT}" STREQUAL "LIBOPENMPT-NOTFOUND")
message(STATUS "[libopenmpt] *not* found! plugin will not be built.")
else()
message(STATUS "[libopenmpt] enabled = true; found library at ${LIBOPENMPT}")
add_subdirectory(src/plugins/libopenmptdecoder)
endif()
if (${ENABLE_FFMPEG} MATCHES "false")
message(STATUS "[ffmpeg] enabled = false")
add_subdirectory(src/plugins/m4adecoder)
add_subdirectory(src/plugins/oggdecoder)
add_subdirectory(src/plugins/nomaddecoder)
add_subdirectory(src/plugins/flacdecoder)
add_dependencies(musikcube m4adecoder oggdecoder nomaddecoder flacdecoder)
else()
message(STATUS "[ffmpeg] enabled = true")
add_subdirectory(src/plugins/ffmpegdecoder)
add_dependencies(musikcube ffmpegdecoder)
endif()
# systemd / MPRIS detection
if (NOT ENABLE_MPRIS MATCHES "false")
find_library(LIB_SYSTEMD NAMES systemd)
if (NOT LIB_SYSTEMD MATCHES "LIB_SYSTEMD-NOTFOUND")
message(STATUS "[mpris] systemd found at " ${LIB_SYSTEMD})
message(STATUS "[mpris] setting ENABLE_MPRIS=true")
set(ENABLE_MPRIS "true")
else()
message(STATUS "[mpris] systemd *not* found. MPRIS plugin not enabled")
set(ENABLE_MPRIS "false")
endif()
endif()
#end systemd / MPRIS detection
add_dependencies(musikcube musikcore taglibreader nullout server httpdatastream stockencoders)
add_dependencies(musikcubed musikcube)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_subdirectory(src/plugins/alsaout)
add_subdirectory(src/plugins/pulseout)
if (${ENABLE_PIPEWIRE} MATCHES "true")
add_subdirectory(src/plugins/pipewireout)
add_dependencies(musikcube pipewireout)
endif()
if (${ENABLE_MPRIS} MATCHES "true")
add_subdirectory(src/plugins/mpris)
add_dependencies(musikcube mpris)
endif()
if (${ENABLE_SNDIO} MATCHES "true")
add_subdirectory(src/plugins/sndioout)
add_dependencies(musikcube sndioout)
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
add_subdirectory(src/plugins/sndioout)
add_dependencies(musikcube sndioout)
if (${ENABLE_PULSEAUDIO} MATCHES "true")
add_subdirectory(src/plugins/pulseout) # disabled by default
add_dependencies(musikcube pulseout)
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_subdirectory(src/plugins/sndioout)
add_dependencies(musikcube sndioout)
if (${ENABLE_PULSEAUDIO} MATCHES "true")
add_subdirectory(src/plugins/pulseout) # disabled by default
add_dependencies(musikcube pulseout)
endif()
if (${ENABLE_ALSA} MATCHES "true")
add_subdirectory(src/plugins/alsaout) # disabled by default
add_dependencies(musikcube alsaout)
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_subdirectory(src/plugins/coreaudioout)
add_dependencies(musikcube coreaudioout)
add_subdirectory(src/plugins/macosmediakeys)
add_dependencies(musikcube macosmediakeys)
endif()
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
file(GLOB plugins "bin/plugins/*.dylib")
install(FILES ${plugins} DESTINATION share/musikcube/plugins)
else ()
file(GLOB plugins "bin/plugins/*.so")
install(FILES ${plugins} DESTINATION share/musikcube/plugins)
endif ()
file(GLOB sdk_headers "src/musikcore/sdk/*.h")
install(FILES ${sdk_headers} DESTINATION include/musikcube/musikcore/sdk)
file(GLOB themes "src/musikcube/data/themes/*.json")
file(COPY ${themes} DESTINATION bin/themes)
install(FILES ${themes} DESTINATION share/musikcube/themes)
file(GLOB locales "src/musikcube/data/locales/*.json")
file(COPY ${locales} DESTINATION bin/locales)
install(FILES ${locales} DESTINATION share/musikcube/locales)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
file(GLOB linux_share_applications "src/musikcube/data/linux/share/applications/musikcube.desktop")
install(FILES ${linux_share_applications} DESTINATION share/applications/)
file(GLOB linux_share_icons_48 "src/musikcube/data/linux/share/icons/hicolor/48x48/apps/*")
install(FILES ${linux_share_icons_48} DESTINATION share/icons/hicolor/48x48/apps/)
file(GLOB linux_share_icons_64 "src/musikcube/data/linux/share/icons/hicolor/64x64/apps/*")
install(FILES ${linux_share_icons_64} DESTINATION share/icons/hicolor/64x64/apps/)
file(GLOB linux_share_icons_128 "src/musikcube/data/linux/share/icons/hicolor/128x128/apps/*")
install(FILES ${linux_share_icons_128} DESTINATION share/icons/hicolor/128x128/apps/)
endif()
# libmusikcore sshared library
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
install(FILES "bin/libmusikcore.dylib" DESTINATION share/musikcube)
else()
install(FILES "bin/libmusikcore.so" DESTINATION share/musikcube)
endif()
# executable and shell script for musikcube
install(
FILES bin/musikcube
DESTINATION share/musikcube
PERMISSIONS
OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ GROUP_WRITE
WORLD_EXECUTE WORLD_READ)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/src/musikcube/musikcube"
DESTINATION bin/
PERMISSIONS
OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ GROUP_WRITE
WORLD_EXECUTE WORLD_READ)
# executable and shell script for daemon
install(
FILES bin/musikcubed
DESTINATION share/musikcube
PERMISSIONS
OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ GROUP_WRITE
WORLD_EXECUTE WORLD_READ)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/src/musikcubed/musikcubed"
DESTINATION bin/
PERMISSIONS
OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ GROUP_WRITE
WORLD_EXECUTE WORLD_READ)
# deb generation
if (GENERATE_DEB MATCHES "1")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
set(DEB_BOOST_VERSION "1.55.0")
set(DEB_MICROHTTPD_VERSION "10")
set(DEB_LIBCURL_VERSION "3")
set(DEB_AVUTIL_VERSION "55")
set(DEB_AVFORMAT_VERSION "57")
set(DEB_SWRESAMPLE_VERSION "2")
set(DEB_NCURSES_VERSION "5")
if (DEB_DISTRO MATCHES "artful")
set(DEB_BOOST_VERSION "1.63.0")
set(DEB_MICROHTTPD_VERSION "12")
elseif (DEB_DISTRO MATCHES "bionic")
set(DEB_BOOST_VERSION "1.65.1")
set(DEB_MICROHTTPD_VERSION "12")
set(DEB_LIBCURL_VERSION "4")
elseif (DEB_DISTRO MATCHES "cosmic" OR DEB_DISTRO MATCHES "disco" OR DEB_DISTRO MATCHES "eoan" OR DEB_DISTRO MATCHES "buster")
set(DEB_BOOST_VERSION "1.67.0")
set(DEB_MICROHTTPD_VERSION "12")
set(DEB_LIBCURL_VERSION "4")
set(DEB_AVUTIL_VERSION "56")
set(DEB_AVFORMAT_VERSION "58")
set(DEB_SWRESAMPLE_VERSION "3")
elseif (DEB_DISTRO MATCHES "focal" OR DEB_DISTRO MATCHES "groovy")
set(DEB_BOOST_VERSION "1.71.0")
set(DEB_MICROHTTPD_VERSION "12")
set(DEB_LIBCURL_VERSION "4")
set(DEB_AVUTIL_VERSION "56")
set(DEB_AVFORMAT_VERSION "58")
set(DEB_SWRESAMPLE_VERSION "3")
set(DEB_NCURSES_VERSION "6")
endif()
set(DEPENDENCIES "libboost-thread${DEB_BOOST_VERSION}, libboost-system${DEB_BOOST_VERSION}, libboost-chrono${DEB_BOOST_VERSION}, libboost-filesystem${DEB_BOOST_VERSION}, libboost-date-time${DEB_BOOST_VERSION}, libmicrohttpd${DEB_MICROHTTPD_VERSION}, libcurl${DEB_LIBCURL_VERSION}, libogg0, libvorbis0a, libvorbisfile3, libncursesw${DEB_NCURSES_VERSION}, libasound2, libpulse0, pulseaudio, libmp3lame0, libev4, libopenmpt0, libssl1.1")
if (${ENABLE_FFMPEG} MATCHES "false")
set(DEPENDENCIES "${DEPENDENCIES}, libflac8, libfaad2")
else()
set(DEPENDENCIES "${DEPENDENCIES}, libavcodec-extra, libavutil${DEB_AVUTIL_VERSION}, libavformat${DEB_AVFORMAT_VERSION}, libswresample${DEB_SWRESAMPLE_VERSION}")
endif()
if (${ENABLE_BUNDLED_TAGLIB} MATCHES "false")
set(DEPENDENCIES "${DEPENDENCIES}, libtag1v5")
endif()
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_DESCRIPTION "musikcube, a terminal-based music player and library")
set(CPACK_PACKAGE_VERSION_MAJOR "${musikcube_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${musikcube_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${musikcube_VERSION_PATCH}")
set(CPACK_DEBIAN_PACKAGE_DEPENDS ${DEPENDENCIES})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "casey langen")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DEB_ARCHITECTURE})
set(CPACK_PACKAGE_FILE_NAME "musikcube_${musikcube_VERSION}_${DEB_PLATFORM}_${DEB_DISTRO}_${DEB_ARCHITECTURE}")
include(CPack)
endif()
endif()
# run `cmake .` again to pick up build plugin build artifacts that we need
# to file glob in. these won't be picked up on the initial build because
# they don't yet exist!
add_custom_target(postbuild ALL DEPENDS musikcube musikcubed)
add_custom_command(TARGET postbuild POST_BUILD COMMAND cmake .)
# strip binaries in release mode
if (CMAKE_BUILD_TYPE MATCHES Release)
if ((NOT DEFINED DISABLE_STRIP) OR (NOT ${DISABLE_STRIP} MATCHES "true"))
message(STATUS "[build] binary stripping enabled for ${CMAKE_CURRENT_SOURCE_DIR}")
add_custom_command(TARGET postbuild POST_BUILD COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/script/strip-nix.sh" ${CMAKE_CURRENT_SOURCE_DIR})
else()
message(STATUS "[build] DISABLE_STRIP=true, *NOT* stripping binaries.")
endif()
endif()