Merge pull request #4365 from RisingFog/patch-1

Add -no-pie flag to CMake
This commit is contained in:
Markus Wick 2016-10-31 12:29:18 +01:00 committed by GitHub
commit 4cf873ea73
1 changed files with 11 additions and 1 deletions

View File

@ -188,7 +188,7 @@ else()
add_definitions(-D_ARCH_32=1) add_definitions(-D_ARCH_32=1)
endif() endif()
include(CheckCCompilerFlag)
if(ENABLE_GENERIC) if(ENABLE_GENERIC)
message("Warning! Building generic build!") message("Warning! Building generic build!")
set(_M_GENERIC 1) set(_M_GENERIC 1)
@ -203,6 +203,16 @@ elseif(_ARCH_64 AND (
set(_M_X86_64 1) set(_M_X86_64 1)
add_definitions(-D_M_X86=1 -D_M_X86_64=1 -msse2) add_definitions(-D_M_X86=1 -D_M_X86_64=1 -msse2)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
CHECK_C_COMPILER_FLAG("-no-pie" NO_PIE_UPSTREAM)
if(NO_PIE_UPSTREAM)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie")
endif()
CHECK_C_COMPILER_FLAG("-nopie" NO_PIE_PATCHED)
if(NO_PIE_PATCHED)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nopie")
endif()
endif()
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64") elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(_M_ARM 1) set(_M_ARM 1)
set(_M_ARM_64 1) set(_M_ARM_64 1)