CMake: add ENABLE_PIE option

This commit is contained in:
Tillmann Karras 2015-05-02 14:15:17 +02:00
parent d4538c762f
commit 0e1c51e5b9
1 changed files with 6 additions and 0 deletions

View File

@ -10,6 +10,7 @@ option(USE_UPNP "Enables UPnP port mapping support" ON)
option(DISABLE_WX "Disable wxWidgets (use Qt or CLI interface)" OFF)
option(ENABLE_QT "Enable Qt (use the experimental Qt interface)" OFF)
option(ENABLE_PCH "Use PCH to speed up compilation" ON)
option(ENABLE_PIE "Build a Position-Independent Executable (PIE)" ON)
option(ENABLE_LTO "Enables Link Time Optimization" OFF)
option(ENABLE_GENERIC "Enables generic build that should run on any little-endian host" OFF)
if(APPLE)
@ -218,6 +219,11 @@ if(UNIX AND NOT APPLE)
check_and_add_flag(VISIBILITY_HIDDEN -fvisibility=hidden)
endif()
if(ENABLE_PIE)
add_definitions(-fPIE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
endif()
if(ENABLE_LTO)
check_and_add_flag(LTO -flto)
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)