Skip to content

Commit

Permalink
improve -ffile-prefix-map detection
Browse files Browse the repository at this point in the history
the current implementation has two problems:
* `clang-cl` does not know `-ffile-prefix-map`, but it identifies as
"Clang", so the compiler will warn about an unknown compiler option
* xcode's clang however does not identify as "Clang", but as
"AppleClang". so `-ffile-prefix-map` is not passed although it is
supported by the compiler
  • Loading branch information
timblechmann committed Sep 9, 2022
1 parent 32eae0e commit 5a2e14f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions CMake/CatchMiscFunctions.cmake
Expand Up @@ -112,9 +112,8 @@ endfunction()
# Adds flags required for reproducible build to the target
# Currently only supports GCC and Clang
function(add_build_reproducibility_settings target)
# Make the build reproducible on versions of g++ and clang that supports -ffile-prefix-map
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 8) OR
("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 10))
target_compile_options(${target} PRIVATE "-ffile-prefix-map=${CATCH_DIR}=.")
# Make the build reproducible on versions of g++ and clang that supports -ffile-prefix-map
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_cxx_flag_if_supported_to_targets("-ffile-prefix-map=${CATCH_DIR}=." "${target}")
endif()
endfunction()

0 comments on commit 5a2e14f

Please sign in to comment.