equal
deleted
inserted
replaced
|
1 |
|
2 #TESTING TIME |
|
3 include(CheckCCompilerFlag) |
|
4 #when you need to check for a linker flag, just leave the argument of "check_c_compiler_flag" empty |
|
5 |
|
6 |
|
7 #check for noexecstack on ELF, Gentoo security |
|
8 set(CMAKE_REQUIRED_FLAGS "-Wl,-z,noexecstack") |
|
9 check_c_compiler_flag("" HAVE_NOEXECSTACK) |
|
10 if(HAVE_NOEXECSTACK) |
|
11 list(APPEND pascal_flags "-k-z" "-knoexecstack") |
|
12 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
|
13 endif() |
|
14 |
|
15 #check for ASLR on Windows Vista or later, requires binutils >= 2.20 |
|
16 set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat") |
|
17 check_c_compiler_flag("" HAVE_WINASLR) |
|
18 if(HAVE_WINASLR) |
|
19 list(APPEND pascal_flags "-k--nxcompat") |
|
20 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
|
21 endif() |
|
22 |
|
23 #check for DEP on Windows XP SP2 or later, requires binutils >= 2.20 |
|
24 set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase") |
|
25 check_c_compiler_flag("" HAVE_WINDEP) |
|
26 if(HAVE_WINDEP) |
|
27 list(APPEND pascal_flags "-k--dynamicbase") |
|
28 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
|
29 endif() |
|
30 |
|
31 |
|
32 #always unset or these flags will be spread everywhere |
|
33 unset(CMAKE_REQUIRED_FLAGS) |
|
34 |