2024-12-18 8:26 AM
Hi,
I use STM32CubeMX v6.13.0 to generate a CMake project for STM32U5 devices. While code generation the process aborts with following error message:
"The Code is successfully generated under: /home/user/projects/stm32u5_firmware Project language : C but CMakeproject generation have a problem."
cmake_minimum_required(VERSION 3.22)
project(stm32cubemx)
add_library(stm32cubemx INTERFACE)
{{sr:Enable_CMake_lanuages}}
target_compile_definitions(stm32cubemx INTERFACE{{sr:symbols_c_SYMB}}
$<$<CONFIG:Debug>:DEBUG>
)
target_include_directories(stm32cubemx INTERFACE{{sr:include_c_DIRS}}
)
target_sources(stm32cubemx INTERFACE{{sr:sources_SRCS}}
)
target_link_directories(stm32cubemx INTERFACE{{sr:link_DIRS}}
)
target_link_libraries(stm32cubemx INTERFACE{{sr:link_LIBS}}
)
# Validate that STM32CubeMX code is compatible with C standard
if(CMAKE_C_STANDARD LESS 11)
message(ERROR "Generated code requires C11 or higher")
endif()
{{sr:Verify_CPP_STD}}
Using another controller (e.g. STM32F407) everything works fine. Any idea?
Best regards,
Ben
2024-12-19 12:29 AM - edited 2024-12-19 12:40 AM
Hello @BFueldner ,
Thank you for bringing this issue to our attention!
Could you please attach your log file for further investigation of the issue?
KR,
Souhaib
2024-12-19 2:36 AM - edited 2024-12-19 2:39 AM
Hi @Souhaib MAZHOUD,
how does STM32CubeMX generate log files? The only output in the bottom of the window is:
Loading: /home/user/STM32CubeMX/db/plugins/boardmanager/boards/B55_Nucleo_NUCLEO-U5A5ZJ-Q_STM32U5A5ZJ_Board.ioc project
Initializing: STM32U5A5ZJTxQ
See attached the IOC and the CMakeLists.txt. For me it seems that the CMakeProject template did not get the right files to solve the placeholders. In the .mxproject file (renamed in attachment to mxproject.txt) all needed files are listet.
Best regards,
Ben
2024-12-19 11:31 PM
Hello @BFueldner
Thank you for your clarification.
This issue has been raised to the relevant team, and it is tracked by internal ticket 199074.
KR, Souhaib
2025-03-05 2:52 AM
The new STM32CubeMX release 6.14.0 is out, announced with CMake improvements. But the CMake generator seems to get even worse:
cmake_minimum_required(VERSION 3.22)
{{sr:Enable_CMake_lanuages}}
# STM32CubeMX generated symbols (macros)
set(MX_Defines_Syms{{sr:symbols_c_SYMB}}
$<$<CONFIG:Debug>:DEBUG>
)
# STM32CubeMX generated include paths
set(MX_Include_Dirs{{sr:include_c_DIRS}}
)
# STM32CubeMX generated application sources
{{sr:STM32_Application_ToReplace}}
# STM32 HAL/LL Drivers
{{sr:STM32_Drivers_ToReplace}}
# Drivers Midllewares
{{sr:drivers_midllewares}}
# Link directories setup
set(MX_LINK_DIRS
{{sr:link_DIRS}}
)
# Project static libraries
set(MX_LINK_LIBS {{sr:link_LIBS}}
STM32_Drivers
{{sr:list_library}}
)
# Interface library for includes and symbols
add_library(stm32cubemx INTERFACE)
target_include_directories(stm32cubemx INTERFACE ${MX_Include_Dirs})
target_compile_definitions(stm32cubemx INTERFACE ${MX_Defines_Syms})
# Create STM32_Drivers static library
add_library(STM32_Drivers OBJECT)
target_sources(STM32_Drivers PRIVATE ${STM32_Drivers_Src})
target_link_libraries(STM32_Drivers PUBLIC stm32cubemx)
{{sr:Verify_CPP_STD}}
{{sr:add_library_ToReplace}}
# Add STM32CubeMX generated application sources to the project
target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${MX_Application_Src})
# Link directories setup
target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE ${MX_LINK_DIRS})
# Add libraries to the project
target_link_libraries(${CMAKE_PROJECT_NAME} ${MX_LINK_LIBS})
# Add the map file to the list of files to be removed with 'clean' target
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES ADDITIONAL_CLEAN_FILES ${CMAKE_PROJECT_NAME}.map)
# Validate that STM32CubeMX code is compatible with C standard
if((CMAKE_C_STANDARD EQUAL 90) OR (CMAKE_C_STANDARD EQUAL 99))
message(ERROR "Generated code requires C11 or higher")
endif()
When are you planning to finally fix this problem?
Best regards