-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
442 lines (402 loc) · 14.2 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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
#project name
PROJECT(music)
#version number
SET (music_VERSION_MAJOR 0)
SET (music_VERSION_MINOR 8)
#tell the compiler to include the version number as preprocessor directive
ADD_DEFINITIONS(-DVERSION=${music_VERSION_MAJOR}.${music_VERSION_MINOR})
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
MESSAGE("CMAKE_BUILD_TYPE set to Debug.")
ELSEIF (CMAKE_BUILD_TYPE STREQUAL Release)
MESSAGE("CMAKE_BUILD_TYPE set to Release.")
#für assert.h
ADD_DEFINITIONS(-DNDEBUG)
ELSEIF (CMAKE_BUILD_TYPE STREQUAL Profiling)
MESSAGE("CMAKE_BUILD_TYPE set to Profiling.")
SET(CMAKE_CXX_FLAGS_PROFILING "-pg")
# SET(CMAKE_EXE_LINKER_FLAGS_PROFILING "-pg")
#for assert.h
ADD_DEFINITIONS(-DNDEBUG)
ELSEIF (CMAKE_BUILD_TYPE STREQUAL Valgrind)
MESSAGE("CMAKE_BUILD_TYPE set to Valgrind.")
SET(CMAKE_CXX_FLAGS_VALGRIND "-g -O3")
# SET(CMAKE_EXE_LINKER_FLAGS_PROFILING "-pg")
#for assert.h
ADD_DEFINITIONS(-DNDEBUG)
ELSE()
MESSAGE ( "Choose build type by typing \"cmake -DCMAKE_BUILD_TYPE=Debug\" or \"cmake -DCMAKE_BUILD_TYPE=Release\" or \"cmake -DCMAKE_BUILD_TYPE=Profiling\" or \"cmake -DCMAKE_BUILD_TYPE=Valgrind\".")
ENDIF ()
IF (DEBUG_LEVEL)
ADD_DEFINITIONS(-DDEBUG_LEVEL=${DEBUG_LEVEL})
MESSAGE( "DEBUG_LEVEL set to " ${DEBUG_LEVEL})
ELSE(DEBUG_LEVEL)
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
ADD_DEFINITIONS(-DDEBUG_LEVEL=200)
MESSAGE( "DEBUG_LEVEL set to 200.")
ELSE()
MESSAGE( "DEBUG_LEVEL cleared.")
ENDIF()
ENDIF()
#here, you would set some compiler specific things
IF ( CMAKE_COMPILER_IS_GNUCXX )
MESSAGE ("Using Gnu g++ compiler...")
#gcc should be more pedantic.
ADD_DEFINITIONS(-Wall -pedantic -Wno-long-long)
#allows usage of c++ comments from c without warnings
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion-null ")
ELSE ( MSVC )
MESSAGE ("Using MS Visual Studio compiler...")
ENDIF()
#set cmake module directory, which is needed to find other libs
SET(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/cmake/modules/"
)
#music decoding libraries
FIND_PACKAGE(Sndfile REQUIRED)
FIND_PACKAGE(Mpg123 REQUIRED)
FIND_PACKAGE(Vorbisfile REQUIRED)
ADD_DEFINITIONS(-DHAVE_VORBISFILE=1)
FIND_PACKAGE(SRC REQUIRED)
ADD_DEFINITIONS(-DUSE_GPL_SRC=1) #TODO: rmove this from source code
#used for matrix multiplication, maybe for fft, too
FIND_PACKAGE(Eigen3 3.1.2 REQUIRED)
#use doxygen for documentation. don't need this for compilation.
FIND_PACKAGE(Doxygen)
#sqlite is needed for the database backend
FIND_PACKAGE(SQLITE3 REQUIRED)
#FFTW is used for fft calculations
FIND_PACKAGE(FFTW REQUIRED)
#place source files here
SET(
music_SOURCES
#transforms
src/music/transforms/constantq.cpp
src/music/transforms/fft.cpp
src/music/transforms/dct.cpp
#feature extraction
src/music/feature_extraction/bpm.cpp
src/music/feature_extraction/chroma.cpp
src/music/feature_extraction/timbre.cpp
src/music/feature_extraction/dynamic_range.cpp
src/music/feature_extraction/feature_extraction_helper.cpp
src/music/feature_extraction/preprocessor.cpp
#database
src/music/database/databaseconnection.cpp
src/music/database/sqlitedatabaseconnection.cpp
src/music/database/databaseentities.cpp
#tools
src/tools/console_colors.cpp
src/tools/stringhelper.cpp
src/tools/tuple.cpp
src/tools/randomnumbers.cpp
src/tools/matrixhelper.cpp
src/tools/filesystem.cpp
src/tools/pthread.cpp
src/tools/jsoncpp/jsoncpp.cpp
#musicaccess
src/musicaccess/filter.cpp
src/musicaccess/resample.cpp
src/musicaccess/soundfile.cpp
#uihelper
src/music/uihelper/progress_callback.cpp
#classification
src/music/classification/classifier.cpp
src/music/classification/lda_fisher.cpp
src/music/classification/gaussian_oneclass.cpp
src/music/classification/classificationprocessor.cpp
src/music/classification/classificationcategory.cpp
src/music/classification/gmm/gmm.cpp
src/music/classification/gmm/gaussian.cpp
src/music/classification/gmm/kmeans.cpp
#parts of the test framework that are needed in between
src/tests/debug.cpp
)
#place header here
SET(
music_HEADERS
src/music.hpp
#transforms
src/music/transforms/constantq.hpp
src/music/transforms/fft.hpp
src/music/transforms/dct.hpp
#feature extraction
src/music/feature_extraction/bpm.hpp
src/music/feature_extraction/chroma.hpp
src/music/feature_extraction/timbre.hpp
src/music/feature_extraction/dynamic_range.hpp
src/music/feature_extraction/feature_extraction_helper.hpp
src/music/feature_extraction/preprocessor.hpp
#database
src/music/database/databaseconnection.hpp
src/music/database/sqlitedatabaseconnection.hpp
src/music/database/databaseentities.hpp
#musicaccess
src/musicaccess/filter.hpp
src/musicaccess/resample.hpp
src/musicaccess/soundfile.hpp
#tools
src/tools/console_colors.hpp
src/tools/stringhelper.hpp
src/tools/tuple.hpp
src/tools/randomnumbers.hpp
src/tools/matrixhelper.hpp
src/tools/filesystem.hpp
src/tools/pthread.hpp
src/tools/jsoncpp/json/json.h
src/tools/jsoncpp/json/json-forwards.h
#uihelper
src/music/uihelper/progress_callback.hpp
#classification
src/music/classification/gmm/gaussian.hpp
src/music/classification/classifier.hpp
src/music/classification/lda_fisher.hpp
src/music/classification/gaussian_oneclass.hpp
src/music/classification/classificationprocessor.hpp
src/music/classification/classificationcategory.hpp
src/music/classification/gmm/gmm.hpp
src/music/classification/gmm/kmeans.hpp
#parts of the test framework that are needed in between
src/tests/debug.hpp
)
#put all (possibly autocreated) headers and source files here
SET(
music_TEST_SOURCES
${music_SOURCES}
src/tests/tests.cpp
src/tests/tests_feature_extraction.cpp
src/tests/tests_classifier.cpp
src/tests/tests_database.cpp
src/tests/tests_performance.cpp
src/tests/testframework.cpp
src/tests/main.cpp
)
SET(
music_TEST_HEADERS
${music_HEADERS}
src/tests/tests.hpp
src/tests/tests_feature_extraction.hpp
src/tests/tests_classifier.hpp
src/tests/tests_database.hpp
src/tests/tests_performance.hpp
src/tests/testframework.hpp
src/tests/main.hpp
)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
${SQLITE_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${VORBISFILE_INCLUDE_DIR}
${FFTW_INCLUDES}
src/
src/tools
src/tools/jsoncpp
src/music
src/music/transforms
src/music/feature_extraction
src/music/database
src/music/uihelper
src/music/classification
src/music/classification/gmm
src/tests
)
#to copy a directory (e.g. test files) to another.
FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/testdata DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
IF(DOXYGEN_FOUND)
#convert semicolon-seperated list to whitespace-seperated one
FOREACH(ARG ${music_TEST_HEADERS})
SET(music_HEADERS_WHITESPACE "${music_HEADERS_WHITESPACE} ${CMAKE_CURRENT_SOURCE_DIR}/${ARG}")
ENDFOREACH(ARG ${music_TEST_HEADERS})
FOREACH(ARG ${music_TEST_SOURCES})
SET(music_SOURCES_WHITESPACE "${music_SOURCES_WHITESPACE} ${CMAKE_CURRENT_SOURCE_DIR}/${ARG}")
ENDFOREACH(ARG ${music_TEST_SOURCES})
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES)
FOREACH(ARG ${DIRINC})
SET(music_INCLUDES_WHITESPACE "${music_INCLUDES_WHITESPACE} ${ARG}")
ENDFOREACH(ARG ${DIRINC})
#add configuration file
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
#add doxygen as new target
ADD_CUSTOM_TARGET(doxygen ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
#"make clean" should also clean doxygen
SET_PROPERTY(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES api-doc)
GET_TARGET_PROPERTY(DOC_TARGET doc TYPE)
IF(NOT DOC_TARGET)
ADD_CUSTOM_TARGET(doc)
ENDIF()
ADD_DEPENDENCIES(doc doxygen)
ENDIF()
#add executable files for our project
ADD_LIBRARY(
music SHARED
${music_SOURCES}
)
#tell the linker which libs need to be linked
TARGET_LINK_LIBRARIES(music
${SQLITE3_LIBRARIES}
${SNDFILE_LIBRARIES}
${MPG123_LIBRARIES}
${SRC_LIBRARIES}
${VORBISFILE_LIBRARIES}
${FFTW_LIBRARIES}
m
)
SET_TARGET_PROPERTIES(music
PROPERTIES COMPILE_FLAGS "-fPIC -shared"
)
#add unit tests here
ENABLE_TESTING()
ADD_TEST(basename "musictests" "basename")
ADD_TEST(stringhelper "musictests" "stringhelper")
ADD_TEST(libmusicaccess "musictests" "libmusicaccess")
ADD_TEST(eigen "musictests" "eigen")
ADD_TEST(constantq "musictests" "constantq")
ADD_TEST(fft "musictests" "fft")
ADD_TEST(dct "musictests" "dct")
ADD_TEST(sqlitedatabaseconnection "musictests" "sqlitedatabaseconnection")
ADD_TEST(estimatebpm "musictests" "estimatebpm")
ADD_TEST(estimatechroma "musictests" "estimatechroma")
ADD_TEST(estimatetimbre "musictests" "estimatetimbre")
ADD_TEST(calculatedynamicrange "musictests" "calculatedynamicrange")
ADD_TEST(perbinstatistics "musictests" "perbinstatistics")
ADD_TEST(pertimeslicestatistics "musictests" "pertimeslicestatistics")
ADD_TEST(fisherlda "musictests" "fisherlda")
ADD_TEST(gmm "musictests" "gmm")
ADD_TEST(gmmrand "musictests" "gmmrand")
ADD_TEST(gaussian "musictests" "gaussian")
ADD_TEST(kmeans "musictests" "kmeans")
ADD_TEST(rng "musictests" "rng")
ADD_TEST(blockingqueue "musictests" "blockingqueue")
ADD_TEST(preprocessfiles "musictests" "preprocessfiles" "./testdata/")
SET_TESTS_PROPERTIES(dct PROPERTIES DEPENDS fft)
SET_TESTS_PROPERTIES(kmeans PROPERTIES DEPENDS rng)
SET_TESTS_PROPERTIES(gmm PROPERTIES DEPENDS "gaussian;kmeans")
SET_TESTS_PROPERTIES(estimatebpm PROPERTIES DEPENDS constantq)
SET_TESTS_PROPERTIES(estimatechroma PROPERTIES DEPENDS constantq)
SET_TESTS_PROPERTIES(estimatetimbre PROPERTIES DEPENDS "constantq;gmm")
SET_TESTS_PROPERTIES(calculatedynamicrange PROPERTIES DEPENDS constantq)
SET_TESTS_PROPERTIES(perbinstatistics PROPERTIES DEPENDS constantq)
SET_TESTS_PROPERTIES(pertimeslicestatistics PROPERTIES DEPENDS constantq)
SET_TESTS_PROPERTIES(preprocessfiles PROPERTIES DEPENDS "estimatebpm;estimatechroma;estimatetimbre;calculatedynamicrange;perbinstatistics;pertimeslicestatistics")
ADD_EXECUTABLE(musictests
${music_TEST_SOURCES}
)
SET_TARGET_PROPERTIES(musictests PROPERTIES COMPILE_FLAGS -DBUILD_TESTS)
#tell the linker which libs need to be linked
TARGET_LINK_LIBRARIES(musictests
${SQLITE3_LIBRARIES}
${SNDFILE_LIBRARIES}
${MPG123_LIBRARIES}
${VORBISFILE_LIBRARIES}
${SRC_LIBRARIES}
${FFTW_LIBRARIES}
m
)
#use "make test" to start all tests.
#use this to automatically create installation packages for different platforms
IF(UNIX)
SET(CPACK_SOURCE_GENERATOR
TGZ
TBZ2
)
SET(CPACK_GENERATOR
TGZ
TBZ2
RPM
DEB
)
ELSE(UNIX)
SET(CPACK_SOURCE_GENERATOR
ZIP
)
SET(CPACK_GENERATOR
NSIS
)
ENDIF(UNIX)
#meta data
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"music is a library for music similarity classifying"
)
SET(CPACK_PACKAGE_VENDOR
"-"
)
SET(CPACK_PACKAGE_DESCRIPTION_FILE
#"${CMAKE_CURRENT_SOURCE_DIR}/README.TXT"
)
SET(CPACK_RESOURCE_FILE_LICENSE
#"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT"
)
SET(CPACK_PACKAGE_VERSION_MAJOR
${music_VERSION_MAJOR}
)
SET(CPACK_PACKAGE_VERSION_MINOR
${music_VERSION_MINOR}
)
SET(CPACK_PACKAGE_CONTACT
)
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER
"Lena Brueder"
)
#maybe set something better here
SET(CPACK_PACKAGE_SECTION
"music"
)
SET(CPACK_SOURCE_IGNORE_FILES
${CMAKE_BINARY_DIR}/*
${CMAKE_CURRENT_BINARY_DIR}/*
${CMAKE_CURRENT_SOURCE_DIR}/.gitignore
${CMAKE_CURRENT_SOURCE_DIR}/.git
${CMAKE_CURRENT_SOURCE_DIR}/build/*
)
INCLUDE(CPack)
INSTALL (TARGETS music
LIBRARY DESTINATION lib
)
FILE(GLOB music_global_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp")
INSTALL (FILES ${music_global_headers}
DESTINATION include
)
FILE(GLOB music_special_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/music/*.hpp")
INSTALL (FILES ${music_special_headers}
DESTINATION include/music
)
FILE(GLOB music_transforms_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/music/transforms/*.hpp")
INSTALL (FILES ${music_transforms_headers}
DESTINATION include/music
)
FILE(GLOB music_database_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/music/database/*.hpp")
INSTALL (FILES ${music_database_headers}
DESTINATION include/music
)
FILE(GLOB music_classification_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/music/classification/*.hpp")
INSTALL (FILES ${music_classification_headers}
DESTINATION include/music
)
FILE(GLOB music_classification_gmm_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/music/classification/gmm/*.hpp")
INSTALL (FILES ${music_classification_gmm_headers}
DESTINATION include/music
)
FILE(GLOB music_uihelper_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/music/uihelper/*.hpp")
INSTALL (FILES ${music_uihelper_headers}
DESTINATION include/music
)
FILE(GLOB music_feature_extraction_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/music/feature_extraction/*.hpp")
INSTALL (FILES ${music_feature_extraction_headers}
DESTINATION include/music
)
FILE(GLOB music_tools_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/tools/*.hpp")
INSTALL (FILES ${music_tools_headers}
DESTINATION include/music
)
FILE(GLOB music_json_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/tools/jsoncpp/json/*.h")
INSTALL (FILES ${music_json_headers}
DESTINATION include/music/json
)
FILE(GLOB music_tests_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/*.hpp")
INSTALL (FILES ${music_tests_headers}
DESTINATION include/music
)