# HG changeset patch
# User koda
# Date 1365876832 -7200
# Node ID 7e9c6efe90fd1e726ac8dece228944a41947df65
# Parent  82756a90a343c975a7d6e3e9c63e2e25d031b837
added two security flags to windows linking

diff -r 82756a90a343 -r 7e9c6efe90fd CMakeLists.txt
--- a/CMakeLists.txt	Fri Apr 12 12:44:14 2013 -0400
+++ b/CMakeLists.txt	Sat Apr 13 20:13:52 2013 +0200
@@ -225,15 +225,26 @@
     set(CMAKE_CXX_FLAGS_DEBUG "-Wall -DDEBUG")
 endif()
 
-#TODO: find out why we need this...
+
+#TESTING TIME
 include(CheckCCompilerFlag)
+
+#check for noexecstack on ELF, should be set on Gentoo and similar
 set(CMAKE_REQUIRED_FLAGS "-Wl,-z -Wl,noexecstack")
 check_c_compiler_flag("" HAVE_NOEXECSTACK) #empty because we are testing a linker flag
 if(HAVE_NOEXECSTACK)
     list(APPEND pascal_flags "-k-z" "-knoexecstack")
-    if(NOT ${MINIMAL_FLAGS})
-        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
-    endif()
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+endif()
+unset(CMAKE_REQUIRED_FLAGS)
+
+#check for ASLR and DEP security features on Windows
+#both supported in binutils >= 2.20, available since Vista and XP SP2 respectively
+set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat -Wl,--dynamicbase")
+check_c_compiler_flag("" HAVE_WINASLRDEP) #empty because we are testing a linker flag
+if(HAVE_WINASLRDEP)
+    list(APPEND pascal_flags "-k--nxcompat" "-k--dynamicbase")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
 endif()
 unset(CMAKE_REQUIRED_FLAGS)