From 2a6a840903de3121d30a054f1adb196974f0fbe7 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Fri, 12 Feb 2021 19:09:11 +0000 Subject: [PATCH] CMake: Refactor Nuvoton targets Refactor all Nuvoton 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. --- targets/TARGET_NUVOTON/CMakeLists.txt | 30 +++++------- .../TARGET_M2351/CMakeLists.txt | 20 ++++---- .../TARGET_M2351/TARGET_M23_NS/CMakeLists.txt | 46 +++++++++++++++---- .../TARGET_M23_NS/TARGET_TFM/CMakeLists.txt | 7 --- .../TARGET_M23_NS/device/CMakeLists.txt | 14 ------ .../device/TARGET_TFM/CMakeLists.txt | 12 ----- .../TARGET_M2351/TARGET_M23_S/CMakeLists.txt | 21 +++++++-- .../TARGET_M23_S/TARGET_TFM/CMakeLists.txt | 13 ------ .../TARGET_NU_PFM_M2351/CMakeLists.txt | 6 ++- .../TARGET_NUVOTON/TARGET_M251/CMakeLists.txt | 25 ++++++---- .../TARGET_NUMAKER_IOT_M252/CMakeLists.txt | 7 --- .../TARGET_NUVOTON/TARGET_M261/CMakeLists.txt | 25 ++++++---- .../TARGET_NUMAKER_IOT_M263A/CMakeLists.txt | 7 --- .../TARGET_NUVOTON/TARGET_M451/CMakeLists.txt | 17 +++++-- .../TARGET_NUVOTON/TARGET_M480/CMakeLists.txt | 36 +++++++++++---- .../TARGET_NANO100/CMakeLists.txt | 16 +++++-- .../device/TOOLCHAIN_ARM/NANO130.sct | 2 +- .../TARGET_NUC472/CMakeLists.txt | 30 ++++++++---- 18 files changed, 186 insertions(+), 148 deletions(-) delete mode 100644 targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/TARGET_TFM/CMakeLists.txt delete mode 100644 targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/device/CMakeLists.txt delete mode 100644 targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/device/TARGET_TFM/CMakeLists.txt delete mode 100644 targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_S/TARGET_TFM/CMakeLists.txt delete mode 100644 targets/TARGET_NUVOTON/TARGET_M251/TARGET_NUMAKER_IOT_M252/CMakeLists.txt delete mode 100644 targets/TARGET_NUVOTON/TARGET_M261/TARGET_NUMAKER_IOT_M263A/CMakeLists.txt diff --git a/targets/TARGET_NUVOTON/CMakeLists.txt b/targets/TARGET_NUVOTON/CMakeLists.txt index 8d6e31bb5b..0c65abd283 100644 --- a/targets/TARGET_NUVOTON/CMakeLists.txt +++ b/targets/TARGET_NUVOTON/CMakeLists.txt @@ -1,28 +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("M2351" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_M2351) -elseif("M251" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_M251) -elseif("M261" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_M261) -elseif("M451" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_M451) -elseif("M480" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_M480) -elseif("NANO100" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_NANO100) -elseif("NUC472" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_NUC472) -endif() +add_library(mbed-nuvoton INTERFACE) -target_include_directories(mbed-core +add_subdirectory(TARGET_M2351 EXCLUDE_FROM_ALL) +add_subdirectory(TARGET_M251 EXCLUDE_FROM_ALL) +add_subdirectory(TARGET_M261 EXCLUDE_FROM_ALL) +add_subdirectory(TARGET_M451 EXCLUDE_FROM_ALL) +add_subdirectory(TARGET_M480 EXCLUDE_FROM_ALL) +add_subdirectory(TARGET_NANO100 EXCLUDE_FROM_ALL) +add_subdirectory(TARGET_NUC472 EXCLUDE_FROM_ALL) + +target_include_directories(mbed-nuvoton INTERFACE . ) -target_sources(mbed-core +target_sources(mbed-nuvoton INTERFACE nu_miscutil.c nu_modutil.c diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M2351/CMakeLists.txt index 205841886b..a6235ed175 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/CMakeLists.txt +++ b/targets/TARGET_NUVOTON/TARGET_M2351/CMakeLists.txt @@ -1,15 +1,13 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. +# Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if("M23_NS" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_M23_NS) -elseif("M23_S" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_M23_S) -elseif("NU_PFM_M2351" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_NU_PFM_M2351) -endif() +add_subdirectory(TARGET_M23_NS EXCLUDE_FROM_ALL) +add_subdirectory(TARGET_M23_S EXCLUDE_FROM_ALL) +add_subdirectory(TARGET_NU_PFM_M2351 EXCLUDE_FROM_ALL) -target_sources(mbed-core +add_library(mbed-m2351 INTERFACE) + +target_sources(mbed-m2351 INTERFACE dma_api.c flash_api.c @@ -80,7 +78,7 @@ target_sources(mbed-core device/startup_M2351.c ) -target_include_directories(mbed-core +target_include_directories(mbed-m2351 INTERFACE . device @@ -88,3 +86,5 @@ target_include_directories(mbed-core device/StdDriver/inc crypto ) + +target_link_libraries(mbed-m2351 INTERFACE mbed-nuvoton) diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/CMakeLists.txt index 90b258e7db..24d5adb4c2 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/CMakeLists.txt +++ b/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/CMakeLists.txt @@ -1,17 +1,43 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. +# Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if("NU_PFM_M2351_NPSA_NS" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_NU_PFM_M2351_NPSA_NS) -elseif("NU_PFM_M2351_NS" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_NU_PFM_M2351_NS) -elseif("TFM" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_TFM) -endif() +add_library(mbed-nu-pfm-m2351-npsa-ns INTERFACE) +target_link_libraries(mbed-nu-pfm-m2351-npsa-ns + INTERFACE + TARGET_NU_PFM_M2351_NPSA_NS/TARGET_NU_PREBUILD_SECURE/cmse_lib.o +) -add_subdirectory(device) +add_library(mbed-nu-pfm-m2351-ns INTERFACE) +target_link_libraries(mbed-nu-pfm-m2351-ns + INTERFACE + TARGET_NU_PFM_M2351_NS/TARGET_NU_PREBUILD_SECURE/cmse_lib.o +) -target_sources(mbed-core +add_library(mbed-nu-m23-ns-tfm INTERFACE) +target_include_directories(mbed-nu-m23-ns-tfm + INTERFACE + device/TARGET_TFM +) +target_sources(mbed-nu-m23-ns-tfm + INTERFACE + TARGET_TFM/tfm_ns_lock_rtx.c + device/TARGET_TFM/cmsis_nvic_virtual.c +) + + +add_library(mbed-m23-ns INTERFACE) + +target_sources(mbed-m23-ns INTERFACE wait_ns.c ) + +if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") + set(LINKER_FILE device/TOOLCHAIN_GCC_ARM/M2351.ld) +elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") + set(LINKER_FILE device/TOOLCHAIN_ARMC6/M2351.sct) +endif() + +mbed_set_linker_script(mbed-m23-ns ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) + +target_link_libraries(mbed-m23-ns INTERFACE mbed-2351) diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/TARGET_TFM/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/TARGET_TFM/CMakeLists.txt deleted file mode 100644 index 8f8f21b08c..0000000000 --- a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/TARGET_TFM/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -target_sources(mbed-core - INTERFACE - tfm_ns_lock_rtx.c -) diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/device/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/device/CMakeLists.txt deleted file mode 100644 index 922d0d8025..0000000000 --- a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/device/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -if("TFM" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_TFM) -endif() - -if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") - set(LINKER_FILE TOOLCHAIN_GCC_ARM/M2351.ld) -elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") - set(LINKER_FILE TOOLCHAIN_ARMC6/M2351.sct) -endif() - -set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/device/TARGET_TFM/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/device/TARGET_TFM/CMakeLists.txt deleted file mode 100644 index 87df1a7319..0000000000 --- a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/device/TARGET_TFM/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -target_sources(mbed-core - INTERFACE - cmsis_nvic_virtual.c -) - -target_include_directories(mbed-core - INTERFACE - . -) diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_S/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_S/CMakeLists.txt index 47a286c86e..673274ff62 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_S/CMakeLists.txt +++ b/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_S/CMakeLists.txt @@ -1,9 +1,18 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. +# Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if("TFM" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_TFM) -endif() +add_library(mbed-nu-m23-s-tfm INTERFACE) +target_include_directories(mbed-nu-m23-s-tfm + INTERFACE + TARGET_TFM +) +target_sources(mbed-nu-m23-s-tfm + INTERFACE + TARGET_TFM/spm_hal.c + TARGET_TFM/target_cfg.cpp +) + +add_library(mbed-m23-s INTERFACE) if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") set(LINKER_FILE device/TOOLCHAIN_GCC_ARM/M2351.ld) @@ -11,4 +20,6 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE device/TOOLCHAIN_ARM_STD/M2351.sct) endif() -set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) +mbed_set_linker_script(mbed-m23-s ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) + +target_link_libraries(mbed-m23-s INTERFACE mbed-2351) diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_S/TARGET_TFM/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_S/TARGET_TFM/CMakeLists.txt deleted file mode 100644 index b92c71eedb..0000000000 --- a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_S/TARGET_TFM/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -target_sources(mbed-core - INTERFACE - target_cfg.cpp - spm_hal.c -) - -target_include_directories(mbed-core - INTERFACE - . -) diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_NU_PFM_M2351/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_NU_PFM_M2351/CMakeLists.txt index 5c029ccc7a..84cba3f5f6 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_NU_PFM_M2351/CMakeLists.txt +++ b/targets/TARGET_NUVOTON/TARGET_M2351/TARGET_NU_PFM_M2351/CMakeLists.txt @@ -1,7 +1,9 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. +# Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -target_include_directories(mbed-core +add_library(mbed-nu-pfm-m2351 INTERFACE) + +target_include_directories(mbed-nu-pfm-m2351 INTERFACE . ) diff --git a/targets/TARGET_NUVOTON/TARGET_M251/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M251/CMakeLists.txt index 68e5c30aac..518c667ee9 100644 --- a/targets/TARGET_NUVOTON/TARGET_M251/CMakeLists.txt +++ b/targets/TARGET_NUVOTON/TARGET_M251/CMakeLists.txt @@ -1,19 +1,15 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. +# Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if("NUMAKER_IOT_M252" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_NUMAKER_IOT_M252) -endif() - if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") set(LINKER_FILE device/TOOLCHAIN_GCC_ARM/M251.ld) elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE device/TOOLCHAIN_ARM_STD/M251.sct) endif() -set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) +add_library(mbed-m251 INTERFACE) -target_sources(mbed-core +target_sources(mbed-m251 INTERFACE analogin_api.c analogout_api.c @@ -66,10 +62,23 @@ target_sources(mbed-core us_ticker.c ) -target_include_directories(mbed-core +target_include_directories(mbed-m251 INTERFACE . device device/Reg device/StdDriver/inc ) + +target_link_libraries(mbed-m251 INTERFACE mbed-nuvoton) + +mbed_set_linker_script(mbed-m251 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) + +add_library(mbed-numaker-iot-m252 INTERFACE) + +target_include_directories(mbed-numaker-iot-m252 + INTERFACE + TARGET_NUMAKER_IOT_M252 +) + +target_link_libraries(mbed-numaker-iot-m252 INTERFACE mbed-m251) diff --git a/targets/TARGET_NUVOTON/TARGET_M251/TARGET_NUMAKER_IOT_M252/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M251/TARGET_NUMAKER_IOT_M252/CMakeLists.txt deleted file mode 100644 index 5c029ccc7a..0000000000 --- a/targets/TARGET_NUVOTON/TARGET_M251/TARGET_NUMAKER_IOT_M252/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -target_include_directories(mbed-core - INTERFACE - . -) diff --git a/targets/TARGET_NUVOTON/TARGET_M261/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M261/CMakeLists.txt index df10fbc39d..eff0d54d33 100644 --- a/targets/TARGET_NUVOTON/TARGET_M261/CMakeLists.txt +++ b/targets/TARGET_NUVOTON/TARGET_M261/CMakeLists.txt @@ -1,19 +1,15 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. +# Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if("NUMAKER_IOT_M263A" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_NUMAKER_IOT_M263A) -endif() - if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") set(LINKER_FILE device/TOOLCHAIN_GCC_ARM/M261.ld) elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE device/TOOLCHAIN_ARM_STD/M261.sct) endif() -set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) +add_library(mbed-m261 INTERFACE) -target_sources(mbed-core +target_sources(mbed-m261 INTERFACE analogin_api.c analogout_api.c @@ -76,7 +72,7 @@ target_sources(mbed-core crypto/crypto-misc.cpp ) -target_include_directories(mbed-core +target_include_directories(mbed-m261 INTERFACE . crypto @@ -84,3 +80,16 @@ target_include_directories(mbed-core device/Reg device/StdDriver/inc ) + +target_link_libraries(mbed-m261 INTERFACE mbed-nuvoton) + +mbed_set_linker_script(mbed-m261 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) + +add_library(mbed-numaker-iot-m263a INTERFACE) + +target_include_directories(mbed-numaker-iot-m263a + INTERFACE + TARGET_NUMAKER_IOT_M263A +) + +target_link_libraries(mbed-numaker-iot-m263a INTERFACE mbed-m261) diff --git a/targets/TARGET_NUVOTON/TARGET_M261/TARGET_NUMAKER_IOT_M263A/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M261/TARGET_NUMAKER_IOT_M263A/CMakeLists.txt deleted file mode 100644 index 5c029ccc7a..0000000000 --- a/targets/TARGET_NUVOTON/TARGET_M261/TARGET_NUMAKER_IOT_M263A/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -target_include_directories(mbed-core - INTERFACE - . -) diff --git a/targets/TARGET_NUVOTON/TARGET_M451/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M451/CMakeLists.txt index 8f84667cdc..19c4d0b2a5 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/CMakeLists.txt +++ b/targets/TARGET_NUVOTON/TARGET_M451/CMakeLists.txt @@ -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 if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") @@ -7,9 +7,9 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE device/TOOLCHAIN_ARM/M453.sct) endif() -set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) +add_library(mbed-m451 INTERFACE) -target_sources(mbed-core +target_sources(mbed-m451 INTERFACE analogin_api.c analogout_api.c @@ -61,9 +61,18 @@ target_sources(mbed-core watchdog_api.c ) -target_include_directories(mbed-core +target_include_directories(mbed-m451 INTERFACE . device device/StdDriver ) + +target_link_libraries(mbed-m451 INTERFACE mbed-nuvoton) + +mbed_set_linker_script(mbed-m451 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) + + +add_library(mbed-numaker-pfm-m453 INTERFACE) + +target_link_libraries(mbed-numaker-pfm-m453 INTERFACE mbed-m451) diff --git a/targets/TARGET_NUVOTON/TARGET_M480/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_M480/CMakeLists.txt index 9dba07afad..18b88a02e9 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/CMakeLists.txt +++ b/targets/TARGET_NUVOTON/TARGET_M480/CMakeLists.txt @@ -1,21 +1,15 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. +# Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if("NUMAKER_IOT_M487" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_NUMAKER_IOT_M487) -elseif("NUMAKER_PFM_M487" IN_LIST MBED_TARGET_LABELS) - add_subdirectory(TARGET_NUMAKER_PFM_M487) -endif() - if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") set(LINKER_FILE device/TOOLCHAIN_GCC_ARM/M487.ld) elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE device/TOOLCHAIN_ARM_STD/M487.sct) endif() -set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) +add_library(mbed-m480 INTERFACE) -target_sources(mbed-core +target_sources(mbed-m480 INTERFACE analogin_api.c analogout_api.c @@ -83,7 +77,7 @@ target_sources(mbed-core watchdog_api.c ) -target_include_directories(mbed-core +target_include_directories(mbed-m480 INTERFACE . crypto @@ -91,3 +85,25 @@ target_include_directories(mbed-core device/Reg device/StdDriver/inc ) + +target_link_libraries(mbed-m480 INTERFACE mbed-nuvoton) + +mbed_set_linker_script(mbed-m480 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) + +add_library(mbed-numaker-iot-m487 INTERFACE) + +target_include_directories(mbed-numaker-iot-m487 + INTERFACE + TARGET_NUMAKER_IOT_M487 +) + +target_link_libraries(mbed-numaker-iot-m487 INTERFACE mbed-m480) + +add_library(mbed-numaker-pfm-m487 INTERFACE) + +target_include_directories(mbed-numaker-pfm-m487 + INTERFACE + TARGET_NUMAKER_PFM_M487 +) + +target_link_libraries(mbed-numaker-pfm-m487 INTERFACE mbed-m480) diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_NANO100/CMakeLists.txt index 5cd351edaf..f959a62b65 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/CMakeLists.txt +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/CMakeLists.txt @@ -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 if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") @@ -7,9 +7,9 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE device/TOOLCHAIN_ARM/NANO130.sct) endif() -set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) +add_library(mbed-nano100 INTERFACE) -target_sources(mbed-core +target_sources(mbed-nano100 INTERFACE device/cmsis_nvic.c device/startup_Nano100Series.c @@ -60,9 +60,17 @@ target_sources(mbed-core watchdog_api.c ) -target_include_directories(mbed-core +target_include_directories(mbed-nano100 INTERFACE . device device/StdDriver ) + +target_link_libraries(mbed-nano100 INTERFACE mbed-nuvoton) + +mbed_set_linker_script(mbed-nano100 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) + +add_library(mbed-numaker-pfm-nano130 INTERFACE) + +target_link_libraries(mbed-numaker-pfm-nano130 INTERFACE mbed-nano100) diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/device/TOOLCHAIN_ARM/NANO130.sct b/targets/TARGET_NUVOTON/TARGET_NANO100/device/TOOLCHAIN_ARM/NANO130.sct index 963e4b631a..45397fb41e 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/device/TOOLCHAIN_ARM/NANO130.sct +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/device/TOOLCHAIN_ARM/NANO130.sct @@ -1,4 +1,4 @@ -#! armcc -E +#! armclang -E --target=arm-arm-none-eabi -x c -mcpu=cortex-m0 /* * Copyright (c) 2020, Nuvoton Technology Corporation diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/CMakeLists.txt b/targets/TARGET_NUVOTON/TARGET_NUC472/CMakeLists.txt index 5da522f7ec..c64a4c261c 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/CMakeLists.txt +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/CMakeLists.txt @@ -1,23 +1,31 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. +# Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") if("NU_XRAM_SUPPORTED" IN_LIST MBED_TARGET_LABELS) - set(LINKER_FILE device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_SUPPORTED/NUC472.ld) + set(LINKER_FILE_NU_XRAM_SUPPORTED device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_SUPPORTED/NUC472.ld) elseif("NU_XRAM_UNSUPPORTED" IN_LIST MBED_TARGET_LABELS) - set(LINKER_FILE device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_UNSUPPORTED/NUC472.ld) + set(LINKER_FILE_NU_XRAM_UNSUPPORTED device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_UNSUPPORTED/NUC472.ld) endif() elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") if("NU_XRAM_SUPPORTED" IN_LIST MBED_TARGET_LABELS) - set(LINKER_FILE device/TOOLCHAIN_ARM_STD/TARGET_NU_XRAM_SUPPORTED/NUC472.sct) + set(LINKER_FILE_NU_XRAM_SUPPORTED device/TOOLCHAIN_ARM_STD/TARGET_NU_XRAM_SUPPORTED/NUC472.sct) elseif("NU_XRAM_UNSUPPORTED" IN_LIST MBED_TARGET_LABELS) - set(LINKER_FILE device/TOOLCHAIN_ARM_STD/TARGET_NU_XRAM_UNSUPPORTED/NUC472.sct) + set(LINKER_FILE_NU_XRAM_UNSUPPORTED device/TOOLCHAIN_ARM_STD/TARGET_NU_XRAM_UNSUPPORTED/NUC472.sct) endif() endif() -set_property(GLOBAL PROPERTY MBED_TARGET_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) +add_library(mbed-nu-xram-supported INTERFACE) +mbed_set_linker_script(mbed-nu-xram-supported ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE_NU_XRAM_SUPPORTED}) -target_sources(mbed-core +add_library(mbed-nu-xram-unsupported INTERFACE) +mbed_set_linker_script(mbed-nu-xram-unsupported ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE_NU_XRAM_UNSUPPORTED}) + + + +add_library(mbed-nuc472 INTERFACE) + +target_sources(mbed-nuc472 INTERFACE crypto/crypto-misc.cpp @@ -74,10 +82,16 @@ target_sources(mbed-core watchdog_api.c ) -target_include_directories(mbed-core +target_include_directories(mbed-nuc472 INTERFACE . crypto device device/StdDriver ) + +target_link_libraries(mbed-nuc472 INTERFACE mbed-nuvoton) + +add_library(mbed-numaker-pfm-nuc472 INTERFACE) + +target_link_libraries(mbed-numaker-pfm-nuc472 INTERFACE mbed-nuc472 mbed-nu-xram-supported)