add cmake support for msp430
This commit is contained in:
52
examples/build_system/cmake/toolchain/msp430_gcc.cmake
Normal file
52
examples/build_system/cmake/toolchain/msp430_gcc.cmake
Normal file
@@ -0,0 +1,52 @@
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
if (NOT DEFINED CMAKE_C_COMPILER)
|
||||
set(CMAKE_C_COMPILER "msp430-elf-gcc")
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED CMAKE_CXX_COMPILER)
|
||||
set(CMAKE_CXX_COMPILER "msp430-elf-g++")
|
||||
endif ()
|
||||
|
||||
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
|
||||
|
||||
set(CMAKE_SIZE "msp430-elf-size" CACHE FILEPATH "")
|
||||
set(CMAKE_OBJCOPY "msp430-elf-objcopy" CACHE FILEPATH "")
|
||||
set(CMAKE_OBJDUMP "msp430-elf-objdump" 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
|
||||
-fdata-sections
|
||||
-ffunction-sections
|
||||
-fsingle-precision-constant
|
||||
-fno-strict-aliasing
|
||||
)
|
||||
|
||||
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
|
||||
-Wl,--print-memory-usage
|
||||
-Wl,--gc-sections
|
||||
-Wl,--cref
|
||||
)
|
||||
|
||||
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 ()
|
Reference in New Issue
Block a user