From 956a8790c12720e81e0a4a10c27defd235b341a7 Mon Sep 17 00:00:00 2001 From: Robert Walton Date: Thu, 11 Feb 2021 13:47:58 +0000 Subject: [PATCH 1/8] Fix DISCO_L4R9I target --- .../TARGET_STM32L4/TARGET_STM32L4R9xI/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L4R9xI/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L4R9xI/CMakeLists.txt index 138cdec45c..d47de667ba 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L4R9xI/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L4R9xI/CMakeLists.txt @@ -11,19 +11,19 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE TOOLCHAIN_ARM/stm32l4r9xi.sct) endif() -add_library(mbed-stm32l4r9xI INTERFACE) +add_library(mbed-stm32l4r9xi INTERFACE) -target_sources(mbed-stm32l4r9xI +target_sources(mbed-stm32l4r9xi INTERFACE system_clock.c ${STARTUP_FILE} ) -target_include_directories(mbed-stm32l4r9xI +target_include_directories(mbed-stm32l4r9xi INTERFACE . ) -mbed_set_linker_script(mbed-stm32l4r9xI ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) +mbed_set_linker_script(mbed-stm32l4r9xi ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) -target_link_libraries(mbed-stm32l4r9xI INTERFACE mbed-stm32l4) +target_link_libraries(mbed-stm32l4r9xi INTERFACE mbed-stm32l4) From f6302dc108959a528124e9249aa23396a71cec77 Mon Sep 17 00:00:00 2001 From: Robert Walton Date: Thu, 11 Feb 2021 13:51:33 +0000 Subject: [PATCH 2/8] Fix NUCLEO_L496ZG_P target --- .../TARGET_STM32L496xG/TARGET_NUCLEO_L496ZG/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/TARGET_NUCLEO_L496ZG/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/TARGET_NUCLEO_L496ZG/CMakeLists.txt index 8cd15528c8..08852bfa34 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/TARGET_NUCLEO_L496ZG/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L496xG/TARGET_NUCLEO_L496ZG/CMakeLists.txt @@ -14,3 +14,7 @@ target_include_directories(mbed-nucleo-l496zg ) target_link_libraries(mbed-nucleo-l496zg INTERFACE mbed-stm32l496xg) + + +add_library(mbed-nucleo-l496zg-p INTERFACE) +target_link_libraries(mbed-nucleo-l496zg-p INTERFACE mbed-nucleo-l496zg) From f2f927ebac1db00681285a39ea9567bf96ac7b19 Mon Sep 17 00:00:00 2001 From: Robert Walton Date: Thu, 11 Feb 2021 14:03:23 +0000 Subject: [PATCH 3/8] Fix NUCLEO_H743ZI2 target --- .../TARGET_NUCLEO_H743ZI2/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H743xI/TARGET_NUCLEO_H743ZI2/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H743xI/TARGET_NUCLEO_H743ZI2/CMakeLists.txt index 30b8f47b60..09d933d1ca 100644 --- a/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H743xI/TARGET_NUCLEO_H743ZI2/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H743xI/TARGET_NUCLEO_H743ZI2/CMakeLists.txt @@ -1,17 +1,17 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -add_library(mbed-nucleo-h743ZI2 INTERFACE) +add_library(mbed-nucleo-h743zi2 INTERFACE) -target_sources(mbed-nucleo-h743ZI2 +target_sources(mbed-nucleo-h743zi2 INTERFACE PeripheralPins.c system_clock.c ) -target_include_directories(mbed-nucleo-h743ZI2 +target_include_directories(mbed-nucleo-h743zi2 INTERFACE . ) -target_link_libraries(mbed-nucleo-h743ZI2 INTERFACE mbed-stm32h743xi) +target_link_libraries(mbed-nucleo-h743zi2 INTERFACE mbed-stm32h743xi) From c82c897e2b273747979630c4dec3e9cf0249db65 Mon Sep 17 00:00:00 2001 From: Robert Walton Date: Thu, 11 Feb 2021 14:28:35 +0000 Subject: [PATCH 4/8] Fix STM32F072xB target --- .../TARGET_STM32F0/TARGET_STM32F072xB/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32F0/TARGET_STM32F072xB/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32F0/TARGET_STM32F072xB/CMakeLists.txt index d7de84b911..ae86a6e62b 100644 --- a/targets/TARGET_STM/TARGET_STM32F0/TARGET_STM32F072xB/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32F0/TARGET_STM32F072xB/CMakeLists.txt @@ -11,19 +11,19 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE TOOLCHAIN_ARM/stm32f072xb.sct) endif() -add_library(mbed-stm32f072xB INTERFACE) +add_library(mbed-stm32f072xb INTERFACE) -target_sources(mbed-stm32f072xB +target_sources(mbed-stm32f072xb INTERFACE system_clock.c ${STARTUP_FILE} ) -target_include_directories(mbed-stm32f072xB +target_include_directories(mbed-stm32f072xb INTERFACE . ) -mbed_set_linker_script(mbed-stm32f072xB ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) +mbed_set_linker_script(mbed-stm32f072xb ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) -target_link_libraries(mbed-stm32f072xB INTERFACE mbed-stm32f0) +target_link_libraries(mbed-stm32f072xb INTERFACE mbed-stm32f0) From ed4027edf07b5e7b1d13046175f846097480fb15 Mon Sep 17 00:00:00 2001 From: Robert Walton Date: Thu, 11 Feb 2021 14:31:49 +0000 Subject: [PATCH 5/8] Fix STM32F103xB target --- .../TARGET_STM32F1/TARGET_STM32F103xB/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32F1/TARGET_STM32F103xB/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32F1/TARGET_STM32F103xB/CMakeLists.txt index 6e71cbefbd..68ba1522da 100644 --- a/targets/TARGET_STM/TARGET_STM32F1/TARGET_STM32F103xB/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32F1/TARGET_STM32F103xB/CMakeLists.txt @@ -11,19 +11,19 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") set(LINKER_FILE TOOLCHAIN_ARM/stm32f103xb.sct) endif() -add_library(mbed-stm32f103xB INTERFACE) +add_library(mbed-stm32f103xb INTERFACE) -target_sources(mbed-stm32f103xB +target_sources(mbed-stm32f103xb INTERFACE system_clock.c ${STARTUP_FILE} ) -target_include_directories(mbed-stm32f103xB +target_include_directories(mbed-stm32f103xb INTERFACE . ) -mbed_set_linker_script(mbed-stm32f103xB ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) +mbed_set_linker_script(mbed-stm32f103xb ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE}) -target_link_libraries(mbed-stm32f103xB INTERFACE mbed-stm32f1) +target_link_libraries(mbed-stm32f103xb INTERFACE mbed-stm32f1) From 91db89143e74ec7cad4377ce76c03eed379b6d3b Mon Sep 17 00:00:00 2001 From: Robert Walton Date: Thu, 11 Feb 2021 14:42:57 +0000 Subject: [PATCH 6/8] Fix FF1705_L151CC target --- .../TARGET_STM32L1/TARGET_XDOT_L151CC/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32L1/TARGET_XDOT_L151CC/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32L1/TARGET_XDOT_L151CC/CMakeLists.txt index 6290a66601..85bff57803 100644 --- a/targets/TARGET_STM/TARGET_STM32L1/TARGET_XDOT_L151CC/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32L1/TARGET_XDOT_L151CC/CMakeLists.txt @@ -32,7 +32,7 @@ target_link_libraries(mbed-xdot-l151cc INTERFACE mbed-stm32l1) # Same target as XDOT_L151CC -add_library(mbed-ff-1705-l151cc INTERFACE) +add_library(mbed-ff1705-l151cc INTERFACE) -target_link_libraries(mbed-xdot-l151cc INTERFACE mbed-xdot-l151cc) +target_link_libraries(mbed-ff1705-l151cc INTERFACE mbed-xdot-l151cc) From 0c7bfe93e3e991f652ca0cd3aeab7d4f16ac412f Mon Sep 17 00:00:00 2001 From: Robert Walton Date: Thu, 11 Feb 2021 15:59:19 +0000 Subject: [PATCH 7/8] CMake: Generate response file before adding mbed-targets We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker script, because of path length limitations on Windows. We set the response file and bind the path to a global property. The MBED_TARGET being built queries this global property when it sets the linker script. We must set this global property before the targets subdirectory is added to the project. This is required because the MBED_TARGET depends on the response file. If the path to the response file is not defined when the target requests it the config definitions will not be passed to CPP. --- CMakeLists.txt | 23 ++++++++++++++--------- tools/cmake/toolchain.cmake | 6 +++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1967c3f65..bd8151bcaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,20 @@ target_compile_definitions(mbed-core ${MBED_CONFIG_DEFINITIONS} ) +# We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker +# script, because of path length limitations on Windows. We set the response file and bind the path +# to a global property here. The MBED_TARGET being built queries this global property when it sets +# the linker script. +# +# We must set this global property before the targets subdirectory is added to the project. This is +# required because the MBED_TARGET depends on the response file. If the path to the response file +# is not defined when the target requests it the config definitions will not be passed to CPP. +# +# TODO: Remove this and find a more idiomatic way of passing compile definitions to CPP without +# using response files or global properties. +mbed_generate_options_for_linker(mbed-core RESPONSE_FILE_PATH) +set_property(GLOBAL PROPERTY COMPILE_DEFS_RESPONSE_FILE ${RESPONSE_FILE_PATH}) + # Add compile definitions for backward compatibility with the toolchain # supported. New source files should instead check for __GNUC__ and __clang__ # for the GCC_ARM and ARM toolchains respectively. @@ -144,15 +158,6 @@ endif() # Note, this function will be removed in the next revisions # function(mbed_configure_app_target target) - # We need to generate a "response file" to pass to the C preprocessor because of path length - # limitations on Windows. We set the response file and bind the path to a global property here. - # We query this global property when we set the linker script for the MBED_TARGET being built. - # - # TODO: Remove this and find a more idiomatic way of passing compile definitions to CPP without - # using global properties. - mbed_generate_options_for_linker(${target} LINKER_PREPROCESS_DEFINITIONS) - set_property(GLOBAL PROPERTY COMPILE_DEFS_RESPONSE_FILE ${LINKER_PREPROCESS_DEFINITIONS}) - # Gcc Arm requires memap to be set with app name, equally to ARMClang # TODO: move this to toolchain and set properly if(MBED_TOOLCHAIN STREQUAL "GCC_ARM") diff --git a/tools/cmake/toolchain.cmake b/tools/cmake/toolchain.cmake index 2472c3d13d..92500e17ed 100644 --- a/tools/cmake/toolchain.cmake +++ b/tools/cmake/toolchain.cmake @@ -2,9 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 # Generate a file containing compile definitions -function(mbed_generate_options_for_linker target definitions_file) +function(mbed_generate_options_for_linker target output_response_file_path) set(_compile_definitions - "$" + "$" ) # Remove macro definitions that contain spaces as the lack of escape sequences and quotation marks @@ -20,7 +20,7 @@ function(mbed_generate_options_for_linker target definitions_file) "$<$:-D$>" ) file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/compile_time_defs.txt" CONTENT "${_compile_definitions}\n") - set(${definitions_file} @${CMAKE_CURRENT_BINARY_DIR}/compile_time_defs.txt PARENT_SCOPE) + set(${output_response_file_path} @${CMAKE_CURRENT_BINARY_DIR}/compile_time_defs.txt PARENT_SCOPE) endfunction() # Set the system processor depending on the CPU core type if (MBED_CPU_CORE STREQUAL Cortex-A9) From fd63d335214a6f69bc7f44fcf3295d7bf1149974 Mon Sep 17 00:00:00 2001 From: Robert Walton Date: Fri, 12 Feb 2021 10:23:03 +0000 Subject: [PATCH 8/8] CMake: Fix STM32G0 target --- targets/TARGET_STM/TARGET_STM32G0/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/TARGET_STM/TARGET_STM32G0/CMakeLists.txt b/targets/TARGET_STM/TARGET_STM32G0/CMakeLists.txt index d9c2b319a0..697a933c3e 100644 --- a/targets/TARGET_STM/TARGET_STM32G0/CMakeLists.txt +++ b/targets/TARGET_STM/TARGET_STM32G0/CMakeLists.txt @@ -27,4 +27,4 @@ target_include_directories(mbed-stm32g0 . ) -target_link_libraries(mbed-stm32g0 INTERFACE mbed-stm mbed-stm32g0cube-few) +target_link_libraries(mbed-stm32g0 INTERFACE mbed-stm mbed-stm32g0cube-fw)