Skip to content

Commit c2d32de

Browse files
committed
CMake target: add naming convenction to the picture
1 parent cab2c24 commit c2d32de

File tree

1 file changed

+46
-14
lines changed

1 file changed

+46
-14
lines changed

docs/porting/target/cmake.md

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Note: All the CMake variables above are generated by mbed-tools and their values
1717

1818
We still support mbed-cli 1 and its requirements for the folders naming. To stay backward compatible, we still use the same naming even with CMake.
1919

20+
Each Mbed OS target should be prefixed with `mbed-`. We translate automatically Mbed OS target names from targets.json to CMake targets. A target from targets.json named `CYSBSYSKIT_01` has CMake target `mbed-cysbsyskit-01`.
21+
2022
### Vendor selection
2123

2224
Vendor selection is handled in [`targets/CMakeLists.txt`](https://github.com/ARMmbed/mbed-os/blob/master/targets/CMakeLists.txt). The matching directory is added to directories to build.
@@ -32,35 +34,65 @@ add_subdirectory(TARGET_Cypress EXCLUDE_FROM_ALL)
3234
For example, the content of `targets/TARGET_Cypress/TARGET_PSOC6` can be listed as follows:
3335

3436
```
35-
if("SCL" IN_LIST MBED_TARGET_LABELS)
36-
add_subdirectory(COMPONENT_SCL EXCLUDE_FROM_ALL)
37-
endif()
37+
add_subdirectory(COMPONENT_SCL EXCLUDE_FROM_ALL)
3838
39-
if("WHD" IN_LIST MBED_TARGET_LABELS)
40-
add_subdirectory(COMPONENT_WHD EXCLUDE_FROM_ALL)
41-
add_subdirectory(common/COMPONENT_WHD EXCLUDE_FROM_ALL)
42-
endif()
4339
44-
if("CY8CKIT064B0S2_4343W" IN_LIST MBED_TARGET_LABELS)
45-
add_subdirectory(TARGET_CY8CKIT064B0S2_4343W)
46-
elseif("CY8CKIT_062S2_43012" IN_LIST MBED_TARGET_LABELS)
47-
add_subdirectory(TARGET_CY8CKIT_062S2_43012)
40+
add_subdirectory(COMPONENT_WHD EXCLUDE_FROM_ALL)
41+
add_subdirectory(common/COMPONENT_WHD EXCLUDE_FROM_ALL)
42+
43+
add_subdirectory(TARGET_CY8CKIT064B0S2_4343W EXCLUDE_FROM_ALL)
44+
add_subdirectory(TARGET_CY8CKIT_062S2_43012 EXCLUDE_FROM_ALL)
4845
...
49-
endif()
46+
47+
add_library(mbed-psoc6 INTERFACE)
5048
5149
# Add the include directories accessible from this directory that are not specific to an MCU family or Mbed target
52-
target_include_directories(mbed-core
50+
target_include_directories(mbed-psoc6
5351
INTERFACE
5452
...
5553
)
5654
5755
# Add the source files accessible from this directory that are not specific to an MCU family or Mbed target
58-
target_sources(mbed-core
56+
target_sources(mbed-psoc6
5957
INTERFACE
6058
...
6159
)
6260
```
6361

62+
The board target can link to `mbed-psoc6`. Let's take `mbed-cysbsyskit-01` target:
63+
64+
```
65+
add_library(mbed-cysbsyskit-01 INTERFACE)
66+
67+
target_include_directories(mbed-cysbsyskit-01
68+
INTERFACE
69+
.
70+
device
71+
)
72+
73+
target_sources(mbed-cysbsyskit-01
74+
INTERFACE
75+
PeripheralPins.c
76+
cybsp.c
77+
)
78+
79+
target_link_libraries(mbed-cysbsyskit-01
80+
INTERFACE
81+
mbed-cat1a
82+
mbed-cysbsyskit-01-cm4
83+
mbed-cysbsyskit-01-bsp-design-modus
84+
mbed-psoc6
85+
mbed-cy-psoc6-scl
86+
)
87+
88+
target_compile_definitions(mbed-cysbsyskit-01
89+
INTERFACE
90+
"CY8C624AFNI_S2D43F"
91+
)
92+
93+
mbed_post_build_psoc6_merge_hex("CYSBSYSKIT_01")
94+
```
95+
6496
## Add target's CMakeLists.txt
6597

6698
Add `CMakeLists.txt` files to the top level directory of a given vendor directory. List all files found in the directory in this CMake input source file, adding additional CMake input source file if it is MCU or Mbed target specific and has a great number of files which will make the top level `CMakeLists.txt` too complex. Think when you decide to create functions in a computer software code to remove complexity.

0 commit comments

Comments
 (0)