-
Notifications
You must be signed in to change notification settings - Fork 0
/
STM32CortexM33GCCCrossToolchain.cmake
32 lines (26 loc) · 1.53 KB
/
STM32CortexM33GCCCrossToolchain.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
#[=======================================================================[.rst:
STM32CortexM33GCCCrossToolchain.cmake
----------------------------
This module should never be imported and used in a CMakeLists.txt file at either
build or configuration time. It is only intended to be used as a toolchain specified
either in a preset or with the ``-DCMAKE_TOOLCHAIN_FILE`` command-line option.
It will download the appropriate gcc cross-compiler for arm to
stm32-tools/gcc-arm-embedded and set some basic compile and linker flags (the
CPU flags specified with ``-m``).
#]=======================================================================]
find_package(CrossGCC)
set(CMAKE_SYSTEM_NAME "Generic")
set(CMAKE_FIND_ROOT_PATH "${CMAKE_CURRENT_LIST_DIR}/../vendor")
set(CMAKE_SYSROOT "${CrossGCC_DIR}/${CrossGCC_TRIPLE}")
set(CMAKE_C_COMPILER "${CrossGCC_BINDIR}/${CrossGCC_TRIPLE}-gcc")
set(CMAKE_ASM_COMPILER "${CrossGCC_BINDIR}/${CrossGCC_TRIPLE}-gcc")
set(CMAKE_CXX_COMPILER "${CrossGCC_BINDIR}/${CrossGCC_TRIPLE}-g++")
set(GCC_CROSS_BASE_FLAGS
"-mthumb -mcpu=cortex-m33 -mfloat-abi=hard -specs=nosys.specs -specs=nano.specs -fpic -ffunction-sections -fdata-sections -fno-lto")
set(CMAKE_C_COMPILER_TARGET thumbv8m.main-none-eabi)
set(CMAKE_CXX_COMPILER_TARGET thumbv8m.main-none-eabi)
set(CMAKE_C_FLAGS ${GCC_CROSS_BASE_FLAGS})
set(CMAKE_CXX_FLAGS ${GCC_CROSS_BASE_FLAGS})
set(CMAKE_ASM_FLAGS ${GCC_CROSS_BASE_FLAGS})
set(CMAKE_CROSSCOMPILING_EMULATOR "${CrossGCC_BINDIR}/${CrossGCC_TRIPLE}-gdb")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)