cancel
Showing results for 
Search instead for 
Did you mean: 

Build analyzer uses wrong *.map file when CMakeLists.txt uses add_library()

parmi93
Associate II

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.

0 REPLIES 0