Skip to content

Commit 0792beb

Browse files
committed
CMake targets: update mcu variant and linker script after refactor
1 parent c2d32de commit 0792beb

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

docs/porting/target/cmake.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,15 @@ A whole directory can be added to the build using `add_subdirectory()` if it is
105105
See an example below:
106106

107107
```
108-
if("<VENDOR_MCU_VARIANT>" IN_LIST MBED_TARGET_LABELS)
109-
add_subdirectory(TARGET_<VENDOR_MCU_VARIANT>)
110-
endif()
108+
add_subdirectory(TARGET_<VENDOR_MCU_VARIANT> EXCLUDE_FROM_ALL)
111109
112-
target_include_directories(mbed-core
110+
target_include_directories(mbed-<vendor-mcu-variant>
113111
INTERFACE
114112
.
115113
subdirectory
116114
)
117115
118-
target_sources(mbed-core
116+
target_sources(mbed-<vendor-mcu-variant>
119117
INTERFACE
120118
file1.c
121119
@@ -128,17 +126,27 @@ Sources are listed using CMake's `target_sources()` function and added to the `m
128126

129127
### Linker script file
130128

131-
A global CMake property named `MBED_TARGET_LINKER_FILE` must be set for each linker file. This linker file must be listed with its absolute path, this is achieved by adding the sub-path obtained by the CMake variable `${CMAKE_CURRENT_SOURCE_DIR}`.
129+
A function `mbed_set_linker_script` must be invoked for each linker file. The linker file must be listed with its absolute path, this is achieved by adding the sub-path obtained by the CMake variable `${CMAKE_CURRENT_SOURCE_DIR}`.
132130
e.g
133131

134132
```
133+
add_library(mbed-cysbsyskit-01-cm4 INTERFACE)
134+
135135
if(${MBED_TOOLCHAIN} STREQUAL "ARM")
136-
set(LINKER_FILE relative/path/to/TOOLCHAIN_ARM_STD/linker_file.sct)
136+
set(LINKER_FILE_CM4 device/COMPONENT_CM4/TOOLCHAIN_ARM/cy8c6xxa_cm4_dual.sct)
137+
set(STARTUP_FILE_CM4 device/COMPONENT_CM4/TOOLCHAIN_ARM/startup_psoc6_02_cm4.S)
137138
elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
138-
set(LINKER_FILE relative/path/to/TOOLCHAIN_GCC_ARM/linker_file.ld)
139+
set(LINKER_FILE_CM4 device/COMPONENT_CM4/TOOLCHAIN_GCC_ARM/cy8c6xxa_cm4_dual.ld)
140+
set(STARTUP_FILE_CM4 device/COMPONENT_CM4/TOOLCHAIN_GCC_ARM/startup_psoc6_02_cm4.S)
139141
endif()
140142
141-
set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
143+
target_sources(mbed-cysbsyskit-01-cm4
144+
INTERFACE
145+
device/COMPONENT_CM4/system_psoc6_cm4.c
146+
${STARTUP_FILE_CM4}
147+
)
148+
149+
mbed_set_linker_script(mbed-cysbsyskit-01-cm4 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE_CM4})
142150
```
143151

144152
#### ARMClang linker file
@@ -152,7 +160,7 @@ Pre-compiled libraries and object files are listed using CMake's `target_link_li
152160
e.g
153161

154162
```
155-
target_link_libraries(mbed-core
163+
target_link_libraries(mbed-cysbsyskit-01-cm4
156164
INTERFACE
157165
${CMAKE_CURRENT_SOURCE_DIR}/libprecompiled.ar
158166
${CMAKE_CURRENT_SOURCE_DIR}/file_object.o

0 commit comments

Comments
 (0)