From 3d36e28307e46a8f80ad56da6972cc72f5c6bbfd Mon Sep 17 00:00:00 2001 From: Martin Kojtal Date: Tue, 23 Feb 2021 08:26:44 +0000 Subject: [PATCH] CMake: mbed target converted is cached variable --- CMakeLists.txt | 12 +++++++----- cmsis/device/rtos/CMakeLists.txt | 5 ----- events/CMakeLists.txt | 5 ----- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9461e50b8..91afa03a5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,12 @@ cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) include(${MBED_CONFIG_PATH}/mbed_config.cmake) include(tools/cmake/set_linker_script.cmake) +# Ensure the words that make up the Mbed target name are separated with a hyphen, lowercase, and with the `mbed-` prefix. +set(MBED_TARGET_CONVERTED "" CACHE STRING "" FORCE) +string(TOLOWER ${MBED_TARGET} MBED_TARGET_CONVERTED) +string(REPLACE "_" "-" MBED_TARGET_CONVERTED ${MBED_TARGET_CONVERTED}) +string(PREPEND MBED_TARGET_CONVERTED "mbed-") + add_library(mbed-core INTERFACE) add_library(mbed-core-obj OBJECT) @@ -23,6 +29,7 @@ target_link_libraries(mbed-os INTERFACE mbed-rtos mbed-core + ${MBED_TARGET_CONVERTED} ) add_library(mbed-baremetal INTERFACE) @@ -147,11 +154,6 @@ add_subdirectory(features EXCLUDE_FROM_ALL) add_subdirectory(cmsis/CMSIS_5/CMSIS/RTOS2 EXCLUDE_FROM_ALL) add_subdirectory(cmsis/device/rtos EXCLUDE_FROM_ALL) -# Ensure the words that make up the Mbed target name are separated with a hyphen, lowercase, and with the `mbed-` prefix. -string(TOLOWER ${MBED_TARGET} MBED_TARGET_CONVERTED) -string(REPLACE "_" "-" MBED_TARGET_CONVERTED ${MBED_TARGET_CONVERTED}) -string(PREPEND MBED_TARGET_CONVERTED "mbed-") - target_link_libraries(mbed-core-obj PRIVATE ${MBED_TARGET_CONVERTED}) # diff --git a/cmsis/device/rtos/CMakeLists.txt b/cmsis/device/rtos/CMakeLists.txt index d1e59c8b28..6d50dae74b 100644 --- a/cmsis/device/rtos/CMakeLists.txt +++ b/cmsis/device/rtos/CMakeLists.txt @@ -31,9 +31,4 @@ target_compile_definitions(mbed-rtos MBED_CONF_RTOS_PRESENT=1 ) -# Ensure the words that make up the Mbed target name are separated with a hyphen, lowercase, and with the `mbed-` prefix. -string(TOLOWER ${MBED_TARGET} MBED_TARGET_CONVERTED) -string(REPLACE "_" "-" MBED_TARGET_CONVERTED ${MBED_TARGET_CONVERTED}) -string(PREPEND MBED_TARGET_CONVERTED "mbed-") - target_link_libraries(mbed-rtos-obj PRIVATE mbed-core ${MBED_TARGET_CONVERTED}) diff --git a/events/CMakeLists.txt b/events/CMakeLists.txt index 0e5216dcdc..9050aaf2c4 100644 --- a/events/CMakeLists.txt +++ b/events/CMakeLists.txt @@ -32,9 +32,4 @@ foreach(options COMPILE_DEFINITIONS COMPILE_FEATURES COMPILE_OPTIONS INCLUDE_DIR set_target_properties(mbed-events-obj PROPERTIES ${options} $) endforeach() -# Ensure the words that make up the Mbed target name are separated with a hyphen, lowercase, and with the `mbed-` prefix. -string(TOLOWER ${MBED_TARGET} MBED_TARGET_CONVERTED) -string(REPLACE "_" "-" MBED_TARGET_CONVERTED ${MBED_TARGET_CONVERTED}) -string(PREPEND MBED_TARGET_CONVERTED "mbed-") - target_link_libraries(mbed-events-obj PRIVATE mbed-core ${MBED_TARGET_CONVERTED})