-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathCMakeLists.txt
165 lines (128 loc) · 5 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
cmake_minimum_required(VERSION 2.8)
project(IOWA_HILLS_FILTERS)
# installs Iowa Hills filters to CMAKE_INSTALL_PREFIX
option(USE_DEBUG_ASAN "use GCC's address sanitizer?" OFF)
option(DISABLE_LINK_WITH_M "Disables linking with m library to build with clangCL from MSVC" OFF)
# C90 requires the gcc extensions for function attributes like always_inline
# C99 provides the function attributes: no gcc extensions required
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 98)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# populate what to install
set(INSTALL_TARGETS "")
set(INSTALL_HEADERS "")
if (USE_DEBUG_ASAN)
set(ASANLIB "asan")
else()
set(ASANLIB "")
endif()
########################################################################
# select the release build type by default to get optimization flags
########################################################################
if ( NOT CMAKE_BUILD_TYPE )
set(CMAKE_BUILD_TYPE "Release")
message(STATUS "Build type not specified: defaulting to release.")
endif(NOT CMAKE_BUILD_TYPE)
if ( CMAKE_C_COMPILER_ID MATCHES "MSVC" )
# using Visual Studio C++
message(STATUS "INFO: detected MSVC: will not link math lib m")
set(MATHLIB "")
else()
if(DISABLE_LINK_WITH_M)
else()
message(STATUS "INFO: detected NO MSVC: ${CMAKE_C_COMPILER_ID}: will link math lib m")
set(MATHLIB "m")
endif()
endif()
set(STDCXXLIB "")
if (MINGW)
set(STDCXXLIB "stdc++")
endif()
set( HDRS
include/iowahills/limits.h
include/iowahills/CplxDMath.hpp
include/iowahills/windowing.h
include/iowahills/fft.h
include/iowahills/goertzel.h
include/iowahills/fir.h
include/iowahills/freq_sampling.h
include/iowahills/iir.h
include/iowahills/lowpass_prototypes.h
include/iowahills/lowpass_roots.h
include/iowahills/parks_mcclellan.h
include/iowahills/PFiftyOneRevE.h
include/iowahills/QuadRootsRevH.h
)
set( SRCS
src/non_throwing_vector.h
src/fft.cpp
src/goertzel.cpp
src/windowing.cpp
src/fir.cpp
src/freq_sampling.cpp
src/iir.cpp
src/lowpass_prototypes.cpp
src/lowpass_roots.cpp
src/parks_mcclellan.cpp
src/PFiftyOneRevE.cpp
src/QuadRootsRevH.cpp
${HDRS}
)
set(INSTALL_HEADERS ${INSTALL_HEADERS} ${HDRS})
######################################################
add_library(iowa_hills_dsp STATIC ${SRCS})
target_compile_definitions(iowa_hills_dsp PRIVATE _USE_MATH_DEFINES)
if (USE_DEBUG_ASAN)
target_compile_options(iowa_hills_dsp PRIVATE "-fsanitize=address")
endif()
target_compile_options(iowa_hills_dsp PRIVATE $<$<C_COMPILER_ID:GNU>:-Wall -Wextra -pedantic>)
target_compile_options(iowa_hills_dsp PRIVATE $<$<C_COMPILER_ID:Clang>:-Wall -Wextra -pedantic>)
target_link_libraries( iowa_hills_dsp ${MATHLIB} )
target_include_directories(iowa_hills_dsp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(INSTALL_TARGETS ${INSTALL_TARGETS} iowa_hills_dsp)
install( TARGETS ${INSTALL_TARGETS} DESTINATION lib)
install( FILES ${INSTALL_HEADERS} DESTINATION include/iowahills)
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_SOURCE_DIR}/uninstall.cmake"
)
#######################################################
# add_subdirectory(examples) ? -> No!
# Have subdirectory as standalone test - without having this CMakeLists.txt
######################################################
add_executable(example examples/FilterKitMain.cpp examples/FilterKitMain.h)
target_compile_definitions(example PRIVATE _USE_MATH_DEFINES)
if (USE_DEBUG_ASAN)
target_compile_options(example PRIVATE "-fsanitize=address")
endif()
target_compile_options(example PRIVATE $<$<C_COMPILER_ID:GNU>:-Wall -Wextra -pedantic>)
target_compile_options(example PRIVATE $<$<C_COMPILER_ID:Clang>:-Wall -Wextra -pedantic>)
target_link_libraries( example iowa_hills_dsp ${MATHLIB} ${ASANLIB} )
#######################################################
# tools
######################################################
add_executable(pmord tools/pmord_tool.cpp)
target_compile_definitions(pmord PRIVATE _USE_MATH_DEFINES)
if (USE_DEBUG_ASAN)
target_compile_options(pmord PRIVATE "-fsanitize=address")
endif()
target_compile_options(pmord PRIVATE $<$<C_COMPILER_ID:GNU>:-Wall -Wextra -pedantic>)
target_compile_options(pmord PRIVATE $<$<C_COMPILER_ID:Clang>:-Wall -Wextra -pedantic>)
target_link_libraries( pmord iowa_hills_dsp ${MATHLIB} ${ASANLIB} )
#######################################################
# tests
######################################################
add_executable(test_fft tests/test_fft.cpp)
target_compile_definitions(test_fft PRIVATE _USE_MATH_DEFINES)
if (USE_DEBUG_ASAN)
target_compile_options(test_fft PRIVATE "-fsanitize=address")
endif()
target_compile_options(test_fft PRIVATE $<$<C_COMPILER_ID:GNU>:-Wall -Wextra -pedantic>)
target_compile_options(test_fft PRIVATE $<$<C_COMPILER_ID:Clang>:-Wall -Wextra -pedantic>)
target_link_libraries( test_fft iowa_hills_dsp ${MATHLIB} ${ASANLIB} )
enable_testing()
add_test(NAME test_fft
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/test_fft"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)