-
Notifications
You must be signed in to change notification settings - Fork 41
/
CMakeLists.txt
72 lines (60 loc) · 1.58 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
cmake_minimum_required(VERSION 3.0)
# project name
project(baremetal)
# select linker script
set(LINKER_SCRIPT "ld/stm32f031x6.ld")
# define CPU OPTIONS
set(CPU_OPTIONS -mthumb -mcpu=cortex-m0)
# optimizations (-O0 -O1 -O2 -O3 -Os -Ofast -Og -flto)
set(CMAKE_C_FLAGS_DEBUG "-Og -g -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")
set(CMAKE_C_FLAGS_RELEASE "-Os -flto")
set(CMAKE_CXX_FLAGS_RELEASE "-Os -flto")
add_compile_options(
${CPU_OPTIONS}
$<$<COMPILE_LANGUAGE:C>:-std=c11>
$<$<COMPILE_LANGUAGE:CXX>:-std=c++17>
$<$<COMPILE_LANGUAGE:CXX>:-fms-extensions>
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
$<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit>
$<$<COMPILE_LANGUAGE:CXX>:-fno-threadsafe-statics>
-fstrict-volatile-bitfields
-ffunction-sections
-fno-threadsafe-statics
-Werror
-Wall
-Wextra
-Wcast-align
-Wconversion
-Wsign-conversion
-Wold-style-cast
-Wshadow
-Wlogical-op
-Wsuggest-override
-Wsuggest-final-types
-Wsuggest-final-methods
-pedantic
)
include_directories(
${CMAKE_SOURCE_DIR}
)
link_directories(
${CMAKE_SOURCE_DIR}
)
# list of modules to build final firmware
add_executable(${PROJECT_NAME}
src/main.cpp
src/startup/startup.cpp
src/startup/stack.cpp
src/startup/handlers_cm.cpp
)
target_link_libraries(${PROJECT_NAME}
${CPU_OPTIONS}
-T${LINKER_SCRIPT}
-nostartfiles
m
# -nostdlib
)
set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_DEPENDS ${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT})
include("cmake/flash.cmake")