Skip to content

Commit ea6955b

Browse files
committed
CMake: Refactor Cypress targets
Refactor all Cypress targets to be CMake buildsystem targets. This removes the need for checking MBED_TARGET_LABELS repeatedly and allows us to be more flexible in the way we include MBED_TARGET source in the build. A side effect of this is it will allow us to support custom targets without breaking the build for 'standard' targets, as we use CMake's standard mechanism for adding build rules to the build system, rather than implementing our own layer of logic to exclude files not needed for the target being built. Using this approach, if an MBED_TARGET is not linked to using target_link_libraries its source files will not be added to the build. This means custom target source can be added to the user's application CMakeLists.txt without polluting the build system when trying to compile for a standard MBED_TARGET.
1 parent c153880 commit ea6955b

File tree

17 files changed

+823
-644
lines changed

17 files changed

+823
-644
lines changed

connectivity/drivers/emac/TARGET_Cypress/COMPONENT_SCL/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ target_include_directories(mbed-emac
99

1010
target_sources(mbed-emac
1111
INTERFACE
12-
interface/SclSTAInterface.cpp
1312
interface/default_wifi_interface.cpp
1413
interface/scl_emac.cpp
14+
interface/SclAccessPoint.cpp
15+
interface/SclSTAInterface.cpp
1516
)

targets/TARGET_Cypress/CMakeLists.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# Copyright (c) 2020 ARM Limited. All rights reserved.
1+
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
if("PSOC6" IN_LIST MBED_TARGET_LABELS)
5-
add_subdirectory(TARGET_PSOC6)
6-
endif()
4+
add_subdirectory(TARGET_PSOC6 EXCLUDE_FROM_ALL)
5+
6+
add_library(mbed-cy-external-wifi-fw INTERFACE)
7+
target_compile_definitions(mbed-cy-external-wifi-fw
8+
INTERFACE
9+
"CY_ENABLE_XIP_PROGRAM"
10+
"CY_STORAGE_WIFI_DATA=\".cy_xip\""
11+
"CY_STORAGE_WIFI_DATA_OUTPUT=cy_xip"
12+
"CY_EXT_WIFI_FW_STORAGE=QSPIF"
13+
)

targets/TARGET_Cypress/TARGET_PSOC6/CMakeLists.txt

Lines changed: 82 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,94 @@
1-
# Copyright (c) 2020 ARM Limited. All rights reserved.
1+
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
if("SCL" IN_LIST MBED_TARGET_LABELS)
5-
add_subdirectory(COMPONENT_SCL EXCLUDE_FROM_ALL)
6-
endif()
4+
add_subdirectory(COMPONENT_SCL EXCLUDE_FROM_ALL)
5+
add_subdirectory(COMPONENT_WHD EXCLUDE_FROM_ALL)
6+
add_subdirectory(common/COMPONENT_WHD EXCLUDE_FROM_ALL)
77

8-
if("WHD" IN_LIST MBED_TARGET_LABELS)
9-
add_subdirectory(COMPONENT_WHD EXCLUDE_FROM_ALL)
10-
add_subdirectory(common/COMPONENT_WHD EXCLUDE_FROM_ALL)
11-
endif()
8+
add_library(mbed-cat1a INTERFACE)
129

13-
if("CAT1A" IN_LIST MBED_TARGET_LABELS)
14-
target_include_directories(mbed-core
15-
INTERFACE
16-
psoc6pdl/devices/COMPONENT_CAT1A/include
17-
psoc6pdl/devices/COMPONENT_CAT1A/include/ip
18-
)
19-
endif()
10+
target_include_directories(mbed-cat1a
11+
INTERFACE
12+
psoc6pdl/devices/COMPONENT_CAT1A/include
13+
psoc6pdl/devices/COMPONENT_CAT1A/include/ip
14+
)
2015

21-
if("CY8CKIT064B0S2_4343W" IN_LIST MBED_TARGET_LABELS)
22-
add_subdirectory(TARGET_CY8CKIT064B0S2_4343W)
23-
elseif("CY8CKIT_062S2_43012" IN_LIST MBED_TARGET_LABELS)
24-
add_subdirectory(TARGET_CY8CKIT_062S2_43012)
25-
elseif("CY8CKIT_062_BLE" IN_LIST MBED_TARGET_LABELS)
26-
add_subdirectory(TARGET_CY8CKIT_062_BLE)
27-
elseif("CY8CKIT_062_WIFI_BT" IN_LIST MBED_TARGET_LABELS)
28-
add_subdirectory(TARGET_CY8CKIT_062_WIFI_BT)
29-
elseif("CY8CPROTO_062S3_4343W" IN_LIST MBED_TARGET_LABELS)
30-
add_subdirectory(TARGET_CY8CPROTO_062S3_4343W)
31-
elseif("CY8CPROTO_062_4343W" IN_LIST MBED_TARGET_LABELS)
32-
add_subdirectory(TARGET_CY8CPROTO_062_4343W)
33-
elseif("CYSBSYSKIT_01" IN_LIST MBED_TARGET_LABELS)
34-
add_subdirectory(TARGET_CYSBSYSKIT_01)
35-
elseif("CYTFM_064B0S2_4343W" IN_LIST MBED_TARGET_LABELS)
36-
add_subdirectory(TARGET_CYTFM_064B0S2_4343W)
37-
elseif("CYW9P62S1_43012EVB_01" IN_LIST MBED_TARGET_LABELS)
38-
add_subdirectory(TARGET_CYW9P62S1_43012EVB_01)
39-
elseif("CYW9P62S1_43438EVB_01" IN_LIST MBED_TARGET_LABELS)
40-
add_subdirectory(TARGET_CYW9P62S1_43438EVB_01)
41-
endif()
16+
add_subdirectory(TARGET_CY8CKIT064B0S2_4343W EXCLUDE_FROM_ALL)
17+
add_subdirectory(TARGET_CY8CKIT_062S2_43012 EXCLUDE_FROM_ALL)
18+
add_subdirectory(TARGET_CY8CKIT_062_BLE EXCLUDE_FROM_ALL)
19+
add_subdirectory(TARGET_CY8CKIT_062_WIFI_BT EXCLUDE_FROM_ALL)
20+
add_subdirectory(TARGET_CY8CPROTO_062S3_4343W EXCLUDE_FROM_ALL)
21+
add_subdirectory(TARGET_CY8CPROTO_062_4343W EXCLUDE_FROM_ALL)
22+
add_subdirectory(TARGET_CYSBSYSKIT_01 EXCLUDE_FROM_ALL)
23+
add_subdirectory(TARGET_CYTFM_064B0S2_4343W EXCLUDE_FROM_ALL)
24+
add_subdirectory(TARGET_CYW9P62S1_43012EVB_01 EXCLUDE_FROM_ALL)
25+
add_subdirectory(TARGET_CYW9P62S1_43438EVB_01 EXCLUDE_FROM_ALL)
4226

4327
add_subdirectory(psoc6csp/abstraction/rtos EXCLUDE_FROM_ALL)
4428

45-
if("CM0P_BLESS" IN_LIST MBED_TARGET_LABELS)
46-
target_sources(mbed-core
47-
INTERFACE
48-
psoc6cm0p/COMPONENT_CM0P_BLESS/psoc6_cm0p_bless.c
49-
)
50-
endif()
51-
52-
if("CM0P_CRYPTO" IN_LIST MBED_TARGET_LABELS)
53-
target_sources(mbed-core
54-
INTERFACE
55-
psoc6cm0p/COMPONENT_CM0P_CRYPTO/psoc6_01_cm0p_crypto.c
56-
psoc6cm0p/COMPONENT_CM0P_CRYPTO/psoc6_02_cm0p_crypto.c
57-
psoc6cm0p/COMPONENT_CM0P_CRYPTO/psoc6_03_cm0p_crypto.c
58-
psoc6cm0p/COMPONENT_CM0P_CRYPTO/psoc6_04_cm0p_crypto.c
59-
)
60-
endif()
29+
add_library(mbed-cm0p-bless INTERFACE)
30+
target_sources(mbed-cm0p-bless
31+
INTERFACE
32+
psoc6cm0p/COMPONENT_CM0P_BLESS/psoc6_cm0p_bless.c
33+
)
6134

62-
if("CM0P_SECURE" IN_LIST MBED_TARGET_LABELS)
63-
target_sources(mbed-core
64-
INTERFACE
65-
psoc6cm0p/COMPONENT_CM0P_SECURE/psoc6_02_cm0p_secure.c
66-
psoc6cm0p/COMPONENT_CM0P_SECURE/psoc6_03_cm0p_secure.c
67-
)
68-
endif()
35+
add_library(mbed-cm0p-crypto INTERFACE)
36+
target_sources(mbed-cm0p-crypto
37+
INTERFACE
38+
psoc6cm0p/COMPONENT_CM0P_CRYPTO/psoc6_01_cm0p_crypto.c
39+
psoc6cm0p/COMPONENT_CM0P_CRYPTO/psoc6_02_cm0p_crypto.c
40+
psoc6cm0p/COMPONENT_CM0P_CRYPTO/psoc6_03_cm0p_crypto.c
41+
psoc6cm0p/COMPONENT_CM0P_CRYPTO/psoc6_04_cm0p_crypto.c
42+
)
6943

70-
if("CM0P_SLEEP" IN_LIST MBED_TARGET_LABELS)
71-
target_sources(mbed-core
72-
INTERFACE
73-
psoc6cm0p/COMPONENT_CM0P_SLEEP/psoc6_01_cm0p_sleep.c
74-
psoc6cm0p/COMPONENT_CM0P_SLEEP/psoc6_02_cm0p_sleep.c
75-
psoc6cm0p/COMPONENT_CM0P_SLEEP/psoc6_03_cm0p_sleep.c
76-
psoc6cm0p/COMPONENT_CM0P_SLEEP/psoc6_04_cm0p_sleep.c
77-
)
78-
endif()
44+
add_library(mbed-cm0p-secure INTERFACE)
45+
target_sources(mbed-cm0p-secure
46+
INTERFACE
47+
psoc6cm0p/COMPONENT_CM0P_SECURE/psoc6_02_cm0p_secure.c
48+
psoc6cm0p/COMPONENT_CM0P_SECURE/psoc6_03_cm0p_secure.c
49+
)
7950

80-
if("UDB_SDIO_P12" IN_LIST MBED_TARGET_LABELS)
81-
target_include_directories(mbed-core
82-
INTERFACE
83-
common/udb-sdio-whd/COMPONENT_UDB_SDIO_P12
84-
)
51+
add_library(mbed-cm0p-sleep INTERFACE)
52+
target_sources(mbed-cm0p-sleep
53+
INTERFACE
54+
psoc6cm0p/COMPONENT_CM0P_SLEEP/psoc6_01_cm0p_sleep.c
55+
psoc6cm0p/COMPONENT_CM0P_SLEEP/psoc6_02_cm0p_sleep.c
56+
psoc6cm0p/COMPONENT_CM0P_SLEEP/psoc6_03_cm0p_sleep.c
57+
psoc6cm0p/COMPONENT_CM0P_SLEEP/psoc6_04_cm0p_sleep.c
58+
)
8559

86-
target_sources(mbed-core
87-
INTERFACE
88-
common/udb-sdio-whd/COMPONENT_UDB_SDIO_P12/SDIO_HOST_cfg.c
89-
)
90-
elseif("UDB_SDIO_P2" IN_LIST MBED_TARGET_LABELS)
91-
target_include_directories(mbed-core
92-
INTERFACE
93-
common/udb-sdio-whd/COMPONENT_UDB_SDIO_P2
94-
)
60+
add_library(mbed-udb-sdio-p12 INTERFACE)
61+
target_include_directories(mbed-udb-sdio-p12
62+
INTERFACE
63+
common/udb-sdio-whd/COMPONENT_UDB_SDIO_P12
64+
)
65+
target_sources(mbed-udb-sdio-p12
66+
INTERFACE
67+
common/udb-sdio-whd/COMPONENT_UDB_SDIO_P12/SDIO_HOST_cfg.c
68+
)
9569

96-
target_sources(mbed-core
97-
INTERFACE
98-
common/udb-sdio-whd/COMPONENT_UDB_SDIO_P2/SDIO_HOST_cfg.c
99-
)
100-
elseif("UDB_SDIO_P9" IN_LIST MBED_TARGET_LABELS)
101-
target_include_directories(mbed-core
102-
INTERFACE
103-
common/udb-sdio-whd/COMPONENT_UDB_SDIO_P9
104-
)
70+
add_library(mbed-udb-sdio-p2 INTERFACE)
71+
target_include_directories(mbed-udb-sdio-p2
72+
INTERFACE
73+
common/udb-sdio-whd/COMPONENT_UDB_SDIO_P2
74+
)
75+
target_sources(mbed-udb-sdio-p2
76+
INTERFACE
77+
common/udb-sdio-whd/COMPONENT_UDB_SDIO_P2/SDIO_HOST_cfg.c
78+
)
10579

106-
target_sources(mbed-core
107-
INTERFACE
108-
common/udb-sdio-whd/COMPONENT_UDB_SDIO_P9/SDIO_HOST_cfg.c
109-
)
110-
endif()
80+
add_library(mbed-udb-sdio-p9 INTERFACE)
81+
target_include_directories(mbed-udb-sdio-p9
82+
INTERFACE
83+
common/udb-sdio-whd/COMPONENT_UDB_SDIO_P9
84+
)
85+
target_sources(mbed-udb-sdio-p9
86+
INTERFACE
87+
common/udb-sdio-whd/COMPONENT_UDB_SDIO_P9/SDIO_HOST_cfg.c
88+
)
11189

112-
target_include_directories(mbed-core
90+
add_library(mbed-psoc6 INTERFACE)
91+
target_include_directories(mbed-psoc6
11392
INTERFACE
11493
.
11594
common
@@ -130,7 +109,7 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
130109
set(ASSEMBLY_ROUTINES psoc6pdl/drivers/source/TOOLCHAIN_GCC_ARM/cy_syslib_gcc.S)
131110
endif()
132111

133-
target_sources(mbed-core
112+
target_sources(mbed-psoc6
134113
INTERFACE
135114
cy_analogin_api.c
136115
cy_analogout_api.c
@@ -300,3 +279,8 @@ target_sources(mbed-core
300279

301280
${ASSEMBLY_ROUTINES}
302281
)
282+
283+
# TODO: Include only if mbed-baremetal is not used
284+
if("CY_RTOS_AWARE" IN_LIST MBED_CONFIG_DEFINITIONS)
285+
target_link_libraries(mbed-psoc6 INTERFACE mbed-cy-rtos mbed-cy-rtx)
286+
endif()
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# Copyright (c) 2020 ARM Limited. All rights reserved.
1+
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
add_library(mbed-cy_psoc6_scl INTERFACE)
4+
add_library(mbed-cy-psoc6-scl INTERFACE)
55

6-
target_include_directories(mbed-cy_psoc6_scl
6+
target_include_directories(mbed-cy-psoc6-scl
77
INTERFACE
88
.
99
inc
1010
src/include
1111
)
1212

13-
target_sources(mbed-cy_psoc6_scl
13+
target_sources(mbed-cy-psoc6-scl
1414
INTERFACE
15-
scl_buffer_api.c
16-
scl_wifi_api.c
15+
src/scl_buffer_api.c
16+
src/scl_wifi_api.c
1717

1818
src/IPC/scl_ipc.c
1919
)

0 commit comments

Comments
 (0)