-
Notifications
You must be signed in to change notification settings - Fork 23
/
CMakeLists.txt
87 lines (74 loc) · 1.87 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
cmake_minimum_required(VERSION 3.0)
# project name
project(rt-soldering-pen)
# path to io
set(IO_DIR "")
# select linker script
set(LINKER_SCRIPT ld/stm32f031g6.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}
src
${IO_DIR}
)
link_directories(
${CMAKE_SOURCE_DIR}
src
${IO_DIR}
)
# list of modules to build final firmware (without extension .c or .cpp)
add_executable(${PROJECT_NAME}
${IO_DIR}io/handlers/stack
${IO_DIR}io/handlers/cortexm
${IO_DIR}io/handlers/stm32/f0
${IO_DIR}io/startup/stm32/f0
src/lib/font
src/lib/nv
src/board/hardfault
src/board/systick
# src/board/debug
src/board/i2c
src/board/display
src/meta
src/main
)
target_link_libraries(${PROJECT_NAME}
${CPU_OPTIONS}
-T${LINKER_SCRIPT}
-nostartfiles
# -nostdlib
)
set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_DEPENDS ${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT})
include("cmake/flash.cmake")