-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
145 lines (122 loc) · 4.48 KB
/
CMakeLists.txt
File metadata and controls
145 lines (122 loc) · 4.48 KB
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
cmake_minimum_required(VERSION 3.14)
# This source code is licensed under the MIT license. See file "LICENSE" at the root of the repository.
project(FilterGen VERSION 1.0.0)
option(DH_CFILTER_BUILD_CPP_BINDINGS "If the bindings for cpp should be built." ON)
option(DH_CFILTER_BUILD_JS_BINDINGS "If the bindings for javascript should be built. This includes the C++ Bindings." OFF)
option(DH_CFILTER_BUILD_TESTS "If the tests should be built." ON)
option(DH_CFILTER_BUILD_EXAMPLES "If the example application should be built." ON)
option(DH_CFILTER_COVERAGE "If the binary should be instrumented to collect coverage information." OFF)
add_library(filter
src/dh_complex.c
src/filter.c
src/utility.c
src/create_filter.c
src/free_filter.c
src/butterworth.c
src/chebyshev.c
)
target_include_directories(filter PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
)
add_library(dh::filter ALIAS filter)
find_package(Doxygen)
if(DH_CFILTER_BUILD_TESTS OR DH_CFILTER_BUILD_EXAMPLES OR TARGET Doxygen::doxygen)
include(FetchContent)
endif()
if(MSVC)
target_compile_options(filter PRIVATE /W4 /WX)
else()
target_compile_options(filter PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
if(DH_CFILTER_COVERAGE AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(filter PUBLIC -coverage -fprofile-arcs -ftest-coverage)
target_link_libraries(filter PUBLIC -coverage)
endif()
if(DH_CFILTER_BUILD_CPP_BINDINGS OR DH_CFILTER_BUILD_JS_BINDINGS)
add_library(filter_cpp
src/bindings/cpp/filter.cpp
)
target_link_libraries(filter_cpp PUBLIC dh::filter)
target_compile_features(filter_cpp PUBLIC cxx_std_11)
add_library(dh::filter_cpp ALIAS filter_cpp)
if(MSVC)
target_compile_options(filter_cpp PRIVATE /W4 /WX)
else()
target_compile_options(filter_cpp PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
endif()
if(DH_CFILTER_BUILD_EXAMPLES AND DH_CFILTER_BUILD_CPP_BINDINGS)
message(STATUS "Fetching cxxopts")
FetchContent_Declare(
Cxxopts
GIT_REPOSITORY https://github.com/jarro2783/cxxopts.git
GIT_TAG v3.3.1
)
FetchContent_MakeAvailable(Cxxopts)
message(STATUS "Done")
add_executable(design-filter
examples/design-filter.cpp
)
target_link_libraries(design-filter PRIVATE cxxopts::cxxopts dh::filter_cpp)
endif()
if(DH_CFILTER_BUILD_JS_BINDINGS)
add_executable(filter.js
src/bindings/js/emscripten.cpp
)
target_link_libraries(filter.js PRIVATE -lembind -Wl,--whole-archive dh::filter dh::filter_cpp -Wl,--no-whole-archive)
endif()
if(DH_CFILTER_BUILD_TESTS)
message(STATUS "Fetching Catch2")
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.7.0
)
FetchContent_MakeAvailable(Catch2)
message(STATUS "Done")
list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras)
include(CTest)
include(Catch)
add_executable(test-filter
test/brickwall-test.cpp
test/butterworth-test.cpp
test/chebyshev-test.cpp
test/chebyshev2-test.cpp
test/moving-average-test.cpp
test/complex_bridge.c
test/generated_c_code.c
test/generated-code-test.cpp
test/iir-filter-test.cpp
test/fir-exponential-test.cpp
test/iir-exponential-test.cpp
test/utility-test.cpp
)
target_link_libraries(test-filter PRIVATE Catch2::Catch2WithMain dh::filter)
if(DH_CFILTER_BUILD_CPP_BINDINGS)
target_sources(test-filter PRIVATE test/cpp-bindings-test.cpp)
target_link_libraries(test-filter PRIVATE dh::filter_cpp)
endif()
catch_discover_tests(test-filter)
endif()
if(TARGET Doxygen::doxygen)
message(STATUS "Fetching doxygen awesome")
FetchContent_Declare(
doxygen-awesome
GIT_REPOSITORY https://github.com/jothepro/doxygen-awesome-css.git
GIT_TAG v2.0.3
)
FetchContent_MakeAvailable(doxygen-awesome)
message(STATUS "Done")
set(DOXYGEN_STRIP_FROM_INC_PATH ${PROJECT_SOURCE_DIR}/include)
set(DOXYGEN_STRIP_FROM_PATH ${PROJECT_SOURCE_DIR}/include)
set(DOXYGEN_HTML_EXTRA_STYLESHEET "${CMAKE_CURRENT_BINARY_DIR}/_deps/doxygen-awesome-src/doxygen-awesome.css;${CMAKE_CURRENT_BINARY_DIR}/_deps/doxygen-awesome-src/doxygen-awesome-sidebar-only.css")
set(DOXYGEN_GENERATE_TREEVIEW "YES")
set(DOXYGEN_PROJECT_BRIEF "A library to design digital filters in embedded systems.")
set(DOXYGEN_PROJECT_LOGO "docs/assets/images/favicon-32x32.png")
set(DOXYGEN_OUTPUT_DIRECTORY "docs/api")
set(DOXYGEN_QUIET "YES")
doxygen_add_docs(apidocs
${PROJECT_SOURCE_DIR}/include/
COMMENT "Generating API documentation"
)
endif()