File: CMakeLists.txt

package info (click to toggle)
libgroove 4.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 616 kB
  • sloc: ansic: 4,192; makefile: 2
file content (333 lines) | stat: -rw-r--r-- 11,273 bytes parent folder | download | duplicates (2)
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
cmake_minimum_required(VERSION 2.8)

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
      "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()

project(groove C)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
include(GNUInstallDirs)

set(LIBGROOVE_STATUS "yes")
set(LIBGROOVE_VERSION_MAJOR 4)
set(LIBGROOVE_VERSION_MINOR 3)
set(LIBGROOVE_VERSION_PATCH 0)
set(LIBGROOVE_VERSION "${LIBGROOVE_VERSION_MAJOR}.${LIBGROOVE_VERSION_MINOR}.${LIBGROOVE_VERSION_PATCH}")
message("Configuring libgroove version ${LIBGROOVE_VERSION}")
file(GLOB_RECURSE LIBGROOVE_SOURCES ${CMAKE_SOURCE_DIR}/groove/*.c)
file(GLOB_RECURSE LIBGROOVE_HEADERS ${CMAKE_SOURCE_DIR}/groove/*.h)

if(DISABLE_PLAYER)
  set(LIBGROOVE_PLAYER_STATUS "no")
else(DISABLE_PLAYER)
  set(LIBGROOVE_PLAYER_STATUS "yes")
  message("Configuring libgrooveplayer version ${LIBGROOVE_VERSION}")
  set(LIBGROOVE_PLAYER_SOURCES ${CMAKE_SOURCE_DIR}/grooveplayer/player.c)
  file(GLOB_RECURSE LIBGROOVE_PLAYER_HEADERS ${CMAKE_SOURCE_DIR}/grooveplayer/*.h)
  if(APPLE)
    set(LIBGROOVE_PLAYER_SOURCES ${LIBGROOVE_PLAYER_SOURCES}
      ${CMAKE_SOURCE_DIR}/grooveplayer/osx_time_shim.c)
  endif(APPLE)
endif(DISABLE_PLAYER)

if(DISABLE_LOUDNESS)
  set(LIBGROOVE_LOUDNESS_STATUS "no")
else(DISABLE_LOUDNESS)
  set(LIBGROOVE_LOUDNESS_STATUS "yes")
  message("Configuring libgrooveloudness version ${LIBGROOVE_VERSION}")
  file(GLOB_RECURSE LIBGROOVE_LOUDNESS_SOURCES ${CMAKE_SOURCE_DIR}/grooveloudness/*.c)
  file(GLOB_RECURSE LIBGROOVE_LOUDNESS_HEADERS ${CMAKE_SOURCE_DIR}/grooveloudness/*.h)
endif(DISABLE_LOUDNESS)

if(DISABLE_FINGERPRINTER)
  set(LIBGROOVE_FINGERPRINTER_STATUS "no")
else(DISABLE_FINGERPRINTER)
  set(LIBGROOVE_FINGERPRINTER_STATUS "yes")
  message("Configuring libgroovefingerprinter version ${LIBGROOVE_VERSION}")
  file(GLOB_RECURSE LIBGROOVE_FINGERPRINTER_SOURCES ${CMAKE_SOURCE_DIR}/groovefingerprinter/*.c)
  file(GLOB_RECURSE LIBGROOVE_FINGERPRINTER_HEADERS ${CMAKE_SOURCE_DIR}/groovefingerprinter/*.h)
endif(DISABLE_FINGERPRINTER)

# check for C99
find_package(C99)
if(C99_FLAG_DETECTED)
  set(HAVE_C99 TRUE)
  set(STATUS_C99 "OK")
else(C99_FLAG_DETECTED)
  set(STATUS_C99 "not found")
  set(LIBGROOVE_STATUS "missing dependencies")
  set(LIBGROOVE_PLAYER_STATUS "missing dependencies")
  set(LIBGROOVE_LOUDNESS_STATUS "missing dependencies")
endif(C99_FLAG_DETECTED)

# check for ebur128
if(DISABLE_LOUDNESS)
  set(STATUS_EBUR128 "not needed")
else(DISABLE_LOUDNESS)
  find_package(ebur128)
  if(EBUR128_FOUND)
    set(STATUS_EBUR128 "OK")
  else(EBUR128_FOUND)
    set(STATUS_EBUR128 "not found")
  endif(EBUR128_FOUND)
endif(DISABLE_LOUDNESS)

# check for chromaprint
if(DISABLE_FINGERPRINTER)
  set(STATUS_CHROMAPRINT "not needed")
else(DISABLE_FINGERPRINTER)
  find_package(Chromaprint)
  if(CHROMAPRINT_FOUND)
    set(STATUS_CHROMAPRINT "OK")
  else(CHROMAPRINT_FOUND)
    set(STATUS_CHROMAPRINT "not found")
  endif(CHROMAPRINT_FOUND)
endif(DISABLE_FINGERPRINTER)

# check for SDL2
if(DISABLE_PLAYER)
  set(STATUS_SDL2 "not needed")
else(DISABLE_PLAYER)
  find_package(SDL2)
  if(SDL2_FOUND)
    set(STATUS_SDL2 "OK")
  else(SDL2_FOUND)
    set(STATUS_SDL2 "not found")
  endif(SDL2_FOUND)
endif(DISABLE_PLAYER)

# check for libav
find_package(LibAV)
if(AVCODEC_FOUND)
  set(STATUS_LIBAVCODEC "OK")
else()
  set(STATUS_LIBAVCODEC "not found")
endif()
if(AVFILTER_FOUND)
  set(STATUS_LIBAVFILTER "OK")
else()
  set(STATUS_LIBAVFILTER "not found")
endif()
if(AVFORMAT_FOUND)
  set(STATUS_LIBAVFORMAT "OK")
else()
  set(STATUS_LIBAVFORMAT "not found")
endif()
if(AVUTIL_FOUND)
  set(STATUS_LIBAVUTIL "OK")
else()
  set(STATUS_LIBAVUTIL "not found")
endif()

# check for pthreads
find_package(Threads)
if(Threads_FOUND)
  set(STATUS_THREADS "OK")
else(Threads_FOUND)
  set(STATUS_THREADS "not found")
  set(LIBGROOVE_STATUS "missing dependencies")
  set(LIBGROOVE_PLAYER_STATUS "missing dependencies")
  set(LIBGROOVE_LOUDNESS_STATUS "missing dependencies")
endif(Threads_FOUND)

configure_file (
  "${PROJECT_SOURCE_DIR}/groove/config.h.in"
  "${PROJECT_BINARY_DIR}/config.h"
  )

set(LIB_CFLAGS "${C99_C_FLAGS} -pedantic -Wall -Werror=strict-prototypes -Werror=old-style-definition -Werror=missing-prototypes -D_REENTRANT -D_POSIX_C_SOURCE=200809L")
set(EXAMPLE_CFLAGS "${C99_C_FLAGS} -pedantic -Wall -g")
set(EXAMPLE_INCLUDES "${PROJECT_SOURCE_DIR}")

add_library(groove SHARED ${LIBGROOVE_SOURCES} ${LIBGROOVE_HEADERS})
set_target_properties(groove PROPERTIES
  SOVERSION ${LIBGROOVE_VERSION_MAJOR}
  VERSION ${LIBGROOVE_VERSION}
  COMPILE_FLAGS ${LIB_CFLAGS}
  )
if(LIBGROOVE_LDFLAGS)
  set_target_properties(groove PROPERTIES LINK_FLAGS ${LIBGROOVE_LDFLAGS})
endif()
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_BINARY_DIR})
target_link_libraries(groove LINK_PRIVATE
  ${AVCODEC_LIBRARIES}
  ${AVFILTER_LIBRARIES}
  ${AVFORMAT_LIBRARIES})
target_link_libraries(groove LINK_PUBLIC ${AVUTIL_LIBRARIES})
if(UNIX)
  target_link_libraries(groove LINK_PRIVATE m)
endif(UNIX)
include_directories(${LIBAV_INCLUDE_DIRS})
target_link_libraries(groove LINK_PUBLIC ${CMAKE_THREAD_LIBS_INIT})


add_library(groove_static STATIC ${LIBGROOVE_SOURCES} ${LIBGROOVE_HEADERS})
set_target_properties(groove_static PROPERTIES
  OUTPUT_NAME groove
  COMPILE_FLAGS "${LIB_CFLAGS} -fPIC")
install(TARGETS groove_static DESTINATION ${CMAKE_INSTALL_LIBDIR})


install(FILES
  "groove/groove.h"
  "groove/queue.h"
  "groove/encoder.h"
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/groove")
install(TARGETS groove DESTINATION ${CMAKE_INSTALL_LIBDIR})

add_executable(metadata example/metadata.c)
set_target_properties(metadata PROPERTIES
  COMPILE_FLAGS ${EXAMPLE_CFLAGS})
include_directories(${EXAMPLE_INCLUDES})
target_link_libraries(metadata groove)
add_dependencies(metadata groove)


add_executable(transcode example/transcode.c)
set_target_properties(transcode PROPERTIES
  COMPILE_FLAGS ${EXAMPLE_CFLAGS})
include_directories(${EXAMPLE_INCLUDES})
target_link_libraries(transcode groove)
add_dependencies(transcode groove)


if(DISABLE_PLAYER)
else()
  add_library(grooveplayer SHARED
    ${LIBGROOVE_PLAYER_SOURCES}
    ${LIBGROOVE_PLAYER_HEADERS})
  set_target_properties(grooveplayer PROPERTIES
    SOVERSION ${LIBGROOVE_VERSION_MAJOR}
    VERSION ${LIBGROOVE_VERSION}
    COMPILE_FLAGS ${LIB_CFLAGS}
    )
  target_link_libraries(grooveplayer LINK_PUBLIC groove)
  if(UNIX AND NOT APPLE)
    target_link_libraries(grooveplayer LINK_PRIVATE rt)
  endif()
  add_dependencies(grooveplayer groove)
  target_link_libraries(grooveplayer LINK_PRIVATE ${SDL2_LIBRARY})
  include_directories(${SDL2_INCLUDE_DIR})

  install(FILES "grooveplayer/player.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/grooveplayer")
  install(TARGETS grooveplayer DESTINATION ${CMAKE_INSTALL_LIBDIR})

  add_library(grooveplayer_static STATIC
    ${LIBGROOVE_PLAYER_SOURCES}
    ${LIBGROOVE_PLAYER_HEADERS})
  set_target_properties(grooveplayer_static PROPERTIES
    OUTPUT_NAME grooveplayer
    COMPILE_FLAGS "${LIB_CFLAGS} -fPIC")
  install(TARGETS grooveplayer_static DESTINATION ${CMAKE_INSTALL_LIBDIR})


  add_executable(playlist example/playlist.c ${PROJECT_SOURCE_DIR}/grooveplayer/player.h)
  set_target_properties(playlist PROPERTIES
    COMPILE_FLAGS ${EXAMPLE_CFLAGS})
  include_directories(${EXAMPLE_INCLUDES})
  target_link_libraries(playlist groove grooveplayer)
  add_dependencies(playlist groove grooveplayer)
endif()

if(DISABLE_LOUDNESS)
else()
  add_library(grooveloudness SHARED
    ${LIBGROOVE_LOUDNESS_SOURCES}
    ${LIBGROOVE_LOUDNESS_HEADERS})
  set_target_properties(grooveloudness PROPERTIES
    SOVERSION ${LIBGROOVE_VERSION_MAJOR}
    VERSION ${LIBGROOVE_VERSION}
    COMPILE_FLAGS ${LIB_CFLAGS}
    )
  target_link_libraries(grooveloudness LINK_PUBLIC groove ${CMAKE_THREAD_LIBS_INIT})
  add_dependencies(grooveloudness groove)
  target_link_libraries(grooveloudness LINK_PRIVATE ${EBUR128_LIBRARY})
  include_directories(${EBUR128_INCLUDE_DIR})

  install(FILES "grooveloudness/loudness.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/grooveloudness")
  install(TARGETS grooveloudness DESTINATION ${CMAKE_INSTALL_LIBDIR})


  add_library(grooveloudness_static STATIC
    ${LIBGROOVE_LOUDNESS_SOURCES}
    ${LIBGROOVE_LOUDNESS_HEADERS})
  set_target_properties(grooveloudness_static PROPERTIES
    OUTPUT_NAME grooveloudness
    COMPILE_FLAGS "${LIB_CFLAGS} -fPIC")
  install(TARGETS grooveloudness_static DESTINATION ${CMAKE_INSTALL_LIBDIR})


  add_executable(replaygain example/replaygain.c)
  set_target_properties(replaygain PROPERTIES
    COMPILE_FLAGS ${EXAMPLE_CFLAGS})
  include_directories(${EXAMPLE_INCLUDES})
  target_link_libraries(replaygain groove grooveloudness)
  add_dependencies(replaygain groove grooveloudness)
endif()

if(DISABLE_FINGERPRINTER)
else()
  add_library(groovefingerprinter SHARED
    ${LIBGROOVE_FINGERPRINTER_SOURCES}
    ${LIBGROOVE_FINGERPRINTER_HEADERS})
  set_target_properties(groovefingerprinter PROPERTIES
    SOVERSION ${LIBGROOVE_VERSION_MAJOR}
    VERSION ${LIBGROOVE_VERSION}
    COMPILE_FLAGS ${LIB_CFLAGS}
    )
  target_link_libraries(groovefingerprinter LINK_PUBLIC groove ${CMAKE_THREAD_LIBS_INIT})
  add_dependencies(groovefingerprinter groove)
  target_link_libraries(groovefingerprinter LINK_PRIVATE ${CHROMAPRINT_LIBRARY})
  include_directories(${CHROMAPRINT_INCLUDE_DIR})

  install(FILES "groovefingerprinter/fingerprinter.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/groovefingerprinter")
  install(TARGETS groovefingerprinter DESTINATION ${CMAKE_INSTALL_LIBDIR})


  add_library(groovefingerprinter_static STATIC
    ${LIBGROOVE_FINGERPRINTER_SOURCES}
    ${LIBGROOVE_FINGERPRINTER_HEADERS})
  set_target_properties(groovefingerprinter_static PROPERTIES
    OUTPUT_NAME groovefingerprinter
    COMPILE_FLAGS "${LIB_CFLAGS} -fPIC")
  install(TARGETS groovefingerprinter_static DESTINATION ${CMAKE_INSTALL_LIBDIR})


  add_executable(fingerprint example/fingerprint.c)
  set_target_properties(fingerprint PROPERTIES
    COMPILE_FLAGS ${EXAMPLE_CFLAGS})
  include_directories(${EXAMPLE_INCLUDES})
  target_link_libraries(fingerprint groove groovefingerprinter)
  add_dependencies(fingerprint groove groovefingerprinter)
endif()

message("\n"
"Installation Summary\n"
"--------------------\n"
"* Install Directory            : ${CMAKE_INSTALL_PREFIX}\n"
"* Build libgroove              : ${LIBGROOVE_STATUS}\n"
"* Build libgrooveplayer        : ${LIBGROOVE_PLAYER_STATUS}\n"
"* Build libgrooveloudness      : ${LIBGROOVE_LOUDNESS_STATUS}\n"
"* Build libgroovefingerprinter : ${LIBGROOVE_FINGERPRINTER_STATUS}\n"
)

message(
"System Dependencies\n"
"-------------------\n"
"* C99 Compiler                 : ${STATUS_C99}\n"
"* threads                      : ${STATUS_THREADS}\n"
"* SDL2                         : ${STATUS_SDL2}\n"
"* ebur128                      : ${STATUS_EBUR128}\n"
"* chromaprint                  : ${STATUS_CHROMAPRINT}\n"
"* libavformat                  : ${STATUS_LIBAVFORMAT}\n"
"* libavcodec                   : ${STATUS_LIBAVCODEC}\n"
"* libavfilter                  : ${STATUS_LIBAVFILTER}\n"
"* libavutil                    : ${STATUS_LIBAVUTIL}"
)

message("\n"
"If everything is looks good, proceed with\n"
"make\n"
)