-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
118 lines (95 loc) · 3.04 KB
/
CMakeLists.txt
File metadata and controls
118 lines (95 loc) · 3.04 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
cmake_minimum_required(VERSION 3.27)
project(embedded-cpp-bsp VERSION 0.0.1 LANGUAGES CXX C ASM)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(COMMON_COMPILE_OPTIONS
-Wall
-Wextra
-Werror
-Wpedantic
-Os
-g
)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(COMMON_COMPILE_OPTIONS ${COMMON_COMPILE_OPTIONS}
-Wno-c++98-compat
-Wno-exit-time-destructors
-Wno-global-constructors
-Wno-weak-vtables
-fno-rtti
-stdlib=libc++
)
# Needed to make clang-tidy and ensure all the built libs use
# the same C++ stdlib implementation
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(COMMON_COMPILE_OPTIONS ${COMMON_COMPILE_OPTIONS}
-Wno-unknown-pragmas
-fno-rtti
)
endif()
include(FetchContent)
FetchContent_Declare(
etl
GIT_REPOSITORY https://github.com/ETLCPP/etl
GIT_TAG 20.38.1
)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG v1.14.0
)
FetchContent_Declare(
stm32cubef7
GIT_REPOSITORY https://github.com/STMicroelectronics/STM32CubeF7
GIT_TAG v1.17.1
)
FetchContent_Declare(
CmakeScripts
GIT_REPOSITORY https://github.com/StableCoder/cmake-scripts.git
GIT_TAG main
)
FetchContent_GetProperties(CmakeScripts)
if(NOT cmakescripts_POPULATED)
FetchContent_MakeAvailable(CmakeScripts)
set(CMAKE_MODULE_PATH ${cmakescripts_SOURCE_DIR} ${CMAKE_MODULE_PATH})
endif()
# Assume libzmq is installed on the system
# CPPZMQ header-only library; uses ZeroMQ
option(CPPZMQ_BUILD_TESTS OFF)
FetchContent_Declare(cppzmq GIT_REPOSITORY https://github.com/zeromq/cppzmq.git GIT_TAG v4.10.0)
# FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz)
FetchContent_Declare(json GIT_REPOSITORY https://github.com/nlohmann/json GIT_TAG v3.11.2)
FetchContent_MakeAvailable(etl)
add_subdirectory(external)
include(tools)
include(code-coverage)
# Configure global code coverage settings
if(CODE_COVERAGE)
# Create 'ccov-all' target and set global exclusions
add_code_coverage_all_targets(
EXCLUDE "test_*.cpp" "*/test/*" "*/_deps/*" "*/googletest/*" "*/gtest/*" "*/external/*"
LLVM_EXCLUDE ".*/test_.*\\.cpp" ".*/test/.*" ".*/_deps/.*" ".*/googletest/.*" ".*/gtest/.*" ".*/external/.*"
LCOV_EXCLUDE "*/test_*.cpp" "*/test/*" "*/_deps/*" "*/googletest/*" "*/gtest/*" "*/external/*"
)
endif()
if(CMAKE_PRESET STREQUAL "host")
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
FetchContent_MakeAvailable(cppzmq)
FetchContent_MakeAvailable(json)
include(CTest)
enable_testing()
endif()
if(CMAKE_PRESET STREQUAL "arm-cm7")
FetchContent_MakeAvailable(stm32cubef7)
endif()
clang_tidy("-header-filter=${CMAKE_CURRENT_SOURCE_DIR}/src/.*}")
add_subdirectory(src)
add_subdirectory(test)
reset_clang_tidy()
add_subdirectory(py) # No clang-tidy for python