stm32-cmake
stm32-cmake copied to clipboard
Full build can occur without linker script or multiple linker scripts
It is possible to build example that won't work because there is no linker script called. Maybe there is a way to force user to either provide a linker script or information that will lead to automatic generation
Blinky example without linker script
if(BLINKY_F4_EXAMPLE)
add_executable(stm32-blinky-f4 blinky.c stm32f4xx_hal_conf.h)
target_link_libraries(stm32-blinky-f4
HAL::STM32::F4::RCC
HAL::STM32::F4::GPIO
HAL::STM32::F4::CORTEX
CMSIS::STM32::F407xx
STM32::NoSys
)
stm32_print_size_of_target(stm32-blinky-f4)
stm32_generate_hex_file(stm32-blinky-f4)
endif()
Notice the use ofCMSIS::STM32::F407xx
instead of CMSIS::STM32::F407VG
Extract of documentation
CMSIS creates the following targets:
CMSIS::STM32::<FAMILY> (e.g. CMSIS::STM32::F4) - common includes, compiler flags and defines for family CMSIS::STM32::<TYPE> (e.g. CMSIS::STM32::F407xx) - common startup source for device type, depends on CMSIS::STM32::<FAMILY> CMSIS::STM32::<DEVICE> (e.g. CMSIS::STM32::F407VG) - linker script for device, depends on CMSIS::STM32::<TYPE>
This will provide 2 linker scripts
CMSIS::STM32::WB55RG::M4
STM32::NoSys
)
stm32_print_size_of_target(stm32-blinky-wb)
stm32_add_linker_script(stm32-blinky-wb PRIVATE stm32wb55xx_flash_cm4.ld)
Should be avoided/warned by cmake
It seems there is still an easy configuration error where no linker file is actually used. Example:
target_link_libraries(targetName
CMSIS::STM32::F103xB
)
Could a CMake warning be added for this case as well?