-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstm32f4.cmake
More file actions
36 lines (23 loc) · 2.04 KB
/
stm32f4.cmake
File metadata and controls
36 lines (23 loc) · 2.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
include (CMakeForceCompiler)
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_VERSION 1)
# specify the cross compiler
SET(CMAKE_C_COMPILER arm-none-eabi-gcc)
SET(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_SIZE arm-none-eabi-size)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
SET(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/stm32f4.ld)
SET(OPTIMIZATION_LEVEL "s")
set (CMAKE_C_STANDARD 11)
set (CMAKE_CXX_STANDARD 20)
#TODO make things like MCU configurable
SET(DEVICE_FLAGS "-mcpu=cortex-m4 -mthumb -mfloat-abi=soft")
SET(OPTIMIZATIONS_FLAGS "-g3 -O${OPTIMIZATION_LEVEL} -finline-functions-called-once -funsigned-char -funsigned-bitfields -ffunction-sections -fdata-sections -fdiagnostics-color=always -fno-stack-protector -finline-small-functions -findirect-inlining -fstack-usage")
SET(DEFINES "-DBUILDING_BOOTLOADER -DBOOT_STM32F4 -DSTM32F412xG -DTX_WITH_CANDB=1 -DHSE_VALUE=8000000 -D__weak='__attribute__((weak))' -D__packed='__attribute__((__packed__))'")
SET(VALIDATION_FLAGS "-Werror=switch -Werror=return-type -Werror=stringop-overflow -Werror=parentheses -Wall -Wextra -Wundef -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wcast-align -Wvla -Wmissing-format-attribute -Wuninitialized -Winit-self -Wdouble-promotion -Wstrict-aliasing -Wno-unused-local-typedefs -Wno-unused-function -Wno-unused-parameter -fno-unwind-tables")
SET(CONFIG_FILES "-DUFSEL_CONFIGURATION_FILE=\"<ufsel-configuration.hpp>\"")
# merge all flags
SET(COMMON_FLAGS "${DEVICE_FLAGS} ${OPTIMIZATIONS_FLAGS} ${DEFINES} ${VALIDATION_FLAGS} ${CONFIG_FILES}")
SET(CMAKE_CXX_FLAGS_INIT "${COMMON_FLAGS} -fno-exceptions -fno-rtti -fno-threadsafe-statics -fno-use-cxa-atexit -Wno-volatile")
SET(CMAKE_C_FLAGS_INIT "${COMMON_FLAGS} -Werror=implicit-function-declaration -Werror=int-conversion -Werror=incompatible-pointer-types")
SET(CMAKE_EXE_LINKER_FLAGS_INIT " -O${OPTIMIZATION_LEVEL} -Xlinker -Map=output.map -lm --specs=nosys.specs --specs=nano.specs -ffreestanding -fdiagnostics-color=always -Wl,--gc-sections -ffunction-sections -fdata-sections -T ${LINKER_SCRIPT}")