-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMSP430.cmake
More file actions
executable file
·28 lines (23 loc) · 1.18 KB
/
Copy pathMSP430.cmake
File metadata and controls
executable file
·28 lines (23 loc) · 1.18 KB
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
message("Loading MSP430 Toolchain File...")
set(CMAKE_SYSTEM_NAME Generic)
set(TOOLS_ROOT $ENV{HOME}/ti/msp430-gcc)
set(CMAKE_C_COMPILER ${TOOLS_ROOT}/bin/msp430-elf-gcc CACHE STRING "MSP C Compiler")
set(CMAKE_CXX_COMPILER ${TOOLS_ROOT}/bin/msp430-elf-g++ CACHE STRING "MSP C++ Compiler")
set(MSP430_COMPILER_FLAGS "-mtiny-printf" CACHE STRING "MSP Compiler Flags")
set(MSP430_LINKER_FLAGS "-mtiny-printf -Wl,--gc-sections,-Map,\"${PROJECT_NAME}.map\"" CACHE STRING "MSP Linker Flags")
function(msp430_add_executable EXECUTABLE)
if(NOT MSP430_DEVICE_NAME)
message(FATAL_ERROR "Variable named MSP430_DEVICE_NAME not defined - this needs to contain the name of the MSP as shown in MSP compiler install_dir/include/devices.csv!")
endif()
# compile and link elf file
add_executable(${EXECUTABLE} ${ARGN})
set_target_properties(${EXECUTABLE} PROPERTIES
COMPILE_FLAGS "-mmcu=${MSP430_DEVICE_NAME} ${MSP430_COMPILER_FLAGS}"
LINK_FLAGS "-mmcu=${MSP430_DEVICE_NAME} ${MSP430_LINKER_FLAGS}")
target_include_directories(${EXECUTABLE} PRIVATE
${TOOLS_ROOT}/include
)
target_link_directories(${EXECUTABLE} PRIVATE
${TOOLS_ROOT}/include
)
endfunction(msp430_add_executable)