forked from andrewrk/libgroove
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
246 lines (213 loc) · 7.64 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
cmake_minimum_required(VERSION 2.8.5)
project(libgroove C)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
if(CMAKE_VERSION VERSION_LESS 3.0.0)
set(CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "library install dir (lib)")
set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "header base install dir (include)")
set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)")
else()
cmake_policy(SET CMP0042 NEW)
cmake_policy(SET CMP0046 NEW)
include(GNUInstallDirs)
endif()
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()
set(LIBGROOVE_VERSION_MAJOR 5)
set(LIBGROOVE_VERSION_MINOR 0)
set(LIBGROOVE_VERSION_PATCH 0)
set(LIBGROOVE_VERSION "${LIBGROOVE_VERSION_MAJOR}.${LIBGROOVE_VERSION_MINOR}.${LIBGROOVE_VERSION_PATCH}")
message("Configuring libgroove version ${LIBGROOVE_VERSION}")
option(BUILD_STATIC_LIBS "Build static libraries" ON)
option(BUILD_EXAMPLE_PROGRAMS "Build example programs" ON)
include_directories(
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
)
find_package(Threads)
if(Threads_FOUND)
set(STATUS_THREADS "OK")
else(Threads_FOUND)
set(STATUS_THREADS "not found")
endif(Threads_FOUND)
find_package(ebur128)
if(EBUR128_FOUND)
set(STATUS_EBUR128 "OK")
include_directories(${EBUR128_INCLUDE_DIR})
else(EBUR128_FOUND)
set(STATUS_EBUR128 "not found")
endif(EBUR128_FOUND)
find_package(Chromaprint)
if(CHROMAPRINT_FOUND)
set(STATUS_CHROMAPRINT "OK")
include_directories(${CHROMAPRINT_INCLUDE_DIR})
else(CHROMAPRINT_FOUND)
set(STATUS_CHROMAPRINT "not found")
endif(CHROMAPRINT_FOUND)
find_package(soundio)
if(SOUNDIO_FOUND)
set(STATUS_SOUNDIO "OK")
include_directories(${SOUNDIO_INCLUDE_DIR})
else(SOUNDIO_FOUND)
set(STATUS_SOUNDIO "not found")
endif(SOUNDIO_FOUND)
find_package(ffmpeg)
if(AVCODEC_FOUND)
set(STATUS_LIBAVCODEC "OK")
include_directories(${AVCODEC_INCLUDE_DIRS})
else()
set(STATUS_LIBAVCODEC "not found")
endif()
if(AVFILTER_FOUND)
set(STATUS_LIBAVFILTER "OK")
include_directories(${AVFILTER_INCLUDE_DIRS})
else()
set(STATUS_LIBAVFILTER "not found")
endif()
if(AVFORMAT_FOUND)
set(STATUS_LIBAVFORMAT "OK")
include_directories(${AVFORMAT_INCLUDE_DIRS})
else()
set(STATUS_LIBAVFORMAT "not found")
endif()
if(AVUTIL_FOUND)
set(STATUS_LIBAVUTIL "OK")
include_directories(${AVUTIL_INCLUDE_DIRS})
else()
set(STATUS_LIBAVUTIL "not found")
endif()
set(LIBGROOVE_SOURCES
"${CMAKE_SOURCE_DIR}/src/buffer.c"
"${CMAKE_SOURCE_DIR}/src/file.c"
"${CMAKE_SOURCE_DIR}/src/groove.c"
"${CMAKE_SOURCE_DIR}/src/player.c"
"${CMAKE_SOURCE_DIR}/src/queue.c"
"${CMAKE_SOURCE_DIR}/src/encoder.c"
"${CMAKE_SOURCE_DIR}/src/fingerprinter.c"
"${CMAKE_SOURCE_DIR}/src/loudness.c"
"${CMAKE_SOURCE_DIR}/src/waveform.c"
"${CMAKE_SOURCE_DIR}/src/playlist.c"
"${CMAKE_SOURCE_DIR}/src/util.c"
"${CMAKE_SOURCE_DIR}/src/os.c"
)
set(CONFIGURE_OUT_FILE "${CMAKE_BINARY_DIR}/config.h")
set(LIBGROOVE_HEADERS
"${CMAKE_SOURCE_DIR}/groove/encoder.h"
"${CMAKE_SOURCE_DIR}/groove/fingerprinter.h"
"${CMAKE_SOURCE_DIR}/groove/groove.h"
"${CMAKE_SOURCE_DIR}/groove/loudness.h"
"${CMAKE_SOURCE_DIR}/groove/player.h"
"${CMAKE_SOURCE_DIR}/groove/waveform.h"
)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror -pedantic")
set(LIB_CFLAGS "-std=c11 -fvisibility=hidden -D_REENTRANT -D_POSIX_C_SOURCE=200809L -Wall -Werror=strict-prototypes -Werror=old-style-definition -Werror=missing-prototypes")
set(EXAMPLE_CFLAGS "-std=c99 -Wall")
configure_file (
"${CMAKE_SOURCE_DIR}/src/config.h.in"
${CONFIGURE_OUT_FILE}
)
set(DOXYGEN_CONF_FILE "${CMAKE_BINARY_DIR}/doxygen.conf")
configure_file(
"${CMAKE_SOURCE_DIR}/doc/doxygen.conf.in"
${DOXYGEN_CONF_FILE}
)
add_library(libgroove_shared SHARED ${LIBGROOVE_SOURCES})
set_target_properties(libgroove_shared PROPERTIES
OUTPUT_NAME groove
SOVERSION ${LIBGROOVE_VERSION_MAJOR}
VERSION ${LIBGROOVE_VERSION}
COMPILE_FLAGS ${LIB_CFLAGS}
LINKER_LANGUAGE C
)
target_link_libraries(libgroove_shared LINK_PUBLIC
${CHROMAPRINT_LIBRARY}
${AVCODEC_LIBRARIES}
${AVFILTER_LIBRARIES}
${AVFORMAT_LIBRARIES}
${AVUTIL_LIBRARIES}
${SOUNDIO_LIBRARY}
${EBUR128_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
m
)
install(TARGETS libgroove_shared DESTINATION lib)
if(BUILD_STATIC_LIBS)
add_library(libgroove_static STATIC ${LIBGROOVE_SOURCES})
set_target_properties(libgroove_static PROPERTIES
OUTPUT_NAME groove
COMPILE_FLAGS ${LIB_CFLAGS}
LINKER_LANGUAGE C
)
install(TARGETS libgroove_static DESTINATION lib)
endif()
install(FILES ${LIBGROOVE_HEADERS} DESTINATION "include/groove")
# Example Programs
if(BUILD_EXAMPLE_PROGRAMS)
add_executable(metadata example/metadata.c)
set_target_properties(metadata PROPERTIES
LINKER_LANGUAGE C
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
target_link_libraries(metadata libgroove_shared)
add_dependencies(metadata libgroove_shared)
add_executable(metadata_checksum example/metadata_checksum.c)
set_target_properties(metadata_checksum PROPERTIES
LINKER_LANGUAGE C
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
target_link_libraries(metadata_checksum libgroove_shared)
add_dependencies(metadata_checksum libgroove_shared)
add_executable(transcode example/transcode.c)
set_target_properties(transcode PROPERTIES
LINKER_LANGUAGE C
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
target_link_libraries(transcode libgroove_shared)
add_dependencies(transcode libgroove_shared)
add_executable(playlist example/playlist.c)
set_target_properties(playlist PROPERTIES
LINKER_LANGUAGE C
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
target_link_libraries(playlist libgroove_shared)
add_dependencies(playlist libgroove_shared)
add_executable(replaygain example/replaygain.c)
set_target_properties(replaygain PROPERTIES
LINKER_LANGUAGE C
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
target_link_libraries(replaygain libgroove_shared)
add_dependencies(replaygain libgroove_shared)
add_executable(fingerprint example/fingerprint.c)
set_target_properties(fingerprint PROPERTIES
LINKER_LANGUAGE C
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
target_link_libraries(fingerprint libgroove_shared)
add_dependencies(fingerprint libgroove_shared)
add_executable(waveform example/waveform.c)
set_target_properties(waveform PROPERTIES
LINKER_LANGUAGE C
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
target_link_libraries(waveform libgroove_shared)
add_dependencies(waveform libgroove_shared)
endif(BUILD_EXAMPLE_PROGRAMS)
add_custom_target(doc
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND doxygen ${DOXYGEN_CONF_FILE}
)
message("\n"
"Installation Summary\n"
"--------------------\n"
"* Install Directory : ${CMAKE_INSTALL_PREFIX}\n"
"* Build Type : ${CMAKE_BUILD_TYPE}\n"
"* Build static libs : ${BUILD_STATIC_LIBS}\n"
"* Build example programs : ${BUILD_EXAMPLE_PROGRAMS}\n"
)
message(
"System Dependencies\n"
"-------------------\n"
"* threads : ${STATUS_THREADS}\n"
"* libsoundio : ${STATUS_SOUNDIO}\n"
"* ebur128 : ${STATUS_EBUR128}\n"
"* chromaprint : ${STATUS_CHROMAPRINT}\n"
"* libavformat : ${STATUS_LIBAVFORMAT}\n"
"* libavcodec : ${STATUS_LIBAVCODEC}\n"
"* libavfilter : ${STATUS_LIBAVFILTER}\n"
"* libavutil : ${STATUS_LIBAVUTIL}\n"
)