This is broken, as it finds ${FILENAME} in any subdirectory of the current ${CMAKE_CURRENT_LIST_DIR}. Symptoms of the bug include linker errors claiming multiple definitions of memory sections and complaints about missing parameter prefixes:
$ cmake .. && make
Using startup file: /home/user/project/app_stub/startup_stm32l476xx.s;/home/user/project/boot_stub/startup_stm32l476xx.s
Using linkerscript: /home/user/project/app_stub/STM32L476RGTx_FLASH.ld;/home/user/project/boot_stub/STM32L476RGTx_FLASH.ld
Using startup file: /home/user/project/app_stub/startup_stm32l476xx.s;/home/user/project/boot_stub/startup_stm32l476xx.s
Using linkerscript: /home/user/project/app_stub/STM32L476RGTx_FLASH.ld;/home/user/project/boot_stub/STM32L476RGTx_FLASH.ld
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/project/build
Scanning dependencies of target bootloader
[ 1%] Linking C executable bootloader.elf
/opt/gcc-arm-none-eabi-10.3-2022.01/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: CMakeFiles/bootloader.dir/boot_stub/startup_stm32l476xx.s.obj:(.isr_vector+0x0): multiple definition of `g_pfnVectors'; CMakeFiles/bootloader.dir/app_stub/startup_stm32l476xx.s.obj:(.isr_vector+0x0): first defined here
/opt/gcc-arm-none-eabi-10.3-2022.01/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: CMakeFiles/bootloader.dir/boot_stub/startup_stm32l476xx.s.obj: in function `Default_Handler':
/home/user/project/boot_stub/startup_stm32l476xx.s:119: multiple definition of `Default_Handler'; CMakeFiles/bootloader.dir/app_stub/startup_stm32l476xx.s.obj:/home/user/project/app_stub/startup_stm32l476xx.s:120: first defined here
Correct would be:
file(GLOB_RECURSIVE VARNAME "${DIR}/${FILENAME}")
PR incoming, just looking through the code if I missed any.
From 8dd123df128127e76b15b37570ad2d0e74771fba Mon Sep 17 00:00:00 2001
From: Benny Baumann <BenBE@geshi.org>
Date: Tue, 29 Mar 2022 09:56:50 +0200
Subject: [PATCH 1/2] Fix globbing for the startup file
---
cubemx.cmake | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cubemx.cmake b/cubemx.cmake
index 8c9c8a47..30eb16ed 100644
--- a/cubemx.cmake
+++ b/cubemx.cmake
@@ -51,11 +51,11 @@ function(add_startup)
if("${CMX_STARTUP}" STREQUAL "")
# Check if the "Makefile" startupfile is in the source tree
cmx_get(startupfile_makefile CMX_STARTUPFILE)
- file(GLOB_RECURSE CMX_STARTUP ${CMX_CUBEMX_CORE_DIR} ${CMX_STARTUPFILE})
+ file(GLOB_RECURSE CMX_STARTUP "${CMX_CUBEMX_CORE_DIR}/${CMX_STARTUPFILE}")
if("${CMX_STARTUP}" STREQUAL "")
# If not, look for the "STM32CubeIDE" startupfile
cmx_get(startupfile_stm32cubeide CMX_STARTUPFILE)
- file(GLOB_RECURSE CMX_STARTUP ${CMX_CUBEMX_CORE_DIR} ${CMX_STARTUPFILE})
+ file(GLOB_RECURSE CMX_STARTUP "${CMX_CUBEMX_CORE_DIR}/${CMX_STARTUPFILE}")
if("${CMX_STARTUP}" STREQUAL "")
message(FATAL_ERROR "CubeMX startup file not found!")
endif()
--
2.25.1
From d171b0442d722dc66988b7ba2d1a8080b1b44771 Mon Sep 17 00:00:00 2001
From: Benny Baumann <BenBE@geshi.org>
Date: Tue, 29 Mar 2022 10:16:29 +0200
Subject: [PATCH 2/2] Fix globbing for the linker script
---
cubemx.cmake | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/cubemx.cmake b/cubemx.cmake
index 30eb16ed..15f70a87 100644
--- a/cubemx.cmake
+++ b/cubemx.cmake
@@ -73,16 +73,17 @@ function(add_ldscript)
if("${CMX_LDSCRIPT}" STREQUAL "")
# Check if the "Makefile" linkerscript is in the source tree
set(LINKERSCRIPT "${CMX_MCUNAME}_FLASH.ld")
- file(GLOB_RECURSE CMX_LDSCRIPT ${CMX_CUBEMX_CORE_DIR} ${LINKERSCRIPT})
+ file(GLOB_RECURSE CMX_LDSCRIPT "${CMX_CUBEMX_CORE_DIR}/${LINKERSCRIPT}")
if("${CMX_LDSCRIPT}" STREQUAL "")
# If not, look for the "STM32CubeIDE" linkerscript
string(REPLACE "x" "X" LINKERSCRIPT ${LINKERSCRIPT})
- file(GLOB_RECURSE CMX_LDSCRIPT ${CMX_CUBEMX_CORE_DIR} ${LINKERSCRIPT})
+ file(GLOB_RECURSE CMX_LDSCRIPT "${CMX_CUBEMX_CORE_DIR}/${LINKERSCRIPT}")
if("${CMX_LDSCRIPT}" STREQUAL "")
message(FATAL_ERROR "CubeMX linkerscript not found!")
endif()
endif()
endif()
+
message("Using linkerscript: ${CMX_LDSCRIPT}")
set(CMX_LDSCRIPT ${CMX_LDSCRIPT} PARENT_SCOPE)
endfunction()
--
2.25.1
There are several places that do
This is broken, as it finds
${FILENAME}
in any subdirectory of the current${CMAKE_CURRENT_LIST_DIR}
. Symptoms of the bug include linker errors claiming multiple definitions of memory sections and complaints about missing parameter prefixes:Correct would be:
PR incoming, just looking through the code if I missed any.