cmake_modules/compilerchecks.cmake
changeset 9206 4788b24fee05
parent 9169 ef53201e95ec
child 9207 16373565692a
--- a/cmake_modules/compilerchecks.cmake	Wed Jun 12 01:26:42 2013 +0200
+++ b/cmake_modules/compilerchecks.cmake	Wed Jun 12 01:30:16 2013 +0200
@@ -72,6 +72,14 @@
     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
 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" "--as-needed")
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+endif()
 
 #always unset or these flags will be spread everywhere
 unset(CMAKE_REQUIRED_FLAGS)