diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2014-10-12 17:44:00 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2014-10-12 17:44:00 +0200 |
commit | 08c6f54d6f80554caa671847417cf04326adb63c (patch) | |
tree | ce64a93968280248704c66713fc889f5b2e22214 | |
parent | 0d5ca8bebbb638b05f1d11537ce41fcf73d10ac9 (diff) | |
download | tde-cmake-08c6f54d6f80554caa671847417cf04326adb63c.tar.gz tde-cmake-08c6f54d6f80554caa671847417cf04326adb63c.zip |
Build setuid binaries with PIE flags
-rw-r--r-- | modules/TDEMacros.cmake | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake index 4f5f59e..c271c98 100644 --- a/modules/TDEMacros.cmake +++ b/modules/TDEMacros.cmake @@ -13,6 +13,7 @@ ################################################# include( KDE3Macros ) # we will need this module for a while +include( CheckCXXCompilerFlag ) ################################################# @@ -1023,6 +1024,12 @@ macro( tde_add_executable _arg_target ) add_dependencies( ${_target} ${_dependencies} ) endif( _dependencies ) + # set PIE flags for setuid binaries + if( _setuid ) + set_target_properties( ${_target} PROPERTIES COMPILE_FLAGS ${TDE_PIE_CFLAGS} ) + set_target_properties( ${_target} PROPERTIES LINK_FLAGS ${TDE_PIE_LDFLAGS} ) + endif( _setuid ) + # set destination directory if( _destination ) if( _setuid ) @@ -1537,4 +1544,10 @@ macro( tde_setup_architecture_flags ) else( ) set( LINKER_IMMEDIATE_BINDING_FLAGS "" CACHE INTERNAL "" FORCE ) endif( ) + + check_cxx_compiler_flag( -fPIE HAVE_PIE_SUPPORT ) + if( HAVE_PIE_SUPPORT ) + set( TDE_PIE_CFLAGS -fPIE ) + set( TDE_PIE_LDFLAGS -pie ) + endif( HAVE_PIE_SUPPORT ) endmacro( ) |