-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
117 lines (93 loc) · 3.05 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
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()
# ZeroMQ itself, so we are not dependent on the system version
# Use this to get the latest version, once the issue is fixed. TODO: pin this version.
# FetchContent_Declare(zeromq GIT_REPOSITORY https://github.com/nehalkpatel/libzmq.git GIT_TAG fix/4629-compile-warning)
option(ZMQ_BUILD_TESTS OFF)
FetchContent_Declare(zeromq GIT_REPOSITORY https://github.com/zeromq/libzmq.git GIT_TAG b268effd886c9ea45f8a6f37f8d62b4bb045ad37)
# 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)
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(zeromq)
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)
reset_clang_tidy()
clang_tidy("-header-filter=${CMAKE_CURRENT_SOURCE_DIR}/src/.*}")
add_subdirectory(test)
reset_clang_tidy()
add_subdirectory(py)