Skip to content

Commit

Permalink
Test for -ffile-prefix-map support instead of comparing versions.
Browse files Browse the repository at this point in the history
Comparing versions is not viable because Apple clang has its own
versioning scheme which is also undocumented.
  • Loading branch information
whitequark committed Nov 24, 2019
1 parent 690f87c commit fb536a1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ endif()

# common compiler flags

if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)) 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}")
include(CheckCXXCompilerFlag)

set(FILE_PREFIX_MAP "-ffile-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.")
check_cxx_compiler_flag("${FILE_PREFIX_MAP}" HAS_FILE_PREFIX_MAP)
if(HAS_FILE_PREFIX_MAP)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FILE_PREFIX_MAP}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FILE_PREFIX_MAP}")
endif()

if(MINGW)
Expand Down

0 comments on commit fb536a1

Please sign in to comment.