Skip to content

Commit 690f87c

Browse files
committedNov 23, 2019
On GNU-compatible compilers, avoid embedding paths into binaries.
This is helpful for reproducible builds, and also makes it easier to debug binaries built on another system.
1 parent 14e095c commit 690f87c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ endif()
6666

6767
# common compiler flags
6868

69+
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)) OR
70+
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
71+
set(DEBUG_FLAGS "-fdebug-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.")
72+
set(DEBUG_FLAGS "${DEBUG_FLAGS} -ffile-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.")
73+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DEBUG_FLAGS}")
74+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DEBUG_FLAGS}")
75+
endif()
76+
6977
if(MINGW)
7078
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
7179
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")

0 commit comments

Comments
 (0)