]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Break everything (tm)
authorMatthias Maier <tamiko@kyomu.43-1.org>
Sat, 1 Feb 2014 21:53:29 +0000 (21:53 +0000)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Sat, 1 Feb 2014 21:53:29 +0000 (21:53 +0000)
- Do not record full path of system libraries and use reduced link line
  instead.

git-svn-id: https://svn.dealii.org/trunk@32369 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/checks/check_02_system_features.cmake
deal.II/cmake/configure/configure_1_threads.cmake
deal.II/cmake/macros/macro_filter_system_libraries.cmake [new file with mode: 0644]
deal.II/cmake/macros/macro_find_system_library.cmake [new file with mode: 0644]
deal.II/cmake/modules/FindDEALII_LAPACK.cmake
deal.II/cmake/modules/FindPETSC.cmake
deal.II/cmake/modules/FindUMFPACK.cmake
deal.II/cmake/setup_finalize.cmake
deal.II/doc/news/changes.h

index df8616c2cc8f12c6be58cf2358fb273db1ef6936..259465b9f93ebf1636a8c458ac453cf3fbeb9019 100644 (file)
@@ -58,13 +58,7 @@ CHECK_CXX_SYMBOL_EXISTS("rand_r" "stdlib.h" HAVE_RAND_R)
 #
 # Do we have the Bessel function jn?
 #
-# Switch the library preference back to prefer dynamic libraries if
-# DEAL_II_PREFER_STATIC_LIBS=TRUE but DEAL_II_STATIC_EXECUTABLE=FALSE. In
-# this case system libraries should be linked dynamically.
-#
-SWITCH_LIBRARY_PREFERENCE()
-FIND_LIBRARY(m_LIBRARY NAMES m)
-SWITCH_LIBRARY_PREFERENCE()
+FIND_SYSTEM_LIBRARY(m_LIBRARY NAMES m)
 MARK_AS_ADVANCED(m_LIBRARY)
 
 IF(NOT m_LIBRARY MATCHES "-NOTFOUND")
index bc698ad5953e778c6e8fea1b8855a147306cd770..1d712c04b7618e254b735c69272a8d8f387cae2a 100644 (file)
@@ -30,22 +30,16 @@ MACRO(SETUP_THREADING)
   # Unfortunately the FindThreads macro needs a working C compiler
   #
   IF(CMAKE_C_COMPILER_WORKS)
-    #
-    # Switch the library preference back to prefer dynamic libraries if
-    # DEAL_II_PREFER_STATIC_LIBS=TRUE but DEAL_II_STATIC_EXECUTABLE=FALSE. In
-    # this case system libraries must be linked dynamically.
-    #
-    SWITCH_LIBRARY_PREFERENCE()
-
     #
     # Clear the test flags because FindThreads.cmake will use a C compiler:
     #
     CLEAR_CMAKE_REQUIRED()
 
+    SWITCH_LIBRARY_PREFERENCE()
     FIND_PACKAGE(Threads)
+    SWITCH_LIBRARY_PREFERENCE()
 
     RESET_CMAKE_REQUIRED()
-    SWITCH_LIBRARY_PREFERENCE()
 
   ELSE()
 
@@ -214,7 +208,7 @@ MACRO(FEATURE_THREADS_CONFIGURE_BUNDLED)
   #
   # TODO: Also necessary for external lib, use preference toggle
   #
-  FIND_LIBRARY(dl_LIBRARY NAMES dl)
+  FIND_SYSTEM_LIBRARY(dl_LIBRARY NAMES dl)
   MARK_AS_ADVANCED(dl_LIBRARY)
   IF(NOT dl_LIBRARY MATCHES "-NOTFOUND")
     LIST(APPEND THREADS_LIBRARIES ${dl_LIBRARY})
diff --git a/deal.II/cmake/macros/macro_filter_system_libraries.cmake b/deal.II/cmake/macros/macro_filter_system_libraries.cmake
new file mode 100644 (file)
index 0000000..49b4e75
--- /dev/null
@@ -0,0 +1,43 @@
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2014 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# This macro replaces absolute paths to system libraries with the
+# corresponding short name within the FEATURE_LIBRARIES(|_DEBUG|_RELEASE)
+# variables
+#
+# Usage:
+#     FILTER_SYSTEM_LIBRARIES(feature)
+#
+
+MACRO(FILTER_SYSTEM_LIBRARIES _feature)
+  FOREACH(_variable
+    ${_feature}_LIBRARIES
+    ${_feature}_LIBRARIES_DEBUG
+    ${_feature}_LIBRARIES_RELEASE
+    )
+    IF(DEFINED ${_variable})
+      SET(_tmp_${_variable} ${${_variable}})
+      SET(${_variable} "")
+      FOREACH(_lib ${_tmp_${_variable}})
+        IF(_lib MATCHES "lib(c|quadmath|gfortran|m|rt|nsl|dl|pthread).so$")
+          string(REGEX REPLACE ".*lib([a-z]+).so$" "\\1" _lib ${_lib})
+        ENDIF()
+        LIST(APPEND ${_variable} ${_lib})
+      ENDFOREACH()
+    ENDIF()
+  ENDFOREACH()
+ENDMACRO()
diff --git a/deal.II/cmake/macros/macro_find_system_library.cmake b/deal.II/cmake/macros/macro_find_system_library.cmake
new file mode 100644 (file)
index 0000000..eda5e4a
--- /dev/null
@@ -0,0 +1,50 @@
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 - 2014 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# Search for a system library. In contrast to normal libraries we do this
+# purely via "-l<library name>" instead of selecting a full library path..
+#
+# USAGE:
+#   FIND_SYSTEM_LIBRARY(variable NAMES [list of possible names])
+#
+
+MACRO(FIND_SYSTEM_LIBRARY)
+  SET(_argn ${ARGN})
+  LIST(GET _argn 0 _variable)
+  LIST(REMOVE_AT _argn 0 1)
+
+  if("${_variable}" MATCHES "^${_variable}$")
+    FOREACH(_arg ${_argn})
+      LIST(APPEND CMAKE_REQUIRED_LIBRARIES "-l${_arg}")
+      CHECK_CXX_COMPILER_FLAG("" ${_variable})
+      RESET_CMAKE_REQUIRED()
+
+      IF(${_variable})
+        UNSET(${_variable} CACHE)
+        SET(${_variable} ${_arg} CACHE STRING "A system library.")
+        SET(${_variable} ${_arg})
+        BREAK()
+      ELSE()
+        UNSET(${_variable} CACHE)
+      ENDIF()
+    ENDFOREACH()
+
+    IF(NOT _variable)
+      SET(${_variable} "${_variable}-NOTFOUND")
+    ENDIF()
+  ENDIF()
+ENDMACRO()
index 378851f71cfb5c35635711555746d343fba478da..4257ab332d58b69bc7d2632fbab93b6b2bf83daa 100644 (file)
@@ -94,28 +94,19 @@ IF(LAPACK_FOUND)
   # If CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES is not available, do it
   # unconditionally for the most common case (gfortran).
   #
-  # Switch the library preference back to prefer dynamic libraries if
-  # DEAL_II_PREFER_STATIC_LIBS=TRUE but DEAL_II_STATIC_EXECUTABLE=FALSE. In
-  # this case system libraries should be linked dynamically.
-  #
   SET(_fortran_libs ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
   SET_IF_EMPTY(_fortran_libs gfortran m quadmath c)
 
-  SWITCH_LIBRARY_PREFERENCE()
   FOREACH(_lib ${_fortran_libs})
-    FIND_LIBRARY(${_lib}_LIBRARY
-      NAMES ${_lib}
-      HINTS
-        ${CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES}
-        ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES})
+    FIND_SYSTEM_LIBRARY(${_lib}_LIBRARY NAMES ${_lib})
     MARK_AS_ADVANCED(${_lib}_LIBRARY)
 
     IF(NOT ${_lib}_LIBRARY MATCHES "-NOTFOUND")
       LIST(APPEND BLAS_LIBRARIES ${${_lib}_LIBRARY})
       LIST(APPEND LAPACK_LIBRARIES ${${_lib}_LIBRARY})
     ENDIF()
+
   ENDFOREACH()
-  SWITCH_LIBRARY_PREFERENCE()
 
   #
   # Filter out spurious "FALSE" in the library lists:
index 1a4f3122c4f2759dc9fcc5826536e222b9ea6d5c..7bd039a11c02d1c8d180e589269f35fa61204f81 100644 (file)
@@ -137,7 +137,16 @@ IF(NOT PETSC_PETSCVARIABLES MATCHES "-NOTFOUND")
     ELSEIF(_token MATCHES "^-l")
       # Search for every library that was specified with -l:
       STRING(REGEX REPLACE "^-l" "" _token "${_token}")
-      IF(NOT _token MATCHES "(petsc|stdc\\+\\+|gcc_s)")
+
+      IF(_token MATCHES "^(c|quadmath|gfortran|m|rt|nsl|dl|pthread)$")
+        FIND_SYSTEM_LIBRARY(PETSC_LIBRARY_${_token} NAMES ${_token})
+        IF(NOT PETSC_LIBRARY_${_token} MATCHES "-NOTFOUND")
+          LIST(APPEND _petsc_libraries ${PETSC_LIBRARY_${_token}})
+        ENDIF()
+        # Remove from cache, so that updating PETSC search paths will
+        # find a (possibly) new link interface
+        UNSET(PETSC_LIBRARY_${_token} CACHE)
+      ELSEIF(NOT _token MATCHES "(petsc|stdc\\+\\+|gcc_s)")
         FIND_LIBRARY(PETSC_LIBRARY_${_token}
           NAMES ${_token}
           HINTS ${_hints}
@@ -145,12 +154,11 @@ IF(NOT PETSC_PETSCVARIABLES MATCHES "-NOTFOUND")
         IF(NOT PETSC_LIBRARY_${_token} MATCHES "-NOTFOUND")
           LIST(APPEND _petsc_libraries ${PETSC_LIBRARY_${_token}})
         ENDIF()
-        #
         # Remove from cache, so that updating PETSC search paths will
         # find a (possibly) new link interface
-        #
         UNSET(PETSC_LIBRARY_${_token} CACHE)
       ENDIF()
+
     ENDIF()
   ENDFOREACH()
 
index 71f9361e1ad0245ed135e38d759eda0a456b3918..7594366b1e39cd9eae0f3e3ff1bc366576ba23fa 100644 (file)
@@ -179,9 +179,7 @@ IF(UMFPACK_FOUND)
   # lib does not record its dependence on librt.so as evidenced
   # by ldd :-( ):
   #
-  SWITCH_LIBRARY_PREFERENCE()
-  FIND_LIBRARY(rt_LIBRARY NAMES rt)
-  SWITCH_LIBRARY_PREFERENCE()
+  FIND_SYSTEM_LIBRARY(rt_LIBRARY NAMES rt)
   MARK_AS_ADVANCED(rt_LIBRARY)
   IF(NOT rt_LIBRARY MATCHES "-NOTFOUND")
     LIST(APPEND UMFPACK_LIBRARIES ${rt_LIBRARY})
index 92ed551db2d4b47bb860ae0113e3d82a0b5d2eb2..e304e24f526c0581ec4d7e1086a2451227146027 100644 (file)
@@ -82,6 +82,7 @@ ENDFOREACH()
 # Register features:
 #
 FOREACH(_feature ${DEAL_II_FEATURES})
+  FILTER_SYSTEM_LIBRARIES(${_feature})
   REGISTER_FEATURE(${_feature})
 ENDFOREACH()
 
index a083239b46b6a35cf3d51c2fac7420e771d92546..a767e1aa5d3f37cc68568be80da04e43f7deb3f7 100644 (file)
@@ -124,6 +124,11 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+  <li>Fixed: The build system does no longer record full paths to system
+  libraries but uses the appropriate short names instead.
+  <br>
+  (Matthias Maier, 2014/02/01)
+
   <li>Reworked: External feature setup. Disabling a feature now cleans up
   associated internal, cached variables. A per-feature linkage test now spots
   common linking inconsistencies early in the configuration stage (and not

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.