-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
78 lines (67 loc) · 1.57 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
cmake_minimum_required(VERSION 3.26.3)
project(stm_manual CXX C ASM)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_definitions(
-DSTM32F411xE
)
set(arch_flags
-mcpu=cortex-m4
-mfpu=fpv4-sp-d16
-mfloat-abi=hard
-mthumb
-mabi=aapcs
)
# Compiler and Linker options
set(common_flags
$<$<C_COMPILER_ID:GNU>:--specs=nosys.specs>
$<$<C_COMPILER_ID:GNU>:--specs=nano.specs>
)
set(compile_flags
-Wall -Wextra
-Wshadow
-Wdouble-promotion
-Wformat=2
-Wformat-truncation
-Wformat-signedness
-Wundef
-Wconversion
# -Werror
$<$<COMPILE_LANGUAGE:CXX>:-Weffc++>
-ffunction-sections
-fdata-sections
-fstack-usage
-fno-strict-aliasing
-fno-builtin
-ffast-math
-fno-common
-fstack-usage -Wstack-usage=256
$<$<COMPILE_LANGUAGE:C>:-std=c11>
$<$<COMPILE_LANGUAGE:CXX>:-std=c++17>
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
-g3
)
# Linker Options
set(link_flags
-Wl,--gc-sections -static
-T ${CMAKE_CURRENT_LIST_DIR}/include/vendor/STM32F411CEUX.ld
-flto
-Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group
-Wl,--print-memory-usage
-Xlinker -Map=output.map
)
add_compile_options(
${arch_flags}
${common_flags}
${compile_flags}
)
# include after options have been defined
add_subdirectory("src/")
# add the executable
# all code comes from libraries -> need to have a dummy empty file
if (NOT DEFINED BUILD_EXAMPLES)
set(BUILD_EXAMPLES OFF)
endif()
if(BUILD_EXAMPLES)
add_subdirectory("example/")
endif()