as-needed only at release time
authorkoda
Thu, 04 Jul 2013 11:58:40 +0200
changeset 9315 15487f7fed42
parent 9313 62032a4cd00b
child 9317 a04c30940d2d
as-needed only at release time
cmake_modules/compilerchecks.cmake
--- 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