Skip to content

Commit 525f3e3

Browse files
committed
Add execstack flags to CMakeLists
1 parent 89d4637 commit 525f3e3

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

rehlds/HLTV/Console/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
cmake_minimum_required(VERSION 3.1)
22
project(hltv CXX)
33

4+
include(CheckCXXCompilerFlag)
5+
46
option(DEBUG "Build with debug information." OFF)
57

68
set(CMAKE_CXX_STANDARD 14)
@@ -14,6 +16,18 @@ set(LINK_FLAGS "-m32 -no-pie -Wl,--no-export-dynamic")
1416

1517
set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions -fno-strict-aliasing -fno-strict-overflow")
1618

19+
check_cxx_compiler_flag("-Wa,--execstack" HAS_EXECSTACK_ASM)
20+
check_cxx_compiler_flag("-Wl,-z,execstack" HAS_EXECSTACK_LINK)
21+
22+
# Glibc >=2.41 fixes
23+
if(HAS_EXECSTACK_ASM)
24+
set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wa,--execstack")
25+
endif()
26+
27+
if(HAS_EXECSTACK_LINK)
28+
set(LINK_FLAGS "${LINK_FLAGS} -Wl,-z,execstack")
29+
endif()
30+
1731
if (DEBUG)
1832
set(COMPILE_FLAGS "${COMPILE_FLAGS} -g3 -O3 -ggdb")
1933
else()

rehlds/dedicated/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
cmake_minimum_required(VERSION 3.1)
22
project(hlds CXX)
33

4+
include(CheckCXXCompilerFlag)
5+
46
option(DEBUG "Build with debug information." OFF)
57

68
set(CMAKE_CXX_STANDARD 14)
@@ -14,6 +16,18 @@ set(LINK_FLAGS "-m32 -no-pie -Wl,--no-export-dynamic")
1416

1517
set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions -fno-strict-aliasing -fno-strict-overflow")
1618

19+
check_cxx_compiler_flag("-Wa,--execstack" HAS_EXECSTACK_ASM)
20+
check_cxx_compiler_flag("-Wl,-z,execstack" HAS_EXECSTACK_LINK)
21+
22+
# Glibc >=2.41 fixes
23+
if(HAS_EXECSTACK_ASM)
24+
set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wa,--execstack")
25+
endif()
26+
27+
if(HAS_EXECSTACK_LINK)
28+
set(LINK_FLAGS "${LINK_FLAGS} -Wl,-z,execstack")
29+
endif()
30+
1731
if (DEBUG)
1832
set(COMPILE_FLAGS "${COMPILE_FLAGS} -g3 -O3 -ggdb")
1933
else()

0 commit comments

Comments
 (0)