mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Add support for building position-independent executables.
This commit is contained in:
parent
bf25959b68
commit
6340ed8993
@ -22,6 +22,7 @@ set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake )
|
||||
option(WITH_TESTS "Enable building of unit tests" ON)
|
||||
option(WITH_GUI_TESTS "Enable building of GUI tests" OFF)
|
||||
option(WITH_LTO "Enable Link Time Optimization (LTO)" OFF)
|
||||
option(WITH_PIE "Build as Position-independent executable (PIE)" OFF)
|
||||
|
||||
set( KEEPASSX_VERSION "0.9.0" )
|
||||
|
||||
@ -80,7 +81,7 @@ endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
if(WITH_LTO)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CMAKE_COMPILER_IS_GNUCC and CMAKE_COMPILER_IS_GNUCXX)
|
||||
check_cxx_compiler_flag("-flto -fuse-linker-plugin" LTO_AVAILABLE)
|
||||
|
||||
if(LTO_AVAILABLE)
|
||||
@ -90,9 +91,18 @@ if(WITH_LTO)
|
||||
endif(LTO_AVAILABLE)
|
||||
else()
|
||||
message(FATAL_ERROR "LTO is only supported with gcc")
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
endif(CMAKE_COMPILER_IS_GNUCC and CMAKE_COMPILER_IS_GNUCXX)
|
||||
endif(WITH_LTO)
|
||||
|
||||
if(WITH_PIE)
|
||||
if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) AND (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX))
|
||||
add_gcc_compiler_flags("-fPIE")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie")
|
||||
else()
|
||||
message(FATAL_ERROR "PIE is only supported with gcc and clang")
|
||||
endif((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) AND (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX))
|
||||
endif(WITH_PIE)
|
||||
|
||||
if( APPLE OR MINGW )
|
||||
set( PROGNAME KeePassX )
|
||||
else( APPLE OR MINGW )
|
||||
|
Loading…
Reference in New Issue
Block a user