[cmake] use relative paths for debug symbols

When not building a Debug configuration use relative paths for __FILE__
et al in the debug symbol entries
This commit is contained in:
akallabeth 2024-11-14 12:40:12 +01:00
parent 780f6dddce
commit af7849b579
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
2 changed files with 16 additions and 8 deletions

View File

@ -64,10 +64,14 @@ endif()
CheckCXXFlag(-fno-omit-frame-pointer)
CheckCXXFlag(-fmacro-prefix-map="${CMAKE_SOURCE_DIR}"="./")
CheckCXXFlag(-fmacro-prefix-map="${CMAKE_BINARY_DIR}"="./build/")
CheckCXXFlag(-ffile-prefix-map="${CMAKE_SOURCE_DIR}"="./")
CheckCXXFlag(-ffile-prefix-map="${CMAKE_BINARY_DIR}"="./build")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=.>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=.>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fdebug-prefix-map=${CMAKE_BINARY_DIR}=./build>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fmacro-prefix-map=${CMAKE_BINARY_DIR}=./build>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-ffile-prefix-map=${CMAKE_BINARY_DIR}=./build>)
endif()
# https://stackoverflow.com/questions/4913922/possible-problems-with-nominmax-on-visual-c
if (WIN32)

View File

@ -64,10 +64,14 @@ endif()
CheckCFlag(-fno-omit-frame-pointer)
CheckCFlag(-fmacro-prefix-map="${CMAKE_SOURCE_DIR}"="./")
CheckCFlag(-fmacro-prefix-map="${CMAKE_BINARY_DIR}"="./build/")
CheckCFlag(-ffile-prefix-map="${CMAKE_SOURCE_DIR}"="./")
CheckCFlag(-ffile-prefix-map="${CMAKE_BINARY_DIR}"="./build")
if (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "GNU")
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=.>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=.>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fdebug-prefix-map=${CMAKE_BINARY_DIR}=./build>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fmacro-prefix-map=${CMAKE_BINARY_DIR}=./build>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-ffile-prefix-map=${CMAKE_BINARY_DIR}=./build>)
endif()
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "default CFLAGS")
message("Using CFLAGS ${CMAKE_C_FLAGS}")