-
Notifications
You must be signed in to change notification settings - Fork 0
/
toolchain_arm_none_eabi_gcc.cmake
44 lines (37 loc) · 1.54 KB
/
toolchain_arm_none_eabi_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
include(CMakeForceCompiler)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR cortex-m4)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
set(CMAKE_SHARED_LINKER_FLAGS "-mthumb -mthumb-interwork -mcpu=cortex-m4")
set(SHARED_C_CXX_FLAGS "-fmessage-length=0 -flto -ffunction-sections -fdata-sections -fno-strict-aliasing -Wall -Wextra")
find_program(ARM_CC arm-none-eabi-gcc)
find_program(ARM_CXX arm-none-eabi-g++)
find_program(ARM_OBJCOPY arm-none-eabi-objcopy)
find_program(ARM_SIZE_TOOL arm-none-eabi-size)
find_program(ARM_AS arm-none-eabi-as)
find_program(ARM_AR arm-none-eabi-ar)
find_program(ARM_RANLIB arm-none-eabi-ranlib)
CMAKE_FORCE_C_COMPILER(${ARM_CC} GNU)
CMAKE_FORCE_CXX_COMPILER(${ARM_CXX} GNU)
set(CMAKE_ASM ${ARM_AS})
set(CMAKE_AR ${ARM_AR})
set(CMAKE_RANLIB ${ARM_RANLIB})
set(CMAKE_C_FLAGS "${SHARED_C_CXX_FLAGS} -std=gnu99")
set(CMAKE_CXX_FLAGS "${SHARED_C_CXX_FLAGS} -std=gnu++11 -pedantic -fno-exceptions -fno-rtti")
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS})
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m4")
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS}"
"${CMAKE_SHARED_LINKER_FLAGS}"
)
else ()
message(WARNING
"Processor not recognised in toolchain file, "
"compiler flags not configured."
)
endif ()
# fix long strings (CMake appends semicolons)
string(REGEX REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "")
set(BUILD_SHARED_LIBS OFF)