cmake_modules/compilerchecks.cmake
changeset 9315 15487f7fed42
parent 9307 a0fef7134ade
child 9339 14f5f3a1e2f7
--- a/cmake_modules/compilerchecks.cmake	Wed Jul 03 17:35:17 2013 +0200
+++ b/cmake_modules/compilerchecks.cmake	Thu Jul 04 11:58:40 2013 +0200
@@ -29,7 +29,7 @@
 
 
 if(UNIX)
-    #symbol visibility, not supported on Windows (error out then)
+    #symbol visibility
     check_c_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITY)
     if(HAVE_VISIBILITY)
         add_flag_append(CMAKE_C_FLAGS "-fvisibility=hidden")
@@ -37,7 +37,7 @@
     endif()
 
     #check for noexecstack on ELF, Gentoo security
-    set(CMAKE_REQUIRED_FLAGS "-Wl,-z,noexecstack")
+    set(CMAKE_REQUIRED_FLAGS "-Wl,-znoexecstack")
     check_c_compiler_flag("" HAVE_NOEXECSTACK)
     if(HAVE_NOEXECSTACK)
         add_linker_flag("-znoexecstack")
@@ -58,11 +58,12 @@
         endif()
     endif()
 
-    #this is actually an optimisation
-    set(CMAKE_REQUIRED_FLAGS "-Wl,--as-needed")
-    check_c_compiler_flag("" HAVE_ASNEEDED)
-    if(HAVE_ASNEEDED)
-        add_linker_flag("--as-needed")
+    if(CMAKE_BUILD_TYPE MATCHES "RELEASE")
+        set(CMAKE_REQUIRED_FLAGS "-Wl,--as-needed")
+        check_c_compiler_flag("" HAVE_ASNEEDED)
+        if(HAVE_ASNEEDED)
+            add_linker_flag("--as-needed")
+        endif()
     endif()
 else(UNIX)
     #check for ASLR on Windows Vista or later, requires binutils >= 2.20