forked from Yaafe/Yaafe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
173 lines (152 loc) · 5.89 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
cmake_minimum_required (VERSION 2.6)
project (yaafe CXX C)
set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-modules")
# The version number.
set (YAAFE_VERSION_MAJOR 0)
set (YAAFE_VERSION_MINOR 70)
set (YAAFE_API_VERSION 0)
set (YAAFE_VERSION ${YAAFE_VERSION_MAJOR}.${YAAFE_VERSION_MINOR})
set (YAAFE_LIBVERSION ${YAAFE_VERSION}.${YAAFE_API_VERSION})
set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${YAAFE_VERSION})
add_custom_target(dist
COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
| bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
# Compiler FLAGS
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif (NOT CMAKE_BUILD_TYPE)
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -ftemplate-depth-30 -g2" CACHE STRING "CXX DEBUG FLAGS" FORCE)
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g2" CACHE STRING "C DEBUG FLAGS" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -ffast-math" CACHE STRING "CXX RELEASE FLAGS" FORCE)
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG -ffast-math" CACHE STRING "C RELEASE FLAGS" FORCE)
add_definitions(-Wno-write-strings)
find_package(Argtable2 REQUIRED)
if (NOT WIN32)
find_package(DL REQUIRED)
endif (NOT WIN32)
option(WITH_EIGEN_LIBRARY "Use external Eigen3 library" ON)
find_package(Eigen3)
if (WITH_EIGEN_LIBRARY)
if (NOT EIGEN3_FOUND)
#message(SEND_ERROR "Cannot find Eigen3 library")
set(EIGEN3_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/externals/eigen)
endif (NOT EIGEN3_FOUND)
else (WITH_EIGEN_LIBRARY)
set(EIGEN3_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/externals/eigen)
endif (WITH_EIGEN_LIBRARY)
mark_as_advanced(FORCE EIGEN3_INCLUDE_DIR)
set(SMARC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/externals/audio-smarc)
mark_as_advanced(FORCE SMARC_INCLUDE_DIR)
if(APPLE)
set(FMEMOPEN_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/externals/fmemopen)
mark_as_advanced(FORCE FMEMOPEN_INCLUDE_DIR)
endif(APPLE)
# optional packages
option(WITH_SNDFILE "Use sndfile library" ON)
find_package(Sndfile)
if (WITH_SNDFILE)
if (NOT SNDFILE_FOUND)
message(SEND_ERROR "Cannot find libsndfile library")
endif (NOT SNDFILE_FOUND)
add_definitions(-DWITH_SNDFILE=1)
endif (WITH_SNDFILE)
find_package(HDF5)
if (HDF5_FOUND)
option(WITH_HDF5 "Use HDF5 library" ON)
else (HDF5_FOUND)
option(WITH_HDF5 "Use HDF5 library" OFF)
endif (HDF5_FOUND)
if (WITH_HDF5)
if (NOT HDF5_FOUND)
message(SEND_ERROR "Cannot find HDF5 library")
endif (NOT HDF5_FOUND)
add_definitions(-DWITH_HDF5=1)
add_definitions(-DH5_NO_DEPRECATED_SYMBOLS)
endif (WITH_HDF5)
find_package(MPG123)
if (MPG123_FOUND)
option(WITH_MPG123 "Use MPG123 library" ON)
else (MPG123_FOUND)
option(WITH_MPG123 "Use MPG123 library" OFF)
endif (MPG123_FOUND)
if (WITH_MPG123)
if (NOT MPG123_FOUND)
message(SEND_ERROR "Cannot find MPG123 library")
endif (NOT MPG123_FOUND)
add_definitions(-DWITH_MPG123=1)
endif (WITH_MPG123)
find_package(Lapack)
if (LAPACK_FOUND)
option(WITH_LAPACK "Use Lapack library" ON)
else (LAPACK_FOUND)
option(WITH_LAPACK "Use Lapack library" OFF)
endif (LAPACK_FOUND)
if (WITH_LAPACK)
if (NOT LAPACK_FOUND)
message(SEND_ERROR "Cannot find Lapack library")
endif (NOT LAPACK_FOUND)
add_definitions(-DWITH_LAPACK=1)
endif (WITH_LAPACK)
find_package(FFTW3)
if (FFTW3_FOUND)
option(WITH_FFTW3 "Use Lapack library" ON)
else (FFTW3_FOUND)
option(WITH_FFTW3 "Use FFTW3 library" OFF)
endif (FFTW3_FOUND)
if (WITH_FFTW3)
if (NOT FFTW3_FOUND)
message(SEND_ERROR "Cannot find FFTW3 library")
endif (NOT FFTW3_FOUND)
add_definitions(-DWITH_FFTW3=1)
add_definitions(-DEIGEN_FFTW_DEFAULT=1)
endif (WITH_FFTW3)
option(WITH_MATLAB_MEX "build matlab mex and install matlab package" OFF)
find_package(Matlab)
if (WITH_MATLAB_MEX)
if (NOT MATLAB_FOUND)
message(SEND_ERROR "Cannot find matlab programs")
endif (NOT MATLAB_FOUND)
endif (WITH_MATLAB_MEX)
FIND_LIBRARY(RT_LIBRARY NAMES rt PATHS /usr/lib /usr/local/lib)
option(WITH_TIMERS "Use timers" OFF)
if (WITH_TIMERS)
if (NOT RT_LIBRARY)
message(SEND_ERROR "Cannot find rt library, needed to enable timers")
endif (NOT RT_LIBRARY)
add_definitions(-DWITH_TIMERS=1)
endif(WITH_TIMERS)
FIND_PROGRAM(SPHINX_BUILD sphinx-build PATHS ENV PATH DOC "sphinx-build script used to build documentation")
execute_process ( COMMAND python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix=''))" OUTPUT_VARIABLE python_packages OUTPUT_STRIP_TRAILING_WHITESPACE )
# install paths
set(CMAKE_INSTALL_BINDIR bin CACHE PATH "Output directory for programs")
set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries")
set(CMAKE_INSTALL_INCLUDE include CACHE PATH "Output directory for header files")
set(CMAKE_INSTALL_PYTHON_PACKAGES ${python_packages} CACHE PATH "Output directory for yaafe Python packages")
set(CMAKE_INSTALL_MATLAB_SCRIPTS matlab CACHE PATH "Output directory for matlab scripts")
# add targets
add_definitions(-DVERSION=${YAAFE_VERSION})
add_subdirectory (externals)
add_subdirectory (src_cpp)
add_subdirectory (src_python)
if (WITH_MATLAB_MEX)
add_subdirectory (matlab)
endif (WITH_MATLAB_MEX)
add_subdirectory (doc)
# export targets
install(EXPORT yaafe-targets DESTINATION lib/yaafe)
install(FILES yaafe-config.cmake DESTINATION lib/yaafe)
# build a CPack driven installer package
include (InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LESSER")
set (CPACK_PACKAGE_VERSION_MAJOR "${YAAFE_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${YAAFE_VERSION_MINOR}")
include (CPack)
# add uninstall target
configure_file(
"${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")