From b0328ef0751b88739355aba8313e715bd57ff18c Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Sat, 13 Jul 2013 10:08:17 +0000 Subject: [PATCH] CMake: Split preference for static libraries in its own configuration toggle git-svn-id: https://svn.dealii.org/trunk@29990 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/cmake/setup_cached_variables.cmake | 25 ++++++++++++++++------ deal.II/cmake/setup_deal_ii.cmake | 10 ++++----- deal.II/doc/development/cmake.html | 8 ++++++- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/deal.II/cmake/setup_cached_variables.cmake b/deal.II/cmake/setup_cached_variables.cmake index 0439cf354a..8b6a6d4465 100644 --- a/deal.II/cmake/setup_cached_variables.cmake +++ b/deal.II/cmake/setup_cached_variables.cmake @@ -33,8 +33,9 @@ # CMAKE_BUILD_TYPE # DEAL_II_ALLOW_PLATFORM_INTROSPECTION # DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS -# DEAL_II_STATIC_EXECUTABLE # BUILD_SHARED_LIBS +# DEAL_II_PREFER_STATIC_LIBS +# DEAL_II_STATIC_EXECUTABLE # CMAKE_INSTALL_RPATH_USE_LINK_PATH # CMAKE_C_FLAGS *) # CMAKE_CXX_FLAGS *) @@ -150,22 +151,32 @@ OPTION(DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS ) MARK_AS_ADVANCED(DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS) +SET(BUILD_SHARED_LIBS "ON" CACHE BOOL + "Build a shared library" + ) + +OPTION(DEAL_II_PREFER_STATIC_LIBS + "Prefer static libraries over dynamic libraries when searching for features and corresponding link interface" + OFF + ) +MARK_AS_ADVANCED(DEAL_II_PREFER_STATIC_LIBS) + OPTION(DEAL_II_STATIC_EXECUTABLE - "Provide a link interface that is suitable for static linkage of executables. Enabling this option forces BUILD_SHARED_LIBS=OFF" + "Provide a link interface that is suitable for static linkage of executables. Enabling this option forces BUILD_SHARED_LIBS=OFF and DEAL_II_PREFER_STATIC_LIBS=ON" OFF ) MARK_AS_ADVANCED(DEAL_II_STATIC_EXECUTABLE) IF(DEAL_II_STATIC_EXECUTABLE) SET(BUILD_SHARED_LIBS "OFF" CACHE BOOL - "Build a shared library" FORCE - ) -ELSE() - SET(BUILD_SHARED_LIBS "ON" CACHE BOOL "Build a shared library" + FORCE + ) + SET(DEAL_II_PREFER_STATIC_LIBS "ON" CACHE BOOL + "Prefer static libraries over dynamic libraries when searching for features and corresponding link interface" + FORCE ) ENDIF() -MARK_AS_ADVANCED(BUILD_SHARED_LIBS) # diff --git a/deal.II/cmake/setup_deal_ii.cmake b/deal.II/cmake/setup_deal_ii.cmake index 4b3f6cdbb8..346d69d51c 100644 --- a/deal.II/cmake/setup_deal_ii.cmake +++ b/deal.II/cmake/setup_deal_ii.cmake @@ -164,11 +164,11 @@ FOREACH(_build ${DEAL_II_BUILD_TYPES}) ) ENDFOREACH() -# -# Invert the search order for libraries when BUILD_SHARED_LIBS=OFF to -# prefer static archives instead of shared libraries: -# -IF(NOT BUILD_SHARED_LIBS) +IF(DEAL_II_PREFER_STATIC_LIBS) + # + # Invert the search order for libraries when DEAL_II_PREFER_STATIC_LIBS + # is set. This will prefer static archives instead of shared libraries: + # # TODO: Does this work on a Windows or CYGWIN target? LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES) ENDIF() diff --git a/deal.II/doc/development/cmake.html b/deal.II/doc/development/cmake.html index b169825b1d..75c7bb8451 100644 --- a/deal.II/doc/development/cmake.html +++ b/deal.II/doc/development/cmake.html @@ -570,12 +570,18 @@ BUILD_SHARED_LIBS: If set (default), deal.II will be linked as a shared library +
  • + DEAL_II_PREFER_STATIC_LIBS (defaults to off): If set + to true, static archives will be preferred over dynamic libraries when + searching for features and corresponding link interface. +
  • DEAL_II_STATIC_EXECUTABLE (defaults to off): If set to true, deal.II will be configured in a way to provide a link interface that is suitable for static linkage of executables. Enabling this option forces - BUILD_SHARED_LIBS=OFF + BUILD_SHARED_LIBS=OFF and + DEAL_II_PERFER_STATIC_LIBS.
  • CMAKE_INSTALL_RPATH_USE_LINK_PATH: If set -- 2.39.5