cmake: Move section to disable PIE with the other compiler flags

This commit is contained in:
Florent Castelli 2017-01-25 06:07:01 +01:00
parent 1dda078c61
commit 221f991f1e
1 changed files with 13 additions and 11 deletions

View File

@ -172,17 +172,6 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
add_definitions(-D_M_X86=1)
add_definitions(-D_M_X86_64=1)
check_and_add_flag(HAVE_SSE2 -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)
@ -233,6 +222,19 @@ else()
if(FLAG_C_FOMIT_FRAME_POINTER)
add_compile_options($<$<CONFIG:Release>:-fomit-frame-pointer>)
endif()
if(NOT ANDROID AND _M_X86_64)
# PIE is required on Android, but not supported with the x86_64 jit currently
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
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()
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Windows")