From baebc028810b40c66aafa4f44f74afff0cd65565 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 21 Nov 2024 13:39:55 +0100 Subject: [PATCH] [cmake,compiler] check for GCC/clang greater equal 10 for -fdebug-prefix-map et al check for compilers supporting it. --- cmake/CXXCompilerFlags.cmake | 2 ++ cmake/CompilerFlags.cmake | 2 ++ 2 files changed, 4 insertions(+) diff --git a/cmake/CXXCompilerFlags.cmake b/cmake/CXXCompilerFlags.cmake index 72fbaa86b..70e86eb5f 100644 --- a/cmake/CXXCompilerFlags.cmake +++ b/cmake/CXXCompilerFlags.cmake @@ -65,12 +65,14 @@ endif() CheckCXXFlag(-fno-omit-frame-pointer) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10) add_compile_options($<$>:-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=.>) add_compile_options($<$>:-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=.>) add_compile_options($<$>:-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.>) add_compile_options($<$>:-fdebug-prefix-map=${CMAKE_BINARY_DIR}=./build>) add_compile_options($<$>:-fmacro-prefix-map=${CMAKE_BINARY_DIR}=./build>) add_compile_options($<$>:-ffile-prefix-map=${CMAKE_BINARY_DIR}=./build>) + endif() endif() # https://stackoverflow.com/questions/4913922/possible-problems-with-nominmax-on-visual-c diff --git a/cmake/CompilerFlags.cmake b/cmake/CompilerFlags.cmake index 7b483f54f..ee2e6c214 100644 --- a/cmake/CompilerFlags.cmake +++ b/cmake/CompilerFlags.cmake @@ -60,12 +60,14 @@ endif() CheckCFlag(-fno-omit-frame-pointer) if (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "GNU") + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10) add_compile_options($<$>:-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=.>) add_compile_options($<$>:-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=.>) add_compile_options($<$>:-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.>) add_compile_options($<$>:-fdebug-prefix-map=${CMAKE_BINARY_DIR}=./build>) add_compile_options($<$>:-fmacro-prefix-map=${CMAKE_BINARY_DIR}=./build>) add_compile_options($<$>:-ffile-prefix-map=${CMAKE_BINARY_DIR}=./build>) + endif() endif() set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "default CFLAGS")