Skip to content

Commit

Permalink
CMake: Refactor WIO_EMW3166 support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hugueskamba committed Feb 12, 2021
1 parent 3174a4c commit d7a7d44
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
6 changes: 4 additions & 2 deletions targets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
include(../tools/cmake/set_linker_script.cmake)

Expand Down Expand Up @@ -34,6 +34,8 @@ elseif("STM" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_STM)
elseif("TOSHIBA" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_TOSHIBA)
elseif("WICED" IN_LIST MBED_TARGET_LABELS)
endif()

if("WICED" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_WICED)
endif()
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

add_library(WIO_EMW3166 INTERFACE)
add_library(mbed-wio-emw3166 INTERFACE)

target_sources(WIO_EMW3166
target_sources(mbed-wio-emw3166
INTERFACE
PeripheralPins.c
)

target_include_directories(WIO_EMW3166
target_include_directories(mbed-wio-emw3166
INTERFACE
.
)

target_link_libraries(WIO_EMW3166 INTERFACE STM32F412xG)
target_link_libraries(mbed-wio-emw3166 INTERFACE mbed-wiced mbed-stm32f412xg)
20 changes: 10 additions & 10 deletions targets/TARGET_WICED/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

if("WIO_EMW3166" IN_LIST MBED_TARGET_LABELS)
if(${MBED_TOOLCHAIN} STREQUAL "ARM")
set(LIB_WICED_DRIVERS TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar)
elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
set(LIB_WICED_DRIVERS TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a)
endif()
add_library(mbed-wiced INTERFACE)

if(${MBED_TOOLCHAIN} STREQUAL "ARM")
set(LIB_WICED_DRIVERS TOOLCHAIN_ARMC6/TARGET_WIO_EMW3166/libwiced_drivers.ar)
elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
set(LIB_WICED_DRIVERS TOOLCHAIN_GCC_ARM/TARGET_WIO_EMW3166/libwiced_drivers.a)
endif()

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

target_include_directories(mbed-core
target_include_directories(mbed-wiced
INTERFACE
wiced_interface
)

target_sources(mbed-core
target_sources(mbed-wiced
INTERFACE
wiced_interface/default_wifi_interface.cpp
)

0 comments on commit d7a7d44

Please sign in to comment.