]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Fix static executable build for cmake 3.9 and newer 10750/head
authorMatthias Maier <tamiko@43-1.org>
Fri, 24 Jul 2020 14:42:17 +0000 (09:42 -0500)
committerMatthias Maier <tamiko@43-1.org>
Fri, 24 Jul 2020 14:45:16 +0000 (09:45 -0500)
We have to filter the shared low-level runtime library "gcc_s" from the
link interface to work around a change in the CMake configuration of
Fortran.

Closes #9184

cmake/modules/FindLAPACK.cmake

index b512b26070c6daa4bbaabd25ed99c76c7bcc93a1..f56c5b8a4e214b2e0d5799b7a2a0f71a5c8f78a0 100644 (file)
@@ -82,12 +82,23 @@ ENDIF()
 # If CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES is not available, do it
 # unconditionally for the most common case (gfortran).
 #
-SET(_fortran_libs ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
-SET_IF_EMPTY(_fortran_libs gfortran m quadmath c)
-FOREACH(_lib ${_fortran_libs})
-  FIND_SYSTEM_LIBRARY(${_lib}_LIBRARY NAMES ${_lib})
-  LIST(APPEND _additional_libraries ${_lib}_LIBRARY)
-ENDFOREACH()
+IF(NOT BUILD_SHARED_LIBS)
+  SET(_fortran_libs ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
+  #
+  # Since CMake 3.9 the gcc runtime libraries libgcc.a and libgcc_s.so.1
+  # have been added to the CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES variable.
+  # We thus have to remove the shared low-level runtime library
+  # libgcc_s.so.1 from the link interface; otherwise completely static
+  # linkage is broken.
+  #
+  LIST(REMOVE_ITEM _fortran_libs gcc_s)
+  SET_IF_EMPTY(_fortran_libs gfortran quadmath m)
+
+  FOREACH(_lib ${_fortran_libs})
+    FIND_SYSTEM_LIBRARY(${_lib}_LIBRARY NAMES ${_lib})
+    LIST(APPEND _additional_libraries ${_lib}_LIBRARY)
+  ENDFOREACH()
+ENDIF()
 
 
 SET(_lapack_include_dirs ${LAPACK_INCLUDE_DIRS})

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.