From 6c64df05567190bb907ee98f96e94ba55b3b01c3 Mon Sep 17 00:00:00 2001
From: Markus Blatt <mblatt@dune-project.org>
Date: Mon, 26 Mar 2012 16:33:29 +0000
Subject: [PATCH] By default cmake prefers to use shared libraries resulting in
 a mix of shared and static (dune-common) linkage. For supercomputer we need
 pure statically linked binaries.

This patch maked Cmake prefer static linkage on request (i.e. setting
DUNE_USE_ONLY_STATIC_LIB to true).

Unfortunately, this breaks the Lapack test on ubuntu and Debian (at least
wheezy) as there are multiple definitions in libblas.a and liblapack.a.


[[Imported from SVN: r6598]]
---
 CMakeLists.txt | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 39f4650a5..7d52c8ad8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,6 +16,23 @@ set(DUNE_COMMON_VERSION_MAJOR    "${DUNE_VERSION_MAJOR}")
 set(DUNE_COMMON_VERSION_MINOR    "${DUNE_VERSION_MINOR}")
 set(DUNE_COMMON_VERSION_REVISION "${DUNE_VERSION_REVISION}")
 
+message("DUNE_USE_ONLY_STATIC_LIB ${DUNE_USE_ONLY_STATIC_LIB}")
+
+if(DUNE_USE_ONLY_STATIC_LIBS)
+  # Use only static libraries.
+  # We do this by overriding the library suffixes.
+  set( BLA_STATIC 1)
+  set( _dune_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
+  if (WIN32)
+    set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
+  endif (WIN32)
+  if (APPLE)
+    set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
+  else (APPLE)
+    set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
+  endif (APPLE)
+endif()
+
 include(DuneStreams)
 dune_set_minimal_debug_level()
 
@@ -62,6 +79,8 @@ add_definitions(-DHAVE_CONFIG_H)
 # add subdirectories to execute CMakeLists.txt there
 add_subdirectory("dune")
 
+set( CMAKE_FIND_LIBRARY_SUFFIXES ${_dune_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
+
 # set up CTest
 enable_testing()
 include(CTest)
-- 
GitLab