-
Notifications
You must be signed in to change notification settings - Fork 142
/
CMakeLists.txt
161 lines (129 loc) · 4.13 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
cmake_minimum_required(VERSION 3.8.0)
project(iir VERSION 1.9.5 LANGUAGES CXX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
include(GNUInstallDirs)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
option(IIR1_NO_EXCEPTIONS "Disable exception handling" OFF)
option(IIR1_INSTALL_STATIC "Install static library" ON)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(IIR1_BUILD_TESTING_DEFAULT ON)
else()
set(IIR1_BUILD_TESTING_DEFAULT OFF)
endif()
option(IIR1_BUILD_TESTING "Build tests" ${IIR1_BUILD_TESTING_DEFAULT})
if(IIR1_BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
option(IIR1_BUILD_DEMO "Build demo" ON)
if(IIR1_BUILD_DEMO)
add_subdirectory(demo)
endif()
if (MSVC)
add_compile_options(/W4)
else()
add_compile_options(-Wall -pedantic)
endif()
set(LIBSRC
iir/Biquad.cpp
iir/Butterworth.cpp
iir/Cascade.cpp
iir/ChebyshevI.cpp
iir/ChebyshevII.cpp
iir/Custom.cpp
iir/PoleFilter.cpp
iir/RBJ.cpp)
set(LIBINCLUDE
iir/Biquad.h
iir/Butterworth.h
iir/Cascade.h
iir/ChebyshevI.h
iir/ChebyshevII.h
iir/Common.h
iir/Custom.h
iir/Layout.h
iir/MathSupplement.h
iir/PoleFilter.h
iir/RBJ.h
iir/State.h
iir/Types.h)
add_library(iir SHARED ${LIBSRC})
add_library(iir::iir ALIAS iir)
target_compile_features(iir PUBLIC cxx_std_11)
target_include_directories(iir
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> # for Iir.h
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/iir> # everything else
)
if(IIR1_NO_EXCEPTIONS)
target_compile_definitions(iir PUBLIC "IIR1_NO_EXCEPTIONS")
endif()
set_target_properties(iir PROPERTIES
SOVERSION 1
VERSION ${PROJECT_VERSION}
PUBLIC_HEADER Iir.h
PRIVATE_HEADER "${LIBINCLUDE}")
install(TARGETS iir EXPORT iir-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PRIVATE_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/iir)
include(JoinPaths)
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
join_paths(libdir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
configure_file(iir.pc.in iir.pc @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/iir.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/")
add_library(iir_static STATIC ${LIBSRC})
add_library(iir::iir_static ALIAS iir_static)
target_compile_features(iir_static PUBLIC cxx_std_11)
target_include_directories(iir_static
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> # for Iir.h
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/iir> # everything else
)
if(IIR1_NO_EXCEPTIONS)
target_compile_definitions(iir_static PUBLIC "IIR1_NO_EXCEPTIONS")
endif()
set_target_properties(iir_static PROPERTIES
POSITION_INDEPENDENT_CODE TRUE
VERSION ${PROJECT_VERSION}
PUBLIC_HEADER Iir.h
PRIVATE_HEADER "${LIBINCLUDE}")
if(IIR1_INSTALL_STATIC)
install(TARGETS iir_static EXPORT iir-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PRIVATE_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/iir)
endif()
install(EXPORT iir-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/iir
NAMESPACE iir::
FILE iirTargets.cmake
)
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/iirConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/iir"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/iirConfigVersion.cmake"
VERSION "${iir_VERSION_MAJOR}.${iir_VERSION_MINOR}"
COMPATIBILITY AnyNewerVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/iirConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/iirConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/iir
)