mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-14 04:18:56 +00:00
clang build board test with h743
This commit is contained in:
parent
9f0e4c2889
commit
96f7ca02bf
@ -5,7 +5,6 @@ if (TOOLCHAIN STREQUAL "gcc")
|
||||
-mfloat-abi=hard
|
||||
-mfpu=fpv5-d16
|
||||
)
|
||||
|
||||
set(FREERTOS_PORT GCC_ARM_CM7 CACHE INTERNAL "")
|
||||
|
||||
elseif (TOOLCHAIN STREQUAL "iar")
|
||||
@ -13,7 +12,15 @@ elseif (TOOLCHAIN STREQUAL "iar")
|
||||
--cpu cortex-m7
|
||||
--fpu VFPv5_D16
|
||||
)
|
||||
|
||||
set(FREERTOS_PORT IAR_ARM_CM7 CACHE INTERNAL "")
|
||||
|
||||
elseif (TOOLCHAIN STREQUAL "clang")
|
||||
set(TOOLCHAIN_COMMON_FLAGS
|
||||
--target=arm-none-eabi
|
||||
-mcpu=cortex-m7
|
||||
-mfloat-abi=hard
|
||||
-mfpu=fpv5-d16
|
||||
)
|
||||
set(FREERTOS_PORT GCC_ARM_CM7 CACHE INTERNAL "")
|
||||
|
||||
endif ()
|
||||
|
21
examples/build_system/cmake/toolchain/arm_clang.cmake
Normal file
21
examples/build_system/cmake/toolchain/arm_clang.cmake
Normal file
@ -0,0 +1,21 @@
|
||||
if (NOT DEFINED CMAKE_C_COMPILER)
|
||||
set(CMAKE_C_COMPILER "clang")
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED CMAKE_CXX_COMPILER)
|
||||
set(CMAKE_CXX_COMPILER "clang++")
|
||||
endif ()
|
||||
|
||||
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
|
||||
set(CMAKE_SIZE "llvm-size" CACHE FILEPATH "")
|
||||
set(CMAKE_OBJCOPY "llvm-objcopy" CACHE FILEPATH "")
|
||||
set(CMAKE_OBJDUMP "llvm-objdump" CACHE FILEPATH "")
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/common.cmake)
|
||||
|
||||
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")
|
||||
cmake_print_variables(CMAKE_C_LINK_FLAGS)
|
||||
endif ()
|
@ -37,7 +37,16 @@ elseif (TOOLCHAIN STREQUAL "iar")
|
||||
--diag_suppress=Li065
|
||||
)
|
||||
elseif (TOOLCHAIN STREQUAL "clang")
|
||||
message(FATAL_ERROR "Clang not supported")
|
||||
list(APPEND TOOLCHAIN_COMMON_FLAGS
|
||||
-fdata-sections
|
||||
-ffunction-sections
|
||||
-fno-strict-aliasing
|
||||
)
|
||||
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
|
||||
-Wl,--print-memory-usage
|
||||
-Wl,--gc-sections
|
||||
-Wl,--cref
|
||||
)
|
||||
endif ()
|
||||
|
||||
# join the toolchain flags into a single string
|
||||
|
@ -10,13 +10,22 @@ get_filename_component(TOP ${TOP} ABSOLUTE)
|
||||
# Toolchain
|
||||
# Can be changed via -DTOOLCHAIN=gcc|iar or -DCMAKE_C_COMPILER=
|
||||
#-------------------------------------------------------------
|
||||
# Detect toolchain based on CMAKE_C_COMPILER
|
||||
if (DEFINED CMAKE_C_COMPILER)
|
||||
string(FIND ${CMAKE_C_COMPILER} "iccarm" IS_IAR)
|
||||
string(FIND ${CMAKE_C_COMPILER} "clang" IS_CLANG)
|
||||
string(FIND ${CMAKE_C_COMPILER} "gcc" IS_GCC)
|
||||
|
||||
if (NOT IS_IAR EQUAL -1)
|
||||
set(TOOLCHAIN iar)
|
||||
elseif (NOT IS_CLANG EQUAL -1)
|
||||
set(TOOLCHAIN clang)
|
||||
elseif (NOT IS_GCC EQUAL -1)
|
||||
set(TOOLCHAIN gcc)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# default to gcc
|
||||
if (NOT DEFINED TOOLCHAIN)
|
||||
set(TOOLCHAIN gcc)
|
||||
endif ()
|
||||
|
@ -29,6 +29,7 @@ function(add_board_target BOARD_TARGET)
|
||||
if (NOT TARGET ${BOARD_TARGET})
|
||||
# Startup & Linker script
|
||||
set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
|
||||
|
||||
if(NOT DEFINED LD_FILE_IAR)
|
||||
@ -72,6 +73,10 @@ function(add_board_target BOARD_TARGET)
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
endfunction()
|
||||
|
Loading…
x
Reference in New Issue
Block a user