This repository has been archived by the owner on Jan 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stm32l4xx.gcc.cmake
71 lines (56 loc) · 1.85 KB
/
stm32l4xx.gcc.cmake
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
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(ROOT "${CMAKE_SOURCE_DIR}")
#######################################
# paths
#######################################
# GCC path
set(GCC_PATH "${ROOT}/Tools/gcc-arm-none-eabi-8-2019-q3-update/bin")
######################################
# building variables
######################################
# optimization
if (CMAKE_BUILD_TYPE EQUAL "MinSizeRel")
set(OPT "-Os")
elseif (CMAKE_BUILD_TYPE EQUAL "Release")
set(OPT "-O3")
else ()
set(OPT "-Og")
endif ()
#######################################
# binaries
#######################################
set(PREFIX "arm-none-eabi-")
set(CMAKE_CXX_COMPILER "${GCC_PATH}/${PREFIX}g++")
set(CMAKE_C_COMPILER "${GCC_PATH}/${PREFIX}gcc")
set(CMAKE_ASM_COMPILER "${GCC_PATH}/${PREFIX}gcc")
set(CMAKE_OBJCOPY "${GCC_PATH}/${PREFIX}objcopy")
#######################################
# CFLAGS
#######################################
# cpu
set(CPU "-mcpu=cortex-m4")
# fpu
set(FPU "-mfpu=fpv4-sp-d16")
# float-abi
set(FLOAT-ABI "-mfloat-abi=hard")
# mcu
set(MCU "${CPU} -mthumb ${FPU} ${FLOAT-ABI}")
#######################################
# LDFLAGS
#######################################
# libraries
set(LIBS "-lc -lm -lnosys -larm_cortexM4lf_math")
set(LIBDIR "-L${ROOT}/Drivers/CMSIS_5/CMSIS/DSP/Lib/GCC")
# link script
set(LINKER_SCRIPT "${ROOT}/Drivers/CMSIS_5/Device/ST/STM32L4xx/Source/GCC/STM32L475VGTx_FLASH.ld")
#######################################
# GCC flags
#######################################
# compilers
set(COMMON_FLAGS "${MCU} -specs=nosys.specs ${LIBDIR} ${LIBS} ${OPT} -Wall -fdata-sections -ffunction-sections")
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -std=c++11")
set(CMAKE_C_FLAGS "${COMMON_FLAGS} -std=gnu99")
set(CMAKE_ASM_FLAGS "${COMMON_FLAGS} -x assembler-with-cpp")
# linkers
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections -T ${LINKER_SCRIPT}")