cancel
Showing results for 
Search instead for 
Did you mean: 

can't set compiler option in top level CMakeList

dvescovi
Associate III

Not sure if this belongs in CubeMX or STM32 code for VS.

I have a CMAKE project generated from CubeMX.

When I build within VS Code IDE with the STM32 Extension I get several nocent warnings I would like to eliminate.

Some of these are deep in the HAL and/or the generated code produced by CubeMX.

ex:

warning: declaration of 'hrtc' shadows a global declaration
warning: cast increases required alignment of target type [-Wcast-align]
etc.
I tried several modifications to my top level CMakeLists.txt suggested by AI to suppress these warnings but NONE work.
I know this line:
include("cmake/gcc-arm-none-eabi.cmake")
brings in all the gcc compile options but I don't want to modify this file as it gets regenerated every time I do a CubeMX "GENERATE CODE"
 
Things I have tried are:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-shadow")
target_compile_options(my_target PRIVATE -Wno-shadow)
set(MCU_GCC_FLAGS "${MCU_GCC_FLAGS} -Wno-shadow")
add_compile_options(${MCU_GCC_FLAGS})
add_compile_options(-Wno-shadow)
set(CMAKE_C_FLAGS_INIT "-Wno-shadow") include("cmake/gcc-arm-none-eabi.cmake")
add_compile_options("$<$<COMPILE_LANGUAGE:C>:-Wno-shadow>")
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} APPEND PROPERTY COMPILE_OPTIONS -Wno-shadow)
 
NONE of these work.
 
HELP
 

 
 
 
 
 
 
 
0 REPLIES 0