@@ -22,48 +22,53 @@ set(FAMILY_MCUS KINETIS_K CACHE INTERNAL "")
22
22
#------------------------------------
23
23
# only need to be built ONCE for all examples
24
24
function (add_board_target BOARD_TARGET)
25
- if (NOT TARGET ${BOARD_TARGET} )
26
- add_library (${BOARD_TARGET} STATIC
27
- # driver
28
- ${SDK_DIR} /drivers/gpio/fsl_gpio.c
29
- ${SDK_DIR} /drivers/uart/fsl_uart.c
30
- ${SDK_DIR} /devices/${MCU_VARIANT} /drivers/fsl_clock.c
31
- ${SDK_DIR} /devices/${MCU_VARIANT} /system_${MCU_VARIANT} .c
32
- )
33
- target_compile_definitions (${BOARD_TARGET} PUBLIC
34
- )
35
- target_include_directories (${BOARD_TARGET} PUBLIC
36
- ${CMSIS_DIR} /CMSIS/Core/Include
37
- ${SDK_DIR} /devices/${MCU_VARIANT}
38
- ${SDK_DIR} /devices/${MCU_VARIANT} /drivers
39
- ${SDK_DIR} /drivers/common
40
- ${SDK_DIR} /drivers/gpio
41
- ${SDK_DIR} /drivers/port
42
- ${SDK_DIR} /drivers/smc
43
- ${SDK_DIR} /drivers/sysmpu
44
- ${SDK_DIR} /drivers/uart
45
- )
25
+ if (TARGET ${BOARD_TARGET} )
26
+ return ()
27
+ endif ()
46
28
47
- update_board(${BOARD_TARGET} )
29
+ # LD_FILE and STARTUP_FILE can be defined in board.cmake
30
+ set (LD_FILE_Clang ${LD_FILE_GNU} )
31
+ set (STARTUP_FILE_GNU ${SDK_DIR} /devices/${MCU_VARIANT} /gcc/startup_${MCU_VARIANT} .S)
32
+ set (STARTUP_FILE_Clang ${STARTUP_FILE_GNU} )
33
+
34
+ add_library (${BOARD_TARGET} STATIC
35
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID} }
36
+ ${SDK_DIR} /drivers/gpio/fsl_gpio.c
37
+ ${SDK_DIR} /drivers/uart/fsl_uart.c
38
+ ${SDK_DIR} /devices/${MCU_VARIANT} /drivers/fsl_clock.c
39
+ ${SDK_DIR} /devices/${MCU_VARIANT} /system_${MCU_VARIANT} .c
40
+ )
41
+ target_compile_definitions (${BOARD_TARGET} PUBLIC
42
+ __STARTUP_CLEAR_BSS
43
+ )
44
+ target_include_directories (${BOARD_TARGET} PUBLIC
45
+ ${CMSIS_DIR} /CMSIS/Core/Include
46
+ ${SDK_DIR} /devices/${MCU_VARIANT}
47
+ ${SDK_DIR} /devices/${MCU_VARIANT} /drivers
48
+ ${SDK_DIR} /drivers/common
49
+ ${SDK_DIR} /drivers/gpio
50
+ ${SDK_DIR} /drivers/port
51
+ ${SDK_DIR} /drivers/smc
52
+ ${SDK_DIR} /drivers/sysmpu
53
+ ${SDK_DIR} /drivers/uart
54
+ )
48
55
49
- # LD_FILE and STARTUP_FILE can be defined in board.cmake
50
- set (STARTUP_FILE_GNU ${SDK_DIR} /devices/${MCU_VARIANT} /gcc/startup_${MCU_VARIANT} .S)
56
+ update_board(${BOARD_TARGET} )
51
57
52
- target_sources (${BOARD_TARGET} PUBLIC
53
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID} }
58
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" )
59
+ target_link_options (${BOARD_TARGET} PUBLIC
60
+ "LINKER:--script=${LD_FILE_GNU} "
61
+ --specs=nosys.specs --specs=nano.specs
62
+ -nostartfiles
63
+ )
64
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang" )
65
+ target_link_options (${BOARD_TARGET} PUBLIC
66
+ "LINKER:--script=${LD_FILE_GNU} "
67
+ )
68
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR" )
69
+ target_link_options (${BOARD_TARGET} PUBLIC
70
+ "LINKER:--config=${LD_FILE_IAR} "
54
71
)
55
-
56
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU" )
57
- target_link_options (${BOARD_TARGET} PUBLIC
58
- "LINKER:--script=${LD_FILE_GNU} "
59
- # nanolib
60
- --specs=nosys.specs --specs=nano.specs
61
- )
62
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR" )
63
- target_link_options (${BOARD_TARGET} PUBLIC
64
- "LINKER:--config=${LD_FILE_IAR} "
65
- )
66
- endif ()
67
72
endif ()
68
73
endfunction ()
69
74
0 commit comments