Skip to content

Commit 8972e73

Browse files
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.
1 parent 8284807 commit 8972e73

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

targets/TARGET_Samsung/CMakeLists.txt

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

4-
if("SIDK_S1SBP6A" IN_LIST MBED_TARGET_LABELS)
5-
add_subdirectory(TARGET_SIDK_S1SBP6A)
6-
elseif("SIDK_S5JS100" IN_LIST MBED_TARGET_LABELS)
7-
add_subdirectory(TARGET_SIDK_S5JS100)
8-
endif()
4+
add_library(mbed-samsung INTERFACE)
5+
6+
add_subdirectory(TARGET_SIDK_S1SBP6A EXCLUDE_FROM_ALL)
7+
add_subdirectory(TARGET_SIDK_S5JS100 EXCLUDE_FROM_ALL)
8+

targets/TARGET_Samsung/TARGET_SIDK_S1SBP6A/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
99
set(STARTUP_FILE device/TOOLCHAIN_GCC_ARM/startup_s1sbp6a.S)
1010
endif()
1111

12-
set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
12+
add_library(mbed-s1sbp6a INTERFACE)
1313

14-
target_include_directories(mbed-core
14+
target_include_directories(mbed-s1sbp6a
1515
INTERFACE
1616
.
1717
device
1818
)
1919

20-
target_sources(mbed-core
20+
target_sources(mbed-s1sbp6a
2121
INTERFACE
2222
PeripheralPins.c
2323
flash_api.c
@@ -42,3 +42,5 @@ target_sources(mbed-core
4242

4343
${STARTUP_FILE}
4444
)
45+
46+
mbed_set_linker_script(mbed-s1sbp6a ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})

targets/TARGET_Samsung/TARGET_SIDK_S5JS100/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
99
set(STARTUP_FILE device/TOOLCHAIN_GCC_ARM/startup_sidk_s5js100.S)
1010
endif()
1111

12-
set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
12+
add_library(mbed-s5js100 INTERFACE)
1313

14-
target_include_directories(mbed-core
14+
target_include_directories(mbed-s5js100
1515
INTERFACE
1616
.
1717
device
@@ -20,7 +20,7 @@ target_include_directories(mbed-core
2020
security_subsystem/drivers
2121
)
2222

23-
target_sources(mbed-core
23+
target_sources(mbed-s5js100
2424
INTERFACE
2525
gpio_api.c
2626
gpio_irq_api.c
@@ -61,3 +61,7 @@ target_sources(mbed-core
6161

6262
${STARTUP_FILE}
6363
)
64+
65+
mbed_set_linker_script(mbed-s5js100 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
66+
67+
target_link_libraries(mbed-s5js100)

0 commit comments

Comments
 (0)