-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
225 lines (202 loc) · 7.74 KB
/
Copy pathCMakeLists.txt
File metadata and controls
225 lines (202 loc) · 7.74 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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
cmake_minimum_required(VERSION 3.25)
project(gr-digitizers CXX)
set(CMAKE_CXX_STANDARD 23)
# Determine if gr-digitizers is built as a subproject (using add_subdirectory)
# or if it is the top-level project.
if(NOT DEFINED GR_DIGITIZERS_TOPLEVEL_PROJECT)
set(GR_DIGITIZERS_TOPLEVEL_PROJECT OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(GR_DIGITIZERS_TOPLEVEL_PROJECT ON)
message(STATUS "CMake version: ${CMAKE_VERSION}")
endif()
endif()
if(NOT EMSCRIPTEN)
option(ENABLE_PICOSCOPE "Enable PicoScope support" ON)
option(ENABLE_TIMING "Enable TimingReceiver support" ON)
option(ENABLE_OPENCMW "Enable OpenCmw support" ON)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") # set default C++ STL to Clang's
# libc++ when using Clang
add_compile_options(-stdlib=libc++ -fcolor-diagnostics)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++")
set(CLANG true)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
include(cmake/CMakeRC.cmake)
include(FetchContent)
find_package(gnuradio4 4.0.0 QUIET)
if(NOT gnuradio4_FOUND)
message(
STATUS "Pre-built gnuradio4 not found, fetching and building from source..."
)
FetchContent_Declare(
gnuradio4
GIT_REPOSITORY https://github.com/fair-acc/gnuradio4.git
GIT_TAG c946b140996efae16486f2118e0faca6f8e52c14 # main as of 2026-04-05
EXCLUDE_FROM_ALL)
list(APPEND GR_DIGITIZER_FETCH_CONTENT_LIST gnuradio4)
endif()
if(ENABLE_GR_DIGITIZERS_TESTING)
FetchContent_Declare(
ut
GIT_REPOSITORY https://github.com/boost-ext/ut.git
GIT_TAG v2.3.1 # latest tag as of 2025-04-02
EXCLUDE_FROM_ALL)
list(APPEND GR_DIGITIZER_FETCH_CONTENT_LIST ut)
endif()
if(ENABLE_OPENCMW)
FetchContent_Declare(
opencmw-cpp
GIT_REPOSITORY https://github.com/fair-acc/opencmw-cpp.git
GIT_TAG e30b78193052bf2ea39160a8ec913044552fe103 # latest as of 2026-03-19
EXCLUDE_FROM_ALL)
list(APPEND GR_DIGITIZER_FETCH_CONTENT_LIST "opencmw-cpp")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "(Clang|GNU)")
if(ADDRESS_SANITIZER)
set(SANITIZER_FLAGS
-fsanitize=address -fsanitize-address-use-after-scope -fsanitize=leak
-fno-omit-frame-pointer -fstack-protector-strong)
elseif(UB_SANITIZER)
set(SANITIZER_FLAGS
-fsanitize=undefined -fsanitize-address-use-after-scope -fsanitize=leak
-fno-omit-frame-pointer -fstack-protector-strong)
elseif(THREAD_SANITIZER)
set(SANITIZER_FLAGS -fsanitize=thread -fsanitize=thread)
endif()
if(DEFINED SANITIZER_FLAGS)
add_compile_options(${SANITIZER_FLAGS} -fno-omit-frame-pointer
-fstack-protector-strong)
if(NOT EMSCRIPTEN)
add_compile_options(${SANITIZER_FLAGS} -fstack-clash-protection)
endif()
add_link_options(${SANITIZER_FLAGS})
message(STATUS "Enabled sanitizer flags: ${SANITIZER_FLAGS}")
endif()
endif()
add_library(gr-digitizers-options INTERFACE)
include(cmake/CompilerWarnings.cmake)
set_project_warnings(gr-digitizers-options)
if(EMSCRIPTEN)
FetchContent_MakeAvailable(${GR_DIGITIZER_FETCH_CONTENT_LIST})
set(CMAKE_EXECUTABLE_SUFFIX ".js")
target_compile_options(gr-digitizers-options INTERFACE -fwasm-exceptions
-pthread)
target_link_options(
gr-digitizers-options
INTERFACE
"SHELL:-s ALLOW_MEMORY_GROWTH=1"
-fwasm-exceptions
-pthread
"SHELL:-s PTHREAD_POOL_SIZE=30"
"SHELL:-s FETCH=1"
"SHELL:-s ASSERTIONS=1")
else()
if(GR_DIGITIZERS_TOPLEVEL_PROJECT)
FetchContent_Declare(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG v1.91.9b-docking)
list(APPEND GR_DIGITIZER_FETCH_CONTENT_LIST imgui)
# Enables 32 bit vertex indices for ImGui
add_compile_definitions("ImDrawIdx=unsigned int")
FetchContent_Declare(
implot
GIT_REPOSITORY https://github.com/epezent/implot.git
GIT_TAG v0.16)
list(APPEND GR_DIGITIZER_FETCH_CONTENT_LIST implot)
FetchContent_MakeAvailable(${GR_DIGITIZER_FETCH_CONTENT_LIST})
find_package(SDL3 REQUIRED)
find_package(OpenGL REQUIRED COMPONENTS OpenGL)
# imgui and implot are not CMake Projects, so we have to define their
# targets manually here
add_library(
imgui OBJECT
${imgui_SOURCE_DIR}/imgui_demo.cpp
${imgui_SOURCE_DIR}/imgui_draw.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl3.cpp
${imgui_SOURCE_DIR}/imgui_tables.cpp
${imgui_SOURCE_DIR}/imgui_widgets.cpp
${imgui_SOURCE_DIR}/imgui.cpp
${imgui_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp)
target_link_libraries(imgui PUBLIC SDL3::SDL3 OpenGL::GL)
target_compile_options(
imgui PRIVATE -w) # imgui does lots of oldstyle casts and pointer
# arithmethic leading to many warnings
target_include_directories(imgui BEFORE PUBLIC SYSTEM ${imgui_SOURCE_DIR}
${imgui_SOURCE_DIR}/backends)
add_library(
implot OBJECT
${implot_SOURCE_DIR}/implot_demo.cpp
${implot_SOURCE_DIR}/implot_items.cpp ${implot_SOURCE_DIR}/implot.cpp)
target_compile_options(
implot PRIVATE -w) # implot does lots of oldstyle casts and pointer
# arithmethic leading to many warnings
target_include_directories(implot BEFORE PUBLIC SYSTEM ${implot_SOURCE_DIR})
target_link_libraries(implot PUBLIC imgui)
endif()
endif()
if(CMAKE_CXX_COMPILER MATCHES "/em\\+\\+(-[a-zA-Z0-9.])?$") # if this hasn't
# been set before
# via e.g. emcmake
message(" Transpiling to WASM: using: Emscripten (${CMAKE_CXX_COMPILER})")
set(EMSCRIPTEN true)
endif()
find_package(PkgConfig REQUIRED)
if(ENABLE_PICOSCOPE)
find_package(PicoScope REQUIRED COMPONENTS ps3000a ps4000a ps5000a ps6000)
endif()
if(ENABLE_TIMING AND NOT EMSCRIPTEN)
pkg_check_modules(saftlib REQUIRED IMPORTED_TARGET saftlib)
pkg_check_modules(etherbone REQUIRED IMPORTED_TARGET etherbone)
endif()
option(ENABLE_GR_DIGITIZERS_TESTING "Enable gr-digitizers Test Builds"
${GR_DIGITIZERS_TOPLEVEL_PROJECT})
if(ENABLE_GR_DIGITIZERS_TESTING
AND UNIX
AND NOT APPLE)
list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure")
enable_testing()
if(ENABLE_COVERAGE)
message("Coverage reporting enabled")
set(CODE_COVERAGE_VERBOSE ON)
include(cmake/CodeCoverage.cmake
)# https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake #
# (License: BSL-1.0)
target_compile_options(
gr-digitizers-options INTERFACE --coverage -O0 -g -U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=0) # fortify_source is
# not possible
# without
# optimization
target_link_libraries(gr-digitizers-options INTERFACE --coverage)
set(GCOVR_ADDITIONAL_ARGS
--print-summary --gcov-ignore-errors=all
--gcov-ignore-errors=no_working_dir_found --verbose)
append_coverage_compiler_flags()
setup_target_for_coverage_gcovr_xml(
NAME
coverage
EXECUTABLE
ctest
DEPENDENCIES
EXCLUDE
"$CMAKE_BUILD_DIR/*"
"concepts/.*"
".*/test/.*")
setup_target_for_coverage_gcovr_html(
NAME
coverage_html
EXECUTABLE
ctest
DEPENDENCIES
EXCLUDE
"$CMAKE_BUILD_DIR/*"
"concepts/.*"
".*/test/.*")
endif()
endif()
add_subdirectory(blocklib)