CMake: refactor Samsung targets

Refactor all Samsung 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.
pull/14276/head
Harrison Mutai 2021-02-12 11:11:31 +00:00
parent 8284807a00
commit 1282242691
3 changed files with 15 additions and 11 deletions

View File

@ -1,8 +1,6 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
if("SIDK_S1SBP6A" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_SIDK_S1SBP6A)
elseif("SIDK_S5JS100" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_SIDK_S5JS100)
endif()
add_subdirectory(TARGET_SIDK_S1SBP6A EXCLUDE_FROM_ALL)
add_subdirectory(TARGET_SIDK_S5JS100 EXCLUDE_FROM_ALL)

View File

@ -9,15 +9,15 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
set(STARTUP_FILE device/TOOLCHAIN_GCC_ARM/startup_s1sbp6a.S)
endif()
set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
add_library(mbed-s1sbp6a INTERFACE)
target_include_directories(mbed-core
target_include_directories(mbed-s1sbp6a
INTERFACE
.
device
)
target_sources(mbed-core
target_sources(mbed-s1sbp6a
INTERFACE
PeripheralPins.c
flash_api.c
@ -42,3 +42,5 @@ target_sources(mbed-core
${STARTUP_FILE}
)
mbed_set_linker_script(mbed-s1sbp6a ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})

View File

@ -9,9 +9,9 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
set(STARTUP_FILE device/TOOLCHAIN_GCC_ARM/startup_sidk_s5js100.S)
endif()
set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
add_library(mbed-s5js100 INTERFACE)
target_include_directories(mbed-core
target_include_directories(mbed-s5js100
INTERFACE
.
device
@ -20,7 +20,7 @@ target_include_directories(mbed-core
security_subsystem/drivers
)
target_sources(mbed-core
target_sources(mbed-s5js100
INTERFACE
gpio_api.c
gpio_irq_api.c
@ -61,3 +61,7 @@ target_sources(mbed-core
${STARTUP_FILE}
)
mbed_set_linker_script(mbed-s5js100 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
target_link_libraries(mbed-s5js100)