#
# Do we have the Bessel function jn?
#
-FIND_LIBRARY(m_lib NAMES m)
-MARK_AS_ADVANCED(m_lib)
+# 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()
+MARK_AS_ADVANCED(m_LIBRARY)
-IF(NOT m_lib MATCHES "-NOTFOUND")
- SET(CMAKE_REQUIRED_LIBRARIES ${m_lib})
+IF(NOT m_LIBRARY MATCHES "-NOTFOUND")
+ SET(CMAKE_REQUIRED_LIBRARIES ${m_LIBRARY})
CHECK_CXX_SYMBOL_EXISTS("jn" "math.h" HAVE_JN)
SET(CMAKE_REQUIRED_LIBRARIES)
IF(HAVE_JN)
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${m_lib})
+ LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${m_LIBRARY})
ENDIF()
ENDIF()
# Do this unconditionally for the most common case:
# TODO: Non-GNU setups...
#
+ #
+ # 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()
FOREACH(_lib gfortran m quadmath)
- FIND_LIBRARY(${_lib}_lib
+ FIND_LIBRARY(${_lib}_LIBRARY
NAMES ${_lib}
HINTS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES})
- MARK_AS_ADVANCED(${_lib}_lib)
+ MARK_AS_ADVANCED(${_lib}_LIBRARY)
- IF(NOT ${_lib}_lib MATCHES "-NOTFOUND")
- LIST(APPEND LAPACK_LIBRARIES ${${_lib}_lib})
+ IF(NOT ${_lib}_LIBRARY MATCHES "-NOTFOUND")
+ LIST(APPEND LAPACK_LIBRARIES ${${_lib}_LIBRARY})
ENDIF()
ENDFOREACH()
+ SWITCH_LIBRARY_PREFERENCE()
MARK_AS_ADVANCED(
atlas_LIBRARY
# The macro will be included in CONFIGURE_FEATURE_THREADS_EXTERNAL/BUNDLED.
#
MACRO(SETUP_THREADING)
+ #
+ # 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_PACKAGE(Threads)
+ SWITCH_LIBRARY_PREFERENCE()
IF(NOT Threads_FOUND)
# TODO:
--- /dev/null
+#####
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## <TODO: Full License information>
+## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
+## version of the LGPL license.
+##
+## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
+##
+#####
+
+#
+# This macro toggles the preference for static/shared libraries if
+# DEAL_II_PREFER_STATIC_LIBS=TRUE but the final executable will still be
+# dynamically linked, i.e. DEAL_II_STATIC_EXECUTABLE=OFF
+#
+# Usage:
+# SWITCH_LIBRARY_PREFERENCE()
+#
+
+MACRO(SWITCH_LIBRARY_PREFERENCE)
+ IF(DEAL_II_PREFER_STATIC_LIBS AND NOT DEAL_II_STATIC_EXECUTABLE)
+ #
+ # Invert the search order for libraries when DEAL_II_PREFER_STATIC_LIBS
+ # is set. This will prefer static archives instead of shared libraries:
+ LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
+ ENDIF()
+ENDMACRO()