add IAR support for G0 with cmake
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
if (TOOLCHAIN STREQUAL "gcc")
|
||||
list(APPEND TOOLCHAIN_COMMON_FLAGS
|
||||
set(TOOLCHAIN_COMMON_FLAGS
|
||||
-mthumb
|
||||
-mcpu=cortex-m0plus
|
||||
-mfloat-abi=soft
|
||||
)
|
||||
|
||||
set(FREERTOS_PORT GCC_ARM_CM0 CACHE INTERNAL "")
|
||||
else ()
|
||||
# TODO support IAR
|
||||
|
||||
elseif (TOOLCHAIN STREQUAL "iar")
|
||||
set(TOOLCHAIN_COMMON_FLAGS
|
||||
--cpu cortex-m0
|
||||
)
|
||||
|
||||
set(FREERTOS_PORT IAR_ARM_CM0 CACHE INTERNAL "")
|
||||
|
||||
endif ()
|
||||
|
@@ -1,8 +1,8 @@
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
set(CMAKE_ASM_COMPILER "arm-none-eabi-gcc")
|
||||
set(CMAKE_C_COMPILER "arm-none-eabi-gcc")
|
||||
set(CMAKE_CXX_COMPILER "arm-none-eabi-g++")
|
||||
set(CMAKE_ASM_COMPILER "arm-none-eabi-gcc")
|
||||
|
||||
set(CMAKE_SIZE "arm-none-eabi-size" CACHE FILEPATH "")
|
||||
set(CMAKE_OBJCOPY "arm-none-eabi-objcopy" CACHE FILEPATH "")
|
||||
@@ -29,13 +29,13 @@ list(APPEND TOOLCHAIN_COMMON_FLAGS
|
||||
-fno-strict-aliasing
|
||||
)
|
||||
|
||||
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
|
||||
set(TOOLCHAIN_EXE_LINKER_FLAGS
|
||||
-Wl,--print-memory-usage
|
||||
-Wl,--gc-sections
|
||||
-Wl,--cref
|
||||
)
|
||||
|
||||
list(APPEND TOOLCHAIN_WARNING_FLAGS
|
||||
set(TOOLCHAIN_WARNING_FLAGS
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
@@ -62,3 +62,11 @@ list(APPEND TOOLCHAIN_WARNING_FLAGS
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
|
||||
|
||||
# try_compile is cmake test compiling its own example,
|
||||
# pass -nostdlib to skip stdlib linking
|
||||
get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
|
||||
if (IS_IN_TRY_COMPILE)
|
||||
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -nostdlib")
|
||||
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib")
|
||||
endif ()
|
||||
|
34
tools/cmake/toolchain/arm_iar.cmake
Normal file
34
tools/cmake/toolchain/arm_iar.cmake
Normal file
@@ -0,0 +1,34 @@
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
set(CMAKE_C_COMPILER "iccarm")
|
||||
set(CMAKE_CXX_COMPILER "iccarm")
|
||||
set(CMAKE_ASM_COMPILER "iasmarm")
|
||||
|
||||
set(CMAKE_SIZE "size" CACHE FILEPATH "")
|
||||
set(CMAKE_OBJCOPY "ielftool" CACHE FILEPATH "")
|
||||
set(CMAKE_OBJDUMP "iefdumparm" CACHE FILEPATH "")
|
||||
|
||||
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
|
||||
|
||||
# Look for includes and libraries only in the target system prefix.
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
|
||||
# pass TOOLCHAIN_CPU to
|
||||
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_PROCESSOR)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake)
|
||||
|
||||
# enable all possible warnings for building examples
|
||||
list(APPEND TOOLCHAIN_COMMON_FLAGS
|
||||
)
|
||||
|
||||
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
|
||||
)
|
||||
|
||||
list(APPEND TOOLCHAIN_WARNING_FLAGS
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
|
@@ -1,9 +1,10 @@
|
||||
include(CMakePrintHelpers)
|
||||
|
||||
# join the toolchain flags into a single string
|
||||
list(JOIN TOOLCHAIN_COMMON_FLAGS " " TOOLCHAIN_COMMON_FLAGS)
|
||||
|
||||
foreach (LANG IN ITEMS C CXX ASM)
|
||||
# join the toolchain flags into a single string
|
||||
list(APPEND TOOLCHAIN_${LANG}_FLAGS ${TOOLCHAIN_COMMON_FLAGS})
|
||||
list(JOIN TOOLCHAIN_${LANG}_FLAGS " " TOOLCHAIN_${LANG}_FLAGS)
|
||||
set(CMAKE_${LANG}_FLAGS_INIT "${TOOLCHAIN_${LANG}_FLAGS}")
|
||||
set(CMAKE_${LANG}_FLAGS_INIT ${TOOLCHAIN_COMMON_FLAGS})
|
||||
|
||||
#cmake_print_variables(CMAKE_${LANG}_FLAGS_INIT)
|
||||
|
||||
@@ -14,11 +15,3 @@ endforeach ()
|
||||
|
||||
# Linker
|
||||
list(JOIN TOOLCHAIN_EXE_LINKER_FLAGS " " CMAKE_EXE_LINKER_FLAGS_INIT)
|
||||
|
||||
# try_compile is cmake test compiling its own example,
|
||||
# pass -nostdlib to skip stdlib linking
|
||||
get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
|
||||
if (IS_IN_TRY_COMPILE)
|
||||
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -nostdlib")
|
||||
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib")
|
||||
endif ()
|
||||
|
Reference in New Issue
Block a user