Skip to content

Commit 3c91fa0

Browse files
committed
cmake: use PIE option specific to game building
1 parent 040b2cf commit 3c91fa0

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ endif()
515515
include(DaemonNacl)
516516
if (NACL)
517517
add_library(srclibs-nacl-module EXCLUDE_FROM_ALL ${NACLLIST_MODULE})
518-
set_target_properties(srclibs-nacl-module PROPERTIES POSITION_INDEPENDENT_CODE 1 FOLDER "libs")
518+
set_target_properties(srclibs-nacl-module PROPERTIES POSITION_INDEPENDENT_CODE ${GAME_PIE} FOLDER "libs")
519519
set(LIBS_BASE ${LIBS_BASE} srclibs-nacl-module)
520520
else()
521521
add_library(srclibs-nacl-native EXCLUDE_FROM_ALL ${NACLLIST_NATIVE})
@@ -642,7 +642,7 @@ if (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER OR BUILD_DUMMY_APP OR (BUIL
642642
find_package(ZLIB REQUIRED)
643643
else()
644644
add_library(srclibs-zlib EXCLUDE_FROM_ALL ${ZLIBLIST})
645-
set_target_properties(srclibs-zlib PROPERTIES POSITION_INDEPENDENT_CODE 1 FOLDER "libs")
645+
set_target_properties(srclibs-zlib PROPERTIES POSITION_INDEPENDENT_CODE ${GAME_PIE} FOLDER "libs")
646646
set(ZLIB_INCLUDE_DIRS ${LIB_DIR}/zlib)
647647
set(ZLIB_LIBRARIES srclibs-zlib)
648648
endif()

cmake/DaemonFlags.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,11 @@ else()
337337

338338
try_c_cxx_flag(FNO_STRICT_OVERFLOW "-fno-strict-overflow")
339339
try_c_cxx_flag(WSTACK_PROTECTOR "-Wstack-protector")
340-
try_c_cxx_flag(FPIE "-fPIE")
341-
try_linker_flag(LINKER_PIE "-pie")
340+
341+
if (NOT NACL OR (NACL AND GAME_PIE))
342+
try_c_cxx_flag(FPIE "-fPIE")
343+
try_linker_flag(LINKER_PIE "-pie")
344+
endif()
342345

343346
if ("${FLAG_LINKER_PIE}" AND MINGW)
344347
# https://github.com/msys2/MINGW-packages/issues/4100

cmake/DaemonPlatform.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,17 @@ else()
4040
message( FATAL_ERROR "Platform not supported" )
4141
endif()
4242

43+
if (USE_NACL_SAIGO)
44+
# Saigo clang reports weird errors when building some cgame and sgame arm nexe with PIE.
45+
# Saigo clang crashes when building amd64 cgame with PIE, sgame builds properly though.
46+
if (NACL_TARGET STREQUAL "armhf" OR NACL_TARGET STREQUAL "amd64")
47+
set(GAME_PIE 0)
48+
else()
49+
set(GAME_PIE 1)
50+
endif()
51+
else()
52+
set(GAME_PIE 1)
53+
endif()
54+
55+
4356
include(DaemonArchitecture)

0 commit comments

Comments
 (0)