forked from arduino-cmake/arduino-cmake
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ArduinoToolchainStm32.cmake
66 lines (59 loc) · 3.09 KB
/
ArduinoToolchainStm32.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
#=============================================================================#
# Author: Tomasz Bogdal (QueezyTheGreat)
# Home: https://github.com/queezythegreat/arduino-cmake
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#=============================================================================#
MESSAGE(STATUS "Setting up STM32 arduino cmake environment")
#
IF(NOT PLATFORM_TOOLCHAIN_PATH)
MESSAGE(FATAL_ERROR "PLATFORM_TOOLCHAIN_PATH is not defined !")
ENDIF(NOT PLATFORM_TOOLCHAIN_PATH)
#
LIST(APPEND CMAKE_SYSTEM_PREFIX_PATH "${PLATFORM_TOOLCHAIN_PATH}")
SET(STM32_TOOLCHAIN_PREFIX arm-none-eabi-)
FUNCTION(FATAL_BANNER msg)
MESSAGE(STATUS "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
MESSAGE(STATUS "${msg}")
MESSAGE(STATUS "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
MESSAGE(FATAL_ERROR "${msg}")
ENDFUNCTION(FATAL_BANNER msg)
IF(WIN32)
SET(TOOLCHAIN_SUFFIX ".exe")
ENDIF(WIN32)
#
# Sanity check
#
IF(NOT EXISTS "${PLATFORM_TOOLCHAIN_PATH}/${STM32_TOOLCHAIN_PREFIX}gcc${TOOLCHAIN_SUFFIX}")
FATAL_BANNER( "!! PLATFORM_TOOLCHAIN_PATH does not point to a valid toolchain (arm-none-eabi-gcc....)!! (${PLATFORM_TOOLCHAIN_PATH})")
ENDIF()
#
IF(EXISTS "${PLATFORM_PATH}/boards.txt")
SET(STM32_FLAVOR "RGCLARCK" CACHE INTERNAL "")
ELSE(EXISTS "${PLATFORM_PATH}/boards.txt")
#SET(STM32_FLAVOR "VANILLA" CACHE INTERNAL "")
FATAL_BANNER( "!! PLATFORM_PATH does not point to valid STM32 arduino files!! (${PLATFORM_PATH})")
ENDIF()
#
SET(CMAKE_C_COMPILER_ID "GNU" CACHE INTERNAL "")
SET(CMAKE_CXX_COMPILER_ID "GNU" CACHE INTERNAL "")
#
set(CMAKE_C_COMPILER ${PLATFORM_TOOLCHAIN_PATH}/${STM32_TOOLCHAIN_PREFIX}gcc${TOOLCHAIN_SUFFIX} CACHE PATH "" FORCE)
set(CMAKE_ASM_COMPILER ${PLATFORM_TOOLCHAIN_PATH}/${STM32_TOOLCHAIN_PREFIX}gcc${TOOLCHAIN_SUFFIX} CACHE PATH "" FORCE)
set(CMAKE_CXX_COMPILER ${PLATFORM_TOOLCHAIN_PATH}/${STM32_TOOLCHAIN_PREFIX}g++${TOOLCHAIN_SUFFIX} CACHE PATH "" FORCE)
#set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
# There is probably a cleaner way to do this....
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> -lgcc -Wl,--start-group <OBJECTS> <LINK_LIBRARIES> -Wl,--end-group -o <TARGET> ")
#set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "")
#set(CMAKE_CXX_LINK_FLAGS "" CACHE INTERNAL "")
#set(CMAKE_C_LINK_FLAGS "" CACHE INTERNAL "")
#set(CMAKE_CXX_LINK_EXECUTABLE "echo CXXFLAGS: ${CMAKE_CXX_FLAGS} LINK_FLAGS: <LINK_FLAGS> LINK_LIBRARIES: <LINK_LIBRARIES> OBJECTS: <OBJECTS>")
MESSAGE(STATUS "C compiler ${CMAKE_C_COMPILER}")
MESSAGE(STATUS "C++ compiler ${CMAKE_CXX_COMPILER}")
if (ARDUINO_SDK_PATH)
set(ENV{_ARDUINO_CMAKE_WORKAROUND_ARDUINO_SDK_PATH} "${ARDUINO_SDK_PATH}")
else ()
message(FATAL_ERROR "Could not find Arduino SDK (set ARDUINO_SDK_PATH)!")
endif ()