Skip to content

Commit

Permalink
Set debug DWARF v4 & rm usage of CMAKE_<LANG>_FLAGS_<CONFIG>_INIT.
Browse files Browse the repository at this point in the history
The _INIT variables were introduced in CMake 3.11, and this
project currently supports 3.6+.

The CMAKE_<LANG>_FLAGS_<CONFIG> are reset here instead of using
_INIT, as we want these to be the starting values, overwritting
any CMake defaults.

Debug info set to DWARF v4 because some tooling does not process
v5 yet.
  • Loading branch information
microbit-carlos committed Sep 12, 2023
1 parent efd034a commit fdc9faa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
26 changes: 13 additions & 13 deletions utils/cmake/toolchains/ARM_GCC/compiler-flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@ set(CMAKE_DEPFILE_FLAGS_CXX "-MMD -MT <OBJECT> -MF <DEPFILE>")
set(CMAKE_C_OUTPUT_EXTENSION ".o")
set(CMAKE_DEPFILE_FLAGS_C "-MMD -MT <OBJECT> -MF <DEPFILE>")

set(CMAKE_C_FLAGS_DEBUG_INIT "-g -gdwarf-3")
set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE_INIT "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-Os -g -gdwarf-3 -DNDEBUG")
set(CMAKE_C_FLAGS_DEBUG "-g -gdwarf-4")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -g -gdwarf-4 -DNDEBUG")
set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ")


set(CMAKE_ASM_FLAGS_DEBUG_INIT "-g -gdwarf-3")
set(CMAKE_ASM_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG")
set(CMAKE_ASM_FLAGS_RELEASE_INIT "-Os -DNDEBUG")
set(CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT "-Os -g -gdwarf-3 -DNDEBUG")
set(CMAKE_ASM_FLAGS_DEBUG "-g -gdwarf-4")
set(CMAKE_ASM_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_ASM_FLAGS_RELEASE "-Os -DNDEBUG")
set(CMAKE_ASM_FLAGS_RELWITHDEBINFO "-Os -g -gdwarf-4 -DNDEBUG")
set(CMAKE_INCLUDE_SYSTEM_FLAG_ASM "-isystem ")

set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> -cr <LINK_FLAGS> <TARGET> <OBJECTS>")

set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> -Wl,-Map,<TARGET>.map -Wl,--start-group <OBJECTS> <LINK_LIBRARIES> -lnosys -lstdc++ -lsupc++ -lm -lc -lgcc -lstdc++ -lsupc++ -lm -lc -lgcc -Wl,--end-group --specs=nano.specs -o <TARGET>")

set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g -gdwarf-3")
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-Os -g -gdwarf-3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g -gdwarf-4")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os -g -gdwarf-4 -DNDEBUG")
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")

if (CMAKE_C_COMPILER_VERSION VERSION_GREATER "7.1.0" OR CMAKE_C_COMPILER_VERSION VERSION_EQUAL "7.1.0")
message("${BoldRed}Supressing -Wexpansion-to-defined.${ColourReset}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-expansion-to-defined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-expansion-to-defined")
endif ()
endif ()
3 changes: 3 additions & 0 deletions utils/cmake/toolchains/AVR_GCC/compiler-flags.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This file is using CMAKE_<LANG>_FLAGS_<CONFIG>_INIT introduced in 3.11
cmake_minimum_required(VERSION 3.11)

set(EXPLICIT_INCLUDES "")
if((CMAKE_VERSION VERSION_GREATER "3.4.0") OR (CMAKE_VERSION VERSION_EQUAL "3.4.0"))
# from CMake 3.4 <INCLUDES> are separate to <FLAGS> in the
Expand Down
3 changes: 3 additions & 0 deletions utils/cmake/toolchains/XTENSA_GCC/compiler-flags.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This file is using CMAKE_<LANG>_FLAGS_<CONFIG>_INIT introduced in 3.11
cmake_minimum_required(VERSION 3.11)

set(EXPLICIT_INCLUDES "")
if((CMAKE_VERSION VERSION_GREATER "3.4.0") OR (CMAKE_VERSION VERSION_EQUAL "3.4.0"))
# from CMake 3.4 <INCLUDES> are separate to <FLAGS> in the
Expand Down

0 comments on commit fdc9faa

Please sign in to comment.