Skip to content

Commit

Permalink
On GNU-compatible compilers, avoid embedding paths into binaries.
Browse files Browse the repository at this point in the history
This is helpful for reproducible builds, and also makes it easier
to debug binaries built on another system.
  • Loading branch information
whitequark committed Nov 23, 2019
1 parent 14e095c commit 9e7681f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ endif()

# common compiler flags

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(DEBUG_FLAGS "-fdebug-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.")
set(DEBUG_FLAGS "${DEBUG_FLAGS} -ffile-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DEBUG_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DEBUG_FLAGS}")
endif()

if(MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
Expand Down

0 comments on commit 9e7681f

Please sign in to comment.