From d0657fde30a265f353e3528db7c683aeb98ee315 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 5 Oct 2022 02:15:22 +0200 Subject: [PATCH] cmake: Use DWARF 4 debug information when building using mingw See f18fae4c689a68bd50ce34d6b9c1f014c2f220a2 --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59ec6bfb8..ae6d29a01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -674,6 +674,18 @@ if(USE_GCC OR USE_CLANG) endif() endif() + if(MINGW) + # See if GCC's -gdwarf-4 is supported + # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101377 for why this is needed on Windows + cmake_push_check_state(RESET) + check_c_compiler_flag("-gdwarf-4" HAVE_GDWARF_4) + if(HAVE_GDWARF_4) + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -gdwarf-4") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -gdwarf-4") + endif() + cmake_pop_check_state() + endif() + # Force color diagnostics when one of these conditions are met if(DEFINED ENV{CI} OR DEFINED ENV{USE_CCACHE} OR CMAKE_GENERATOR MATCHES Ninja) if(EMSCRIPTEN OR (USE_GCC AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9))