From d2c9101f60eeaf6fc5af9bbe46417281f37b6191 Mon Sep 17 00:00:00 2001 From: Vishwanath Martur <64204611+vishwamartur@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:53:10 +0530 Subject: [PATCH] CMake: Don't force users to build specific library type Related to #14520 Modify CMakeLists files to allow users to specify the type of library to build without hardcoding OBJECT, STATIC, or shared libs. * Change `add_library` calls in `CMakeLists.txt`, `cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_A/CMakeLists.txt`, `cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_M/CMakeLists.txt`, `connectivity/CMakeLists.txt`, `targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG/CMakeLists.txt`, `targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG11/CMakeLists.txt`, `targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFR32MG12/CMakeLists.txt`, `targets/TARGET_Silicon_Labs/TARGET_SL_RAIL/CMakeLists.txt`, `targets/TARGET_STM/CMakeLists.txt`, `targets/TARGET_STM/TARGET_STM32F0/CMakeLists.txt`, `targets/TARGET_STM/TARGET_STM32F1/CMakeLists.txt`, `targets/TARGET_STM/TARGET_STM32F2/CMakeLists.txt`, `targets/TARGET_STM/TARGET_STM32F3/CMakeLists.txt`, `targets/TARGET_STM/TARGET_STM32F4/CMakeLists.txt`, `targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F407xE/CMakeLists.txt`, `targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F429xG/CMakeLists.txt`, `targets/TARGET_STM/TARGET_STM32F7/CMakeLists.txt`, `targets/TARGET_STM/TARGET_STM32G0/CMakeLists.txt`, `targets/TARGET_STM/TARGET_STM32G4/CMakeLists.txt`, and `targets/TARGET_STM/TARGET_STM32H7/CMakeLists.txt` to use default `add_library` calls with `${CMAKE_LIBRARY_TYPE}`. * Allow users to specify the type of library to build by setting the `CMAKE_LIBRARY_TYPE` variable in their CMake configuration. --- CMakeLists.txt | 28 ++++++------- .../CMSIS/TARGET_CORTEX_A/CMakeLists.txt | 6 +-- .../CMSIS/TARGET_CORTEX_M/CMakeLists.txt | 6 +-- connectivity/CMakeLists.txt | 42 +++++++++---------- targets/TARGET_STM/CMakeLists.txt | 8 ++-- .../TARGET_STM/TARGET_STM32F0/CMakeLists.txt | 8 ++-- .../TARGET_STM/TARGET_STM32F1/CMakeLists.txt | 8 ++-- .../TARGET_STM/TARGET_STM32F2/CMakeLists.txt | 8 ++-- .../TARGET_STM/TARGET_STM32F3/CMakeLists.txt | 8 ++-- .../TARGET_STM/TARGET_STM32F4/CMakeLists.txt | 8 ++-- .../TARGET_STM32F407xE/CMakeLists.txt | 8 ++-- .../TARGET_STM32F429xG/CMakeLists.txt | 10 +++-- .../TARGET_STM/TARGET_STM32F7/CMakeLists.txt | 8 ++-- .../TARGET_STM/TARGET_STM32G0/CMakeLists.txt | 8 ++-- .../TARGET_STM/TARGET_STM32G4/CMakeLists.txt | 8 ++-- .../TARGET_STM/TARGET_STM32H7/CMakeLists.txt | 14 +++---- .../TARGET_EFM32GG/CMakeLists.txt | 16 +++---- .../TARGET_EFM32GG11/CMakeLists.txt | 14 +++---- .../TARGET_EFR32MG12/CMakeLists.txt | 14 +++---- .../TARGET_SL_RAIL/CMakeLists.txt | 7 ++-- 20 files changed, 119 insertions(+), 118 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b3fab59fc05..cf236f94742 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,20 +40,20 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) endif() endif() -add_library(mbed-core INTERFACE) +add_library(mbed-core ${CMAKE_LIBRARY_TYPE}) -add_library(mbed-os INTERFACE) +add_library(mbed-os ${CMAKE_LIBRARY_TYPE}) target_link_libraries(mbed-os - INTERFACE + ${CMAKE_LIBRARY_TYPE} mbed-rtos mbed-core ) -add_library(mbed-baremetal INTERFACE) +add_library(mbed-baremetal ${CMAKE_LIBRARY_TYPE}) target_link_libraries(mbed-baremetal - INTERFACE + ${CMAKE_LIBRARY_TYPE} mbed-core ) # Validate selected C library type @@ -92,7 +92,7 @@ if(${CMAKE_CROSSCOMPILING}) mbed_set_printf_lib(mbed-core ${MBED_PRINTF_LIB}) target_compile_features(mbed-core - INTERFACE + ${CMAKE_LIBRARY_TYPE} c_std_11 cxx_std_14 ) @@ -100,7 +100,7 @@ if(${CMAKE_CROSSCOMPILING}) endif() target_compile_definitions(mbed-core - INTERFACE + ${CMAKE_LIBRARY_TYPE} TARGET_NAME=${MBED_TARGET} ${MBED_TARGET_DEFINITIONS} ${MBED_CONFIG_DEFINITIONS} @@ -110,7 +110,7 @@ if(${CMAKE_CROSSCOMPILING}) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) if(NOT BUILD_GREENTEA_TESTS) target_compile_definitions(${PROJECT_NAME} - INTERFACE + ${CMAKE_LIBRARY_TYPE} MBED_TEST_MODE ) endif() @@ -135,13 +135,13 @@ if(${CMAKE_CROSSCOMPILING}) # for the GCC_ARM and ARM toolchains respectively. if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") target_compile_definitions(mbed-core - INTERFACE + ${CMAKE_LIBRARY_TYPE} TOOLCHAIN_GCC_ARM TOOLCHAIN_GCC ) elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") target_compile_definitions(mbed-core - INTERFACE + ${CMAKE_LIBRARY_TYPE} TOOLCHAIN_ARM ) endif() @@ -149,7 +149,7 @@ endif() # Include mbed.h and config from generate folder target_include_directories(mbed-core - INTERFACE + ${CMAKE_LIBRARY_TYPE} ${CMAKE_CURRENT_SOURCE_DIR} ) @@ -157,8 +157,8 @@ target_include_directories(mbed-core # are spread in different directories can be referenced and can be linked against # by libraries that depend on them. # TODO CMake: Should the source files be moved? -add_library(mbed-device_key INTERFACE) -add_library(mbed-rtos INTERFACE) +add_library(mbed-device_key ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-rtos ${CMAKE_LIBRARY_TYPE}) # Include targets/ first, because any post-build hook needs to be defined # before other parts of Mbed OS can add greentea tests which require @@ -188,7 +188,7 @@ if(${CMAKE_CROSSCOMPILING}) string(REPLACE "_" "-" MBED_TARGET_CONVERTED ${MBED_TARGET_CONVERTED}) string(PREPEND MBED_TARGET_CONVERTED "mbed-") - target_link_libraries(mbed-core INTERFACE ${MBED_TARGET_CONVERTED}) + target_link_libraries(mbed-core ${CMAKE_LIBRARY_TYPE} ${MBED_TARGET_CONVERTED}) endif() # Ninja requires to be forced for response files diff --git a/cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_A/CMakeLists.txt b/cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_A/CMakeLists.txt index cdd29d79f4b..cfa1ec12ed4 100644 --- a/cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_A/CMakeLists.txt +++ b/cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_A/CMakeLists.txt @@ -1,14 +1,14 @@ # Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -add_library(mbed-cmsis-cortex-a INTERFACE) +add_library(mbed-cmsis-cortex-a ${CMAKE_LIBRARY_TYPE}) target_include_directories(mbed-cmsis-cortex-a - INTERFACE + ${CMAKE_LIBRARY_TYPE} Include ) target_sources(mbed-cmsis-cortex-a - INTERFACE + ${CMAKE_LIBRARY_TYPE} Source/irq_ctrl_gic.c ) diff --git a/cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_M/CMakeLists.txt b/cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_M/CMakeLists.txt index b944fe4247a..2845c5c41b2 100644 --- a/cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_M/CMakeLists.txt +++ b/cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_M/CMakeLists.txt @@ -1,14 +1,14 @@ # Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -add_library(mbed-cmsis-cortex-m INTERFACE) +add_library(mbed-cmsis-cortex-m ${CMAKE_LIBRARY_TYPE}) target_include_directories(mbed-cmsis-cortex-m - INTERFACE + ${CMAKE_LIBRARY_TYPE} Include ) target_sources(mbed-cmsis-cortex-m - INTERFACE + ${CMAKE_LIBRARY_TYPE} Source/mbed_tz_context.c ) diff --git a/connectivity/CMakeLists.txt b/connectivity/CMakeLists.txt index 1a3bfd41c47..f76413f2bda 100644 --- a/connectivity/CMakeLists.txt +++ b/connectivity/CMakeLists.txt @@ -2,27 +2,27 @@ # SPDX-License-Identifier: Apache-2.0 # List of all connectivity libraries available. -add_library(mbed-802.15.4-rf INTERFACE) -add_library(mbed-ble INTERFACE) -add_library(mbed-ble-cordio INTERFACE) -add_library(mbed-ble-cordio_ll INTERFACE) -add_library(mbed-cellular INTERFACE) -add_library(mbed-coap INTERFACE) -add_library(mbed-emac INTERFACE) -add_library(mbed-lorawan INTERFACE) -add_library(mbed-lwipstack INTERFACE) -add_library(mbed-mbedtls INTERFACE) -add_library(mbed-nanostack INTERFACE) -add_library(mbed-nanostack-coap_service INTERFACE) -add_library(mbed-nanostack-mbed_mesh_api INTERFACE) -add_library(mbed-nanostack-hal_mbed_cmsis_rtos INTERFACE) -add_library(mbed-nanostack-sal_stack INTERFACE) -add_library(mbed-nanostack-sal_stack-event_loop INTERFACE) -add_library(mbed-nanostack-libservice INTERFACE) -add_library(mbed-netsocket INTERFACE) -add_library(mbed-nfc INTERFACE) -add_library(mbed-ppp INTERFACE) -add_library(mbed-wifi INTERFACE) +add_library(mbed-802.15.4-rf ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-ble ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-ble-cordio ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-ble-cordio_ll ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-cellular ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-coap ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-emac ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-lorawan ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-lwipstack ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-mbedtls ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-nanostack ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-nanostack-coap_service ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-nanostack-mbed_mesh_api ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-nanostack-hal_mbed_cmsis_rtos ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-nanostack-sal_stack ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-nanostack-sal_stack-event_loop ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-nanostack-libservice ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-netsocket ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-nfc ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-ppp ${CMAKE_LIBRARY_TYPE}) +add_library(mbed-wifi ${CMAKE_LIBRARY_TYPE}) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) # Add these subdirectories for tests diff --git a/targets/TARGET_STM/CMakeLists.txt b/targets/TARGET_STM/CMakeLists.txt index eca413e2510..fe5cf9825db 100644 --- a/targets/TARGET_STM/CMakeLists.txt +++ b/targets/TARGET_STM/CMakeLists.txt @@ -18,15 +18,15 @@ add_subdirectory(TARGET_STM32U5 EXCLUDE_FROM_ALL) add_subdirectory(TARGET_STM32WB EXCLUDE_FROM_ALL) add_subdirectory(TARGET_STM32WL EXCLUDE_FROM_ALL) -add_library(mbed-stm INTERFACE) +add_library(mbed-stm ${CMAKE_LIBRARY_TYPE}) target_include_directories(mbed-stm - INTERFACE + ${CMAKE_LIBRARY_TYPE} . ) target_sources(mbed-stm - INTERFACE + ${CMAKE_LIBRARY_TYPE} USBPhy_STM32.cpp analogin_api.c analogout_api.c @@ -53,4 +53,4 @@ target_sources(mbed-stm watchdog_api.c ) -target_link_libraries(mbed-stm INTERFACE mbed-cmsis-cortex-m) +target_link_libraries(mbed-stm ${CMAKE_LIBRARY_TYPE} mbed-cmsis-cortex-m) diff --git a/targets/TARGET_STM/TARGET_STM32F0/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32F0/CMakeLists.txt index cf33302d077..52c7536c2b5 100644 --- a/targets/TARGET_STM/TARGET_STM32F0/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32F0/CMakeLists.txt @@ -7,15 +7,15 @@ add_subdirectory(TARGET_STM32F070xB EXCLUDE_FROM_ALL) add_subdirectory(TARGET_STM32F030x8 EXCLUDE_FROM_ALL) add_subdirectory(STM32Cube_FW EXCLUDE_FROM_ALL) -add_library(mbed-stm32f0 INTERFACE) +add_library(mbed-stm32f0 ${CMAKE_LIBRARY_TYPE}) target_include_directories(mbed-stm32f0 - INTERFACE + ${CMAKE_LIBRARY_TYPE} . ) target_sources(mbed-stm32f0 - INTERFACE + ${CMAKE_LIBRARY_TYPE} analogin_device.c analogout_device.c cmsis_nvic.c @@ -27,4 +27,4 @@ target_sources(mbed-stm32f0 spi_api.c ) -target_link_libraries(mbed-stm32f0 INTERFACE mbed-stm mbed-stm32f0cube-fw) +target_link_libraries(mbed-stm32f0 ${CMAKE_LIBRARY_TYPE} mbed-stm mbed-stm32f0cube-fw) diff --git a/targets/TARGET_STM/TARGET_STM32F1/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32F1/CMakeLists.txt index e8337e0c699..4b720466ff7 100644 --- a/targets/TARGET_STM/TARGET_STM32F1/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32F1/CMakeLists.txt @@ -9,10 +9,10 @@ add_subdirectory(TARGET_STM32F103xE EXCLUDE_FROM_ALL) add_subdirectory(TARGET_STM32F103xG EXCLUDE_FROM_ALL) add_subdirectory(STM32Cube_FW EXCLUDE_FROM_ALL) -add_library(mbed-stm32f1 INTERFACE) +add_library(mbed-stm32f1 ${CMAKE_LIBRARY_TYPE}) target_sources(mbed-stm32f1 - INTERFACE + ${CMAKE_LIBRARY_TYPE} analogin_device.c analogout_device.c flash_api.c @@ -23,8 +23,8 @@ target_sources(mbed-stm32f1 ) target_include_directories(mbed-stm32f1 - INTERFACE + ${CMAKE_LIBRARY_TYPE} . ) -target_link_libraries(mbed-stm32f1 INTERFACE mbed-stm mbed-stm32f1cube-fw) +target_link_libraries(mbed-stm32f1 ${CMAKE_LIBRARY_TYPE} mbed-stm mbed-stm32f1cube-fw) diff --git a/targets/TARGET_STM/TARGET_STM32F2/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32F2/CMakeLists.txt index dd36902e73e..e21adc740e9 100644 --- a/targets/TARGET_STM/TARGET_STM32F2/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32F2/CMakeLists.txt @@ -4,10 +4,10 @@ add_subdirectory(TARGET_STM32F207xG EXCLUDE_FROM_ALL) add_subdirectory(STM32Cube_FW EXCLUDE_FROM_ALL) -add_library(mbed-stm32f2 INTERFACE) +add_library(mbed-stm32f2 ${CMAKE_LIBRARY_TYPE}) target_sources(mbed-stm32f2 - INTERFACE + ${CMAKE_LIBRARY_TYPE} analogin_device.c analogout_device.c flash_api.c @@ -18,7 +18,7 @@ target_sources(mbed-stm32f2 ) target_include_directories(mbed-stm32f2 - INTERFACE + ${CMAKE_LIBRARY_TYPE} . ./STM32Cube_FW ./STM32Cube_FW/CMSIS @@ -26,4 +26,4 @@ target_include_directories(mbed-stm32f2 ./STM32Cube_FW/STM32F2xx_HAL_Driver/Legacy ) -target_link_libraries(mbed-stm32f2 INTERFACE mbed-stm mbed-stm32f2cube-fw) +target_link_libraries(mbed-stm32f2 ${CMAKE_LIBRARY_TYPE} mbed-stm mbed-stm32f2cube-fw) diff --git a/targets/TARGET_STM/TARGET_STM32F3/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32F3/CMakeLists.txt index f1684b7fc6b..f6e31a037a4 100644 --- a/targets/TARGET_STM/TARGET_STM32F3/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32F3/CMakeLists.txt @@ -8,15 +8,15 @@ add_subdirectory(TARGET_STM32F303xE EXCLUDE_FROM_ALL) add_subdirectory(TARGET_STM32F334x8 EXCLUDE_FROM_ALL) add_subdirectory(STM32Cube_FW EXCLUDE_FROM_ALL) -add_library(mbed-stm32f3 INTERFACE) +add_library(mbed-stm32f3 ${CMAKE_LIBRARY_TYPE}) target_include_directories(mbed-stm32f3 - INTERFACE + ${CMAKE_LIBRARY_TYPE} . ) target_sources(mbed-stm32f3 - INTERFACE + ${CMAKE_LIBRARY_TYPE} analogin_device.c analogout_device.c flash_api.c @@ -27,4 +27,4 @@ target_sources(mbed-stm32f3 spi_api.c ) -target_link_libraries(mbed-stm32f3 INTERFACE mbed-stm mbed-stm32f3cube-fw) +target_link_libraries(mbed-stm32f3 ${CMAKE_LIBRARY_TYPE} mbed-stm mbed-stm32f3cube-fw) diff --git a/targets/TARGET_STM/TARGET_STM32F4/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32F4/CMakeLists.txt index 635a578ba8b..80d30f89873 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32F4/CMakeLists.txt @@ -39,15 +39,15 @@ add_subdirectory(TARGET_STM32F479xG EXCLUDE_FROM_ALL) add_subdirectory(STM32Cube_FW EXCLUDE_FROM_ALL) -add_library(mbed-stm32f4 INTERFACE) +add_library(mbed-stm32f4 ${CMAKE_LIBRARY_TYPE}) target_include_directories(mbed-stm32f4 - INTERFACE + ${CMAKE_LIBRARY_TYPE} . ) target_sources(mbed-stm32f4 - INTERFACE + ${CMAKE_LIBRARY_TYPE} analogin_device.c analogout_device.c flash_api.c @@ -57,4 +57,4 @@ target_sources(mbed-stm32f4 spi_api.c ) -target_link_libraries(mbed-stm32f4 INTERFACE mbed-stm mbed-stm32f4cube-fw) +target_link_libraries(mbed-stm32f4 ${CMAKE_LIBRARY_TYPE} mbed-stm mbed-stm32f4cube-fw) diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F407xE/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F407xE/CMakeLists.txt index 89bc7a53157..eb073d65c57 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F407xE/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F407xE/CMakeLists.txt @@ -11,19 +11,19 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE TOOLCHAIN_ARM/stm32f407xe.sct) endif() -add_library(mbed-stm32f407xe INTERFACE) +add_library(mbed-stm32f407xe ${CMAKE_LIBRARY_TYPE}) target_include_directories(mbed-stm32f407xe - INTERFACE + ${CMAKE_LIBRARY_TYPE} . ) target_sources(mbed-stm32f407xe - INTERFACE + ${CMAKE_LIBRARY_TYPE} ${STARTUP_FILE} system_clock.c ) mbed_set_linker_script(mbed-stm32f407xe ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) -target_link_libraries(mbed-stm32f407xe INTERFACE mbed-stm32f4) +target_link_libraries(mbed-stm32f407xe ${CMAKE_LIBRARY_TYPE} mbed-stm32f4) diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F429xG/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F429xG/CMakeLists.txt index 11bf32fe12f..ea3965b4dda 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F429xG/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F429xG/CMakeLists.txt @@ -9,18 +9,20 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE TOOLCHAIN_ARM/stm32f429xg.sct) endif() -add_library(mbed-stm32f429xg INTERFACE) +add_library(mbed-stm32f429xg ${CMAKE_LIBRARY_TYPE}) target_include_directories(mbed-stm32f429xg - INTERFACE + ${CMAKE_LIBRARY_TYPE} . ) target_sources(mbed-stm32f429xg - INTERFACE + ${CMAKE_LIBRARY_TYPE} ${STARTUP_FILE} ) mbed_set_linker_script(mbed-stm32f429xg ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) -target_link_libraries(mbed-stm32f429xg INTERFACE mbed-stm32f4) +target_link_libraries(mbed-stm32f429xg + ${CMAKE_LIBRARY_TYPE} + INTERFACE mbed-stm32f4) diff --git a/targets/TARGET_STM/TARGET_STM32F7/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32F7/CMakeLists.txt index fc81e3bd8d7..9a77466f154 100644 --- a/targets/TARGET_STM/TARGET_STM32F7/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32F7/CMakeLists.txt @@ -8,10 +8,10 @@ add_subdirectory(TARGET_STM32F767xI EXCLUDE_FROM_ALL) add_subdirectory(TARGET_STM32F769xI EXCLUDE_FROM_ALL) add_subdirectory(STM32Cube_FW EXCLUDE_FROM_ALL) -add_library(mbed-stm32f7 INTERFACE) +add_library(mbed-stm32f7 ${CMAKE_LIBRARY_TYPE}) target_sources(mbed-stm32f7 - INTERFACE + ${CMAKE_LIBRARY_TYPE} analogin_device.c analogout_device.c flash_api.c @@ -24,8 +24,8 @@ target_sources(mbed-stm32f7 target_include_directories(mbed-stm32f7 - INTERFACE + ${CMAKE_LIBRARY_TYPE} . ) -target_link_libraries(mbed-stm32f7 INTERFACE mbed-stm mbed-stm32f7cube-fw) +target_link_libraries(mbed-stm32f7 ${CMAKE_LIBRARY_TYPE} mbed-stm mbed-stm32f7cube-fw) diff --git a/targets/TARGET_STM/TARGET_STM32G0/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32G0/CMakeLists.txt index 5b92d4b8a9e..de7d184c69f 100644 --- a/targets/TARGET_STM/TARGET_STM32G0/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32G0/CMakeLists.txt @@ -17,15 +17,15 @@ add_subdirectory(TARGET_STM32G0C1xE EXCLUDE_FROM_ALL) add_subdirectory(STM32Cube_FW EXCLUDE_FROM_ALL) -add_library(mbed-stm32g0 INTERFACE) +add_library(mbed-stm32g0 ${CMAKE_LIBRARY_TYPE}) target_include_directories(mbed-stm32g0 - INTERFACE + ${CMAKE_LIBRARY_TYPE} . ) target_sources(mbed-stm32g0 - INTERFACE + ${CMAKE_LIBRARY_TYPE} analogin_device.c analogout_device.c flash_api.c @@ -36,4 +36,4 @@ target_sources(mbed-stm32g0 spi_api.c ) -target_link_libraries(mbed-stm32g0 INTERFACE mbed-stm mbed-stm32g0cube-fw) +target_link_libraries(mbed-stm32g0 ${CMAKE_LIBRARY_TYPE} mbed-stm mbed-stm32g0cube-fw) diff --git a/targets/TARGET_STM/TARGET_STM32G4/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32G4/CMakeLists.txt index 6808ec840b3..10209b01dad 100644 --- a/targets/TARGET_STM/TARGET_STM32G4/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32G4/CMakeLists.txt @@ -12,10 +12,10 @@ add_subdirectory(TARGET_STM32G491xE EXCLUDE_FROM_ALL) add_subdirectory(TARGET_STM32G4A1xE EXCLUDE_FROM_ALL) add_subdirectory(STM32Cube_FW EXCLUDE_FROM_ALL) -add_library(mbed-stm32g4 INTERFACE) +add_library(mbed-stm32g4 ${CMAKE_LIBRARY_TYPE}) target_sources(mbed-stm32g4 - INTERFACE + ${CMAKE_LIBRARY_TYPE} analogin_device.c analogout_device.c flash_api.c @@ -27,8 +27,8 @@ target_sources(mbed-stm32g4 ) target_include_directories(mbed-stm32g4 - INTERFACE + ${CMAKE_LIBRARY_TYPE} . ) -target_link_libraries(mbed-stm32g4 INTERFACE mbed-stm mbed-stm32g4cube-fw) +target_link_libraries(mbed-stm32g4 ${CMAKE_LIBRARY_TYPE} mbed-stm mbed-stm32g4cube-fw) diff --git a/targets/TARGET_STM/TARGET_STM32H7/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32H7/CMakeLists.txt index 6985c5fe42a..abf9d1779d2 100644 --- a/targets/TARGET_STM/TARGET_STM32H7/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32H7/CMakeLists.txt @@ -13,10 +13,10 @@ add_subdirectory(TARGET_STM32H7A3xIQ EXCLUDE_FROM_ALL) add_subdirectory(TARGET_STM32H7B3xIQ EXCLUDE_FROM_ALL) add_subdirectory(STM32Cube_FW EXCLUDE_FROM_ALL) -add_library(mbed-stm32h7 INTERFACE) +add_library(mbed-stm32h7 ${CMAKE_LIBRARY_TYPE}) target_sources(mbed-stm32h7 - INTERFACE + ${CMAKE_LIBRARY_TYPE} analogin_device.c analogout_device.c flash_api.c @@ -28,18 +28,18 @@ target_sources(mbed-stm32h7 ) target_include_directories(mbed-stm32h7 - INTERFACE + ${CMAKE_LIBRARY_TYPE} . ) -target_link_libraries(mbed-stm32h7 INTERFACE mbed-stm mbed-stm32h7cube-fw) +target_link_libraries(mbed-stm32h7 ${CMAKE_LIBRARY_TYPE} INTERFACE mbed-stm mbed-stm32h7cube-fw) # Add clock file depending on the frequency if("STM32H7_480MHZ" IN_LIST MBED_TARGET_LABELS) - target_sources(mbed-stm32h7 INTERFACE clock_cfg/TARGET_STM32H7_480MHZ/system_clock.c) + target_sources(mbed-stm32h7 ${CMAKE_LIBRARY_TYPE} INTERFACE clock_cfg/TARGET_STM32H7_480MHZ/system_clock.c) elseif("STM32H7_550MHZ" IN_LIST MBED_TARGET_LABELS) - target_sources(mbed-stm32h7 INTERFACE clock_cfg/TARGET_STM32H7_550MHZ/system_clock.c) + target_sources(mbed-stm32h7 ${CMAKE_LIBRARY_TYPE} INTERFACE clock_cfg/TARGET_STM32H7_550MHZ/system_clock.c) elseif("STM32H7_280MHZ" IN_LIST MBED_TARGET_LABELS) - target_sources(mbed-stm32h7 INTERFACE clock_cfg/TARGET_STM32H7_280MHZ/system_clock.c) + target_sources(mbed-stm32h7 ${CMAKE_LIBRARY_TYPE} INTERFACE clock_cfg/TARGET_STM32H7_280MHZ/system_clock.c) endif() diff --git a/targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG/CMakeLists.txt b/targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG/CMakeLists.txt index 09373e280ff..69f849b9df1 100644 --- a/targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG/CMakeLists.txt +++ b/targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -add_library(mbed-1024k INTERFACE) +add_library(mbed-1024k ${CMAKE_LIBRARY_TYPE}) if(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE device/TARGET_1024K/TOOLCHAIN_ARM_STD/efm32gg.sct) @@ -12,12 +12,12 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") endif() target_include_directories(mbed-1024k - INTERFACE + ${CMAKE_LIBRARY_TYPE} device ) target_sources(mbed-1024k - INTERFACE + ${CMAKE_LIBRARY_TYPE} PeripheralPins.c device/system_efm32gg.c @@ -26,15 +26,15 @@ target_sources(mbed-1024k mbed_set_linker_script(mbed-1024k ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) -add_library(mbed-efm32gg990f1024 INTERFACE) +add_library(mbed-efm32gg990f1024 ${CMAKE_LIBRARY_TYPE}) -target_link_libraries(mbed-efm32gg990f1024 INTERFACE mbed-efm32 mbed-1024k) +target_link_libraries(mbed-efm32gg990f1024 ${CMAKE_LIBRARY_TYPE} mbed-efm32 mbed-1024k) -add_library(mbed-efm32gg-stk3700 INTERFACE) +add_library(mbed-efm32gg-stk3700 ${CMAKE_LIBRARY_TYPE}) target_include_directories(mbed-efm32gg-stk3700 - INTERFACE + ${CMAKE_LIBRARY_TYPE} TARGET_EFM32GG_STK3700 ) -target_link_libraries(mbed-efm32gg-stk3700 INTERFACE mbed-efm32gg990f1024) +target_link_libraries(mbed-efm32gg-stk3700 ${CMAKE_LIBRARY_TYPE} mbed-efm32gg990f1024) diff --git a/targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG11/CMakeLists.txt b/targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG11/CMakeLists.txt index 2ae2d9f7ae0..5ffd4d12cf9 100644 --- a/targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG11/CMakeLists.txt +++ b/targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG11/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -add_library(mbed-efm32gg11 INTERFACE) +add_library(mbed-efm32gg11 ${CMAKE_LIBRARY_TYPE}) if(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE device/TOOLCHAIN_ARM_STD/efm32gg11.sct) @@ -12,27 +12,27 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") endif() target_include_directories(mbed-efm32gg11 - INTERFACE + ${CMAKE_LIBRARY_TYPE} device ) target_sources(mbed-efm32gg11 - INTERFACE + ${CMAKE_LIBRARY_TYPE} PeripheralPins.c device/system_efm32gg11b.c ${STARTUP_FILE} ) -target_link_libraries(mbed-efm32gg11 INTERFACE mbed-efm32) +target_link_libraries(mbed-efm32gg11 ${CMAKE_LIBRARY_TYPE} mbed-efm32) mbed_set_linker_script(mbed-efm32gg11 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) -add_library(mbed-efm32gg11-stk3701 INTERFACE) +add_library(mbed-efm32gg11-stk3701 ${CMAKE_LIBRARY_TYPE}) target_include_directories(mbed-efm32gg11-stk3701 - INTERFACE + ${CMAKE_LIBRARY_TYPE} TARGET_EFM32GG11_STK3701 ) -target_link_libraries(mbed-efm32gg11-stk3701 INTERFACE mbed-efm32gg11) +target_link_libraries(mbed-efm32gg11-stk3701 ${CMAKE_LIBRARY_TYPE} mbed-efm32gg11) diff --git a/targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFR32MG12/CMakeLists.txt b/targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFR32MG12/CMakeLists.txt index 8f8f3d1d14a..f9e65faa1b8 100644 --- a/targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFR32MG12/CMakeLists.txt +++ b/targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFR32MG12/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -add_library(mbed-efm32mg12 INTERFACE) +add_library(mbed-efm32mg12 ${CMAKE_LIBRARY_TYPE}) if(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE device/TOOLCHAIN_ARM_STD/efr32mg12p.sct) @@ -12,27 +12,27 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") endif() target_include_directories(mbed-efm32mg12 - INTERFACE + ${CMAKE_LIBRARY_TYPE} device ) target_sources(mbed-efm32mg12 - INTERFACE + ${CMAKE_LIBRARY_TYPE} PeripheralPins.c device/system_efr32mg12p.c ${STARTUP_FILE} ) -target_link_libraries(mbed-efm32mg12 INTERFACE mbed-efm32) +target_link_libraries(mbed-efm32mg12 ${CMAKE_LIBRARY_TYPE} mbed-efm32) mbed_set_linker_script(mbed-efm32mg12 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) -add_library(mbed-tb-sense-12 INTERFACE) +add_library(mbed-tb-sense-12 ${CMAKE_LIBRARY_TYPE}) target_include_directories(mbed-tb-sense-12 - INTERFACE + ${CMAKE_LIBRARY_TYPE} TARGET_TB_SENSE_12 ) -target_link_libraries(mbed-tb-sense-12 INTERFACE mbed-efm32mg12 mbed-sl-rail-efr32-12) +target_link_libraries(mbed-tb-sense-12 ${CMAKE_LIBRARY_TYPE} mbed-efm32mg12 mbed-sl-rail-efr32-12) diff --git a/targets/TARGET_Silicon_Labs/TARGET_SL_RAIL/CMakeLists.txt b/targets/TARGET_Silicon_Labs/TARGET_SL_RAIL/CMakeLists.txt index 08ccd5912d9..42d7233c417 100644 --- a/targets/TARGET_Silicon_Labs/TARGET_SL_RAIL/CMakeLists.txt +++ b/targets/TARGET_Silicon_Labs/TARGET_SL_RAIL/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -add_library(mbed-sl-rail-efr32-12 INTERFACE) +add_library(mbed-sl-rail-efr32-12 ${CMAKE_LIBRARY_TYPE}) if(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LIB_RAIL efr32-rf-driver/rail/TARGET_EFR32_12/librail_efr32xg12_release.ar) @@ -9,11 +9,10 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM") set(LIB_RAIL efr32-rf-driver/rail/TARGET_EFR32_12/librail_efr32xg12_release.a) endif() -target_link_libraries(mbed-sl-rail-efr32-12 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_RAIL}) - +target_link_libraries(mbed-sl-rail-efr32-12 ${CMAKE_LIBRARY_TYPE} ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_RAIL}) target_include_directories(mbed-sl-rail-efr32-12 - INTERFACE + ${CMAKE_LIBRARY_TYPE} efr32-rf-driver/rail efr32-rf-driver/rail/ble efr32-rf-driver/rail/ieee802154