-
Notifications
You must be signed in to change notification settings - Fork 26
/
CMakeLists.txt
184 lines (146 loc) · 5.87 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
project(ReSampler C CXX)
cmake_minimum_required(VERSION 3.11)
find_package(Threads REQUIRED)
set(CMAKE_CXX_STANDARD 17)
add_compile_definitions(COMPILER_ID="${CMAKE_CXX_COMPILER_ID}" COMPILER_VERSION="${CMAKE_CXX_COMPILER_VERSION}")
if(ANDROID)
set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS OFF)
add_subdirectory (android/src/fftw-3.3.8)
include_directories(android/src/fftw-3.3.8/api)
add_subdirectory (android/src/libsndfile)
include_directories($CMAKE_SOURCE_DIR/android/src/libsndfile/src)
set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}")
set(SOURCE_FILES
alignedmalloc.h
biquad.h
conversioninfo.h
conversioninfo.cpp
csv.h
dff.h
ditherer.h
dsf.h
FIRFilter.h
fraction.h
factorial.h
noiseshape.h
osspecific.h
raiitimer.h
main.cpp
ReSampler.cpp
ReSampler.h
srconvert.h
iqdemodulator.h
mpxdecode.h
effect.h
effectchain.h
stereoimager.h
fadeeffect.h
)
add_library(ReSampler SHARED ${SOURCE_FILES})
target_link_libraries(ReSampler sndfile fftw3 log)
else()
if(NOT CMAKE_CONFIGURATION_TYPES)
# single-config build (build type decided by CMAKE_BUILD_TYPE )
# for single-config builds, add additional configurations
set (CMAKE_CXX_FLAGS_RELEASEAVX ${CMAKE_CXX_FLAGS_RELEASE_INIT} " -DUSE_AVX -mavx")
set (CMAKE_CXX_FLAGS_RELEASEQUADMATH ${CMAKE_CXX_FLAGS_RELEASE_INIT} " -DUSE_QUADMATH")
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "build type not specified - using default")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the build type" FORCE)
endif()
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "ReleaseAVX" "ReleaseQuadmath")
message(STATUS "build type: '${CMAKE_BUILD_TYPE}'")
endif()
set(SOURCE_FILES
alignedmalloc.h
biquad.h
conversioninfo.h
csv.h
dff.h
ditherer.h
dsf.h
FIRFilter.h
fraction.h
factorial.h
noiseshape.h
osspecific.h
raiitimer.h
ReSampler.cpp
ReSampler.h
srconvert.h
conversioninfo.cpp
iqdemodulator.h
mpxdecode.h
effect.h
effectchain.h
stereoimager.h
fadeeffect.h
)
if (WIN32)
message(STATUS "libsndfile library location: " ${SNDFILE_LIBRARY})
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
message(STATUS "Windows 32-bit")
set (SNDFILE_DIR libsndfile-1.2.0-win32)
set (FFTW_DIR fftw32)
else()
message(STATUS "Windows 64-bit")
set (SNDFILE_DIR libsndfile-1.2.0-win64)
set (FFTW_DIR fftw64)
endif()
include_directories(${SNDFILE_DIR}/include ${FFTW_DIR})
link_directories(${SNDFILE_DIR}/lib ${FFTW_DIR})
find_library(SNDFILE_LIBRARY NAMES sndfile HINTS ${SNDFILE_DIR}/lib)
add_library(ReSamplerLib ${SOURCE_FILES})
if(MSVC)
message(STATUS "Visual Studio")
target_link_libraries(ReSamplerLib libsndfile.lib libfftw3-3.lib ${CMAKE_THREAD_LIBS_INIT})
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 4)
# create additional 64-bit config: ReleaseAVX
set (CMAKE_CONFIGURATION_TYPES "Debug;Release;ReleaseAVX" CACHE STRING "" FORCE)
# add /arch:AVX and /DUSE_AVX flags for ReleaseAVX configuration
set (CMAKE_CXX_FLAGS_RELEASEAVX ${CMAKE_CXX_FLAGS_RELEASE_INIT} " /arch:AVX /DUSE_AVX")
# same linker flags
set (CMAKE_EXE_LINKER_FLAGS_RELEASEAVX ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT})
set (CMAKE_SHARED_LINKER_FLAGS_RELEASEAVX ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
endif()
else()
message(STATUS "compiler flags: ${CMAKE_CXX_FLAGS_RELEASE_INIT}")
message(STATUS "mingw dll location is here: ${MINGW_PREFIX}/bin")
if(CMAKE_BUILD_TYPE STREQUAL "ReleaseQuadmath")
set(CMAKE_CXX_EXTENSIONS TRUE) # -std=gnu++11 instead of -std=c++11
message(STATUS "Linking with Quadmath library")
target_link_libraries(ReSamplerLib ${SNDFILE_LIBRARY} libfftw3-3 libquadmath ${CMAKE_THREAD_LIBS_INIT})
else()
target_link_libraries(ReSamplerLib ${SNDFILE_LIBRARY} libfftw3-3 ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()
else()
#Not Windows ...
if(APPLE)
# since Mojave, cmake no longer finds these automatically:
# (see https://stackoverflow.com/questions/54068035/linking-not-working-in-homebrews-cmake-since-mojave)
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
endif()
add_library(ReSamplerLib SHARED ${SOURCE_FILES})
if(CMAKE_BUILD_TYPE STREQUAL "ReleaseQuadmath")
message(STATUS "Linking with Quadmath library")
set(CMAKE_CXX_EXTENSIONS TRUE) # -std=gnu++11 instead of -std=c++11
target_link_libraries(ReSamplerLib sndfile fftw3 quadmath ${CMAKE_THREAD_LIBS_INIT})
else()
target_link_libraries(ReSamplerLib sndfile fftw3 ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()
# include(CheckIPOSupported)
# check_ipo_supported(RESULT iposupported OUTPUT error)
add_executable(ReSampler main.cpp)
# if(iposupported)
# message(STATUS "IPO / LTO enabled")
# set_property(TARGET ReSampler PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
# else()
# message(STATUS "IPO / LTO not supported: <${error}>")
# endif()
target_link_libraries(ReSampler ReSamplerLib)
endif()