Skip to content

Commit d7a7d44

Browse files
committed
CMake: Refactor WIO_EMW3166 support
Ensure WICED is included for Mbed targets that require it. This also 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 3174a4c commit d7a7d44

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

targets/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
include(../tools/cmake/set_linker_script.cmake)
44

@@ -34,6 +34,8 @@ elseif("STM" IN_LIST MBED_TARGET_LABELS)
3434
add_subdirectory(TARGET_STM)
3535
elseif("TOSHIBA" IN_LIST MBED_TARGET_LABELS)
3636
add_subdirectory(TARGET_TOSHIBA)
37-
elseif("WICED" IN_LIST MBED_TARGET_LABELS)
37+
endif()
38+
39+
if("WICED" IN_LIST MBED_TARGET_LABELS)
3840
add_subdirectory(TARGET_WICED)
3941
endif()
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
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(WIO_EMW3166 INTERFACE)
4+
add_library(mbed-wio-emw3166 INTERFACE)
55

6-
target_sources(WIO_EMW3166
6+
target_sources(mbed-wio-emw3166
77
INTERFACE
88
PeripheralPins.c
99
)
1010

11-
target_include_directories(WIO_EMW3166
11+
target_include_directories(mbed-wio-emw3166
1212
INTERFACE
1313
.
1414
)
1515

16-
target_link_libraries(WIO_EMW3166 INTERFACE STM32F412xG)
16+
target_link_libraries(mbed-wio-emw3166 INTERFACE mbed-wiced mbed-stm32f412xg)
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
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("WIO_EMW3166" IN_LIST MBED_TARGET_LABELS)
5-
if(${MBED_TOOLCHAIN} STREQUAL "ARM")
6-
set(LIB_WICED_DRIVERS TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar)
7-
elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
8-
set(LIB_WICED_DRIVERS TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a)
9-
endif()
4+
add_library(mbed-wiced INTERFACE)
5+
6+
if(${MBED_TOOLCHAIN} STREQUAL "ARM")
7+
set(LIB_WICED_DRIVERS TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar)
8+
elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
9+
set(LIB_WICED_DRIVERS TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a)
1010
endif()
1111

12-
target_link_libraries(mbed-core INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_WICED_DRIVERS})
12+
target_link_libraries(mbed-wiced INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_WICED_DRIVERS})
1313

14-
target_include_directories(mbed-core
14+
target_include_directories(mbed-wiced
1515
INTERFACE
1616
wiced_interface
1717
)
1818

19-
target_sources(mbed-core
19+
target_sources(mbed-wiced
2020
INTERFACE
2121
wiced_interface/default_wifi_interface.cpp
2222
)

0 commit comments

Comments
 (0)