]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Bugfix: Test the support of a linker flag by actually trying to link with
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 22 Sep 2012 15:11:09 +0000 (15:11 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 22 Sep 2012 15:11:09 +0000 (15:11 +0000)
it...

git-svn-id: https://svn.dealii.org/branches/branch_cmake@26632 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/macros/macro_enable_if_links.cmake [new file with mode: 0644]
deal.II/cmake/setup_compiler_flags_gnu.cmake

diff --git a/deal.II/cmake/macros/macro_enable_if_links.cmake b/deal.II/cmake/macros/macro_enable_if_links.cmake
new file mode 100644 (file)
index 0000000..79dba18
--- /dev/null
@@ -0,0 +1,23 @@
+#
+# Tests whether it is possible to compile and link a dummy program with a
+# given flag.
+# If so, add it to variable.
+#
+# Usage:
+#     ENABLE_IF_LINKS(variable flag)
+#
+
+MACRO(ENABLE_IF_LINKS variable flag)
+  ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${flag}")
+  CHECK_CXX_SOURCE_COMPILES(
+  "
+  int main() { return 0; }
+  "
+  DEAL_II_HAVE_FLAG_${flag}
+  )
+  STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${flag}")
+  IF(DEAL_II_HAVE_FLAG_${flag})
+    SET(${variable} "${${variable}} ${flag}")
+  ENDIF()
+ENDMACRO()
+
index b768c14d479f2f12262c0510ca0ed60a33f1699e..d1c4150967fcec199ede3023deb78ee9d449fe6b 100644 (file)
@@ -23,7 +23,7 @@ ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-fpic")
 # Check whether the -as-needed flag is available. If so set it to link
 # the deal.II library with it.
 #
-ENABLE_IF_SUPPORTED(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
+ENABLE_IF_LINKS(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
 
 
 #
@@ -93,8 +93,9 @@ IF(CMAKE_SYSTEM_NAME MATCHES "CYGWIN") # TODO: Check for correct name
   # you accidentally defined one symbol multiple times...
   # (added 2005/07/13, Ralf B. Schulz)
   # (modified 2005/12/20, Ralf B. Schulz)
-  ENABLE_IF_SUPPORTED(CMAKE_SHARED_LINKER_FLAGS
-    "-Xlinker --allow-multiple-definition")
+  ENABLE_IF_LINKS(CMAKE_SHARED_LINKER_FLAGS
+    "-Xlinker --allow-multiple-definition"
+    )
 ENDIF()
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.