2026-02-03 6:35 AM - last edited on 2026-02-03 6:46 AM by Andrew Neil
After several days of wasted time trying to understand what was causing this issue, I finally realized that if I use the add_library() command in a CMake file, the build analyzer tool, without any reasonable explanation, searches for the *.map file with the wrong name. Specifically, if my VSCodeSTM32 project is located in the my_folder directory, then the build analyzer tool looks for the file my_folder/build/Debug/my_folder.map instead of my_folder/build/Debug/project_name.map.
I ran into this problem because our project is generated by STM32CubeMX, which uses the add_library() command several times in the cmake/stm32cubemx/CMakeLists.txt file.
This is the piece of code that is causing this issue in my main CMakeLists.txt (look in the attached project)
################################################################################################################
if(true) # <-- Use false to fix this BUG
set(STM32_Drivers_Src
${CMAKE_CURRENT_SOURCE_DIR}/temp.c
)
add_library(stm32cubemx INTERFACE)
# 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)
endif()
################################################################################################################
Attaching a small project that reproduces this bug.