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

View file

@ -188,7 +188,7 @@ else()
add_definitions(-D_ARCH_32=1)
endif()
include(CheckCCompilerFlag)
if(ENABLE_GENERIC)
message("Warning! Building generic build!")
set(_M_GENERIC 1)
@ -203,6 +203,16 @@ elseif(_ARCH_64 AND (
set(_M_X86_64 1)
add_definitions(-D_M_X86=1 -D_M_X86_64=1 -msse2)
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")
set(_M_ARM 1)
set(_M_ARM_64 1)