summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2020-12-22 20:23:50 +0100
committerSlávek Banko <slavek.banko@axis.cz>2021-01-13 11:27:17 +0100
commitfa2f9f61483e31e76354e34fbb787257a6a28c2e (patch)
tree2d3307208beb860382d51353b9e5ffe5e5ace16f /modules
parentc8ee49a69d1777b65064d4c15ae2850250e8588b (diff)
downloadtde-cmake-fa2f9f61483e31e76354e34fbb787257a6a28c2e.tar.gz
tde-cmake-fa2f9f61483e31e76354e34fbb787257a6a28c2e.zip
Set compiler flags useful for reproducible building.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz> (cherry picked from commit b2b9e890528f27daeb577983e1ed4fe2ecf8f852)
Diffstat (limited to 'modules')
-rw-r--r--modules/TDEMacros.cmake16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index 5a9f29b..e75914c 100644
--- a/modules/TDEMacros.cmake
+++ b/modules/TDEMacros.cmake
@@ -2316,6 +2316,22 @@ macro( tde_setup_architecture_flags )
set( TDE_PIE_CFLAGS -fPIE )
set( TDE_PIE_LDFLAGS -pie )
endif( HAVE_PIE_SUPPORT )
+
+ set( _reproducible_cxxflags
+ "-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=."
+ "-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=."
+ )
+ foreach( _flag ${_reproducible_cxxflags} )
+ string( REGEX REPLACE "=.*" "" _flag_name "${_flag}" )
+ string( REGEX REPLACE "[^a-zA-Z0-9]+" "_" _flag_var "CXXFLAG_${_flag_name}" )
+ if( NOT "${CMAKE_CXX_FLAGS}" MATCHES "(^| )${_flag_name}" )
+ check_cxx_compiler_flag( "${_flag}" ${_flag_var} )
+ if( ${_flag_var} )
+ set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}" )
+ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}" )
+ endif()
+ endif()
+ endforeach()
endif( )
endmacro( )