--- a/cmake_modules/compilerchecks.cmake Thu Jun 13 14:44:28 2013 +0200
+++ b/cmake_modules/compilerchecks.cmake Thu Jun 13 15:37:52 2013 +0200
@@ -33,32 +33,21 @@
set(CMAKE_REQUIRED_FLAGS "-Wl,-z,noexecstack")
check_c_compiler_flag("" HAVE_NOEXECSTACK)
if(HAVE_NOEXECSTACK)
- list(APPEND pascal_flags "-k-z" "-knoexecstack")
- list(APPEND haskell_flags "-optl" "${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ append_linker_flag("-znoexecstack")
endif()
#check for full relro on ELF, Debian security
-set(CMAKE_REQUIRED_FLAGS "-Wl,-z,relro,-z,now")
+set(CMAKE_REQUIRED_FLAGS "-Wl,-zrelro,-znow")
check_c_compiler_flag("" HAVE_RELROFULL)
if(HAVE_RELROFULL)
- list(APPEND pascal_flags "-k-z" "-krelro" "-k-z" "-know")
- list(APPEND haskell_flags "-optl" "${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ append_linker_flag("-zrelro")
+ append_linker_flag("-znow")
else()
#if full relro is not available, try partial relro
- set(CMAKE_REQUIRED_FLAGS "-Wl,-z,relro")
+ set(CMAKE_REQUIRED_FLAGS "-Wl,-zrelro")
check_c_compiler_flag("" HAVE_RELROPARTIAL)
if(HAVE_RELROPARTIAL)
- list(APPEND pascal_flags "-k-z" "-krelro")
- list(APPEND haskell_flags "-optl" "${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ append_linker_flag("-zrelro")
endif()
endif()
@@ -66,33 +55,21 @@
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
check_c_compiler_flag("" HAVE_WINASLR)
if(HAVE_WINASLR)
- list(APPEND pascal_flags "-k--nxcompat")
- list(APPEND haskell_flags "-optl" "${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ append_linker_flag("--nxcompat")
endif()
#check for DEP on Windows XP SP2 or later, requires binutils >= 2.20
set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
check_c_compiler_flag("" HAVE_WINDEP)
if(HAVE_WINDEP)
- list(APPEND pascal_flags "-k--dynamicbase")
- list(APPEND haskell_flags "-optl" "${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ append_linker_flag("--dynamicbase")
endif()
#this is actually an optimisation
set(CMAKE_REQUIRED_FLAGS "-Wl,--as-needed")
check_c_compiler_flag("" HAVE_ASNEEDED)
if(HAVE_ASNEEDED)
- list(APPEND pascal_flags "-k--as-needed")
- list(APPEND haskell_flags "-optl" "${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ append_linker_flag("--as-needed")
endif()
#always unset or these flags will be spread everywhere