25 set(CMAKE_REQUIRED_FLAGS "-Wl,-z,noexecstack") |
28 set(CMAKE_REQUIRED_FLAGS "-Wl,-z,noexecstack") |
26 check_c_compiler_flag("" HAVE_NOEXECSTACK) |
29 check_c_compiler_flag("" HAVE_NOEXECSTACK) |
27 if(HAVE_NOEXECSTACK) |
30 if(HAVE_NOEXECSTACK) |
28 list(APPEND pascal_flags "-k-z" "-knoexecstack") |
31 list(APPEND pascal_flags "-k-z" "-knoexecstack") |
29 list(APPEND haskell_flags "-optl" "-z" "-optl" "noexecstack") |
32 list(APPEND haskell_flags "-optl" "-z" "-optl" "noexecstack") |
30 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
33 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
31 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
|
32 endif() |
34 endif() |
33 |
35 |
34 #check for full relro on ELF, Debian security |
36 #check for full relro on ELF, Debian security |
35 set(CMAKE_REQUIRED_FLAGS "-Wl,-z,relro,-z,now") |
37 set(CMAKE_REQUIRED_FLAGS "-Wl,-z,relro,-z,now") |
36 check_c_compiler_flag("" HAVE_RELROFULL) |
38 check_c_compiler_flag("" HAVE_RELROFULL) |
37 if(HAVE_RELROFULL) |
39 if(HAVE_RELROFULL) |
38 list(APPEND pascal_flags "-k-z" "-krelro" "-k-z" "-know") |
40 list(APPEND pascal_flags "-k-z" "-krelro" "-k-z" "-know") |
39 list(APPEND haskell_flags "-optl" "-z" "-optl" "relro" "-optl" "-z" "-optl" "now") |
41 list(APPEND haskell_flags "-optl" "-z" "-optl" "relro" "-optl" "-z" "-optl" "now") |
40 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
42 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
41 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
|
42 else() |
43 else() |
43 #if full relro is not available, try partial relro |
44 #if full relro is not available, try partial relro |
44 set(CMAKE_REQUIRED_FLAGS "-Wl,-z,relro") |
45 set(CMAKE_REQUIRED_FLAGS "-Wl,-z,relro") |
45 check_c_compiler_flag("" HAVE_RELROPARTIAL) |
46 check_c_compiler_flag("" HAVE_RELROPARTIAL) |
46 if(HAVE_RELROPARTIAL) |
47 if(HAVE_RELROPARTIAL) |
47 list(APPEND pascal_flags "-k-z" "-krelro") |
48 list(APPEND pascal_flags "-k-z" "-krelro") |
48 list(APPEND haskell_flags "-optl" "-z" "-optl" "relro") |
49 list(APPEND haskell_flags "-optl" "-z" "-optl" "relro") |
49 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
50 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
50 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
|
51 endif() |
51 endif() |
52 endif() |
52 endif() |
53 |
53 |
54 #check for ASLR on Windows Vista or later, requires binutils >= 2.20 |
54 #check for ASLR on Windows Vista or later, requires binutils >= 2.20 |
55 set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat") |
55 set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat") |
56 check_c_compiler_flag("" HAVE_WINASLR) |
56 check_c_compiler_flag("" HAVE_WINASLR) |
57 if(HAVE_WINASLR) |
57 if(HAVE_WINASLR) |
58 list(APPEND pascal_flags "-k--nxcompat") |
58 list(APPEND pascal_flags "-k--nxcompat") |
59 list(APPEND haskell_flags "-optl" "--nxcompat") |
59 list(APPEND haskell_flags "-optl" "--nxcompat") |
60 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
60 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
61 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
|
62 endif() |
61 endif() |
63 |
62 |
64 #check for DEP on Windows XP SP2 or later, requires binutils >= 2.20 |
63 #check for DEP on Windows XP SP2 or later, requires binutils >= 2.20 |
65 set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase") |
64 set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase") |
66 check_c_compiler_flag("" HAVE_WINDEP) |
65 check_c_compiler_flag("" HAVE_WINDEP) |
67 if(HAVE_WINDEP) |
66 if(HAVE_WINDEP) |
68 list(APPEND pascal_flags "-k--dynamicbase") |
67 list(APPEND pascal_flags "-k--dynamicbase") |
69 list(APPEND haskell_flags "-optl" "--dynamicbase") |
68 list(APPEND haskell_flags "-optl" "--dynamicbase") |
70 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
69 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
71 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
|
72 endif() |
70 endif() |
73 |
71 |
74 |
72 |
75 #always unset or these flags will be spread everywhere |
73 #always unset or these flags will be spread everywhere |
76 unset(CMAKE_REQUIRED_FLAGS) |
74 unset(CMAKE_REQUIRED_FLAGS) |