diff options
| author | Martin Hořeňovský | 2021-05-09 17:36:30 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-05-09 18:05:34 +0200 |
| commit | d4a3cd99925166d6cbaed8f26fd989083ddae0a8 (patch) | |
| tree | 3ca3e8301f76fdb381db1e8845273cc30199320a /CMake | |
| parent | 342dd3445c745e50c5be7bda485a89bc3298afc5 (diff) | |
| download | catch3-d4a3cd99925166d6cbaed8f26fd989083ddae0a8.tar.gz | |
Make the static library build reproducible with supported compilers
This is based on bed285af07607a9da93892f8b08d36c3fd6af98d from
`v2.x` branch, but done properly for the build in v3 branch,
effectively porting #2141 to devel.
Diffstat (limited to 'CMake')
| -rw-r--r-- | CMake/MiscFunctions.cmake | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/CMake/MiscFunctions.cmake b/CMake/MiscFunctions.cmake index 1f0ed865..5fb3c4f7 100644 --- a/CMake/MiscFunctions.cmake +++ b/CMake/MiscFunctions.cmake @@ -77,3 +77,13 @@ function(add_warnings_to_targets targets) endif() endif() 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}=.") + endif() +endfunction() |