#
# 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")
# 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()
#
# 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})
--- /dev/null
+## ---------------------------------------------------------------------
+## $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()
--- /dev/null
+## ---------------------------------------------------------------------
+## $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()
# 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:
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}
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()
# 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})
# Register features:
#
FOREACH(_feature ${DEAL_II_FEATURES})
+ FILTER_SYSTEM_LIBRARIES(${_feature})
REGISTER_FEATURE(${_feature})
ENDFOREACH()
<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