]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Bugfix: only add to the linker line what is needed 14515/head
authorMatthias Maier <tamiko@43-1.org>
Thu, 1 Dec 2022 16:46:01 +0000 (10:46 -0600)
committerMatthias Maier <tamiko@43-1.org>
Thu, 1 Dec 2022 16:46:01 +0000 (10:46 -0600)
The `INTERFACE_LINK_LIBRARIES` option of the Kokkos target might contain
much more than we actually need. So restrict the fixup to finding the
missing linker flag and adding this one.

This works around an issue with the regression tester where the link
interface of the Kokkos::kokkos target contains entries that make the
final link fail.

cmake/modules/FindDEAL_II_TRILINOS.cmake

index 77c82e415392c510b3676c3baa60521f1d4e74f8..7753f35ad7e643425bbdb686ffe8b4f8d80098ab 100644 (file)
@@ -132,7 +132,18 @@ if(TARGET Kokkos::kokkos)
   get_property(KOKKOS_COMPILE_FLAGS_FULL TARGET Kokkos::kokkos PROPERTY INTERFACE_COMPILE_OPTIONS)
   string(REGEX REPLACE "\\$<\\$<COMPILE_LANGUAGE:CXX>:([^>]*)>" "\\1" KOKKOS_COMPILE_FLAGS "${KOKKOS_COMPILE_FLAGS_FULL}")
   string(REPLACE ";" " " KOKKOS_COMPILE_FLAGS "${KOKKOS_COMPILE_FLAGS}")
-  get_property(KOKKOS_LINK_LIBRARIES TARGET Kokkos::kokkos PROPERTY INTERFACE_LINK_LIBRARIES)
+
+  #
+  # Extract missing openmp linker options from the
+  # "INTERFACE_LINK_LIBRARIES" property of the Kokkos::kokkos target:
+  #
+  set(_kokkos_openmp_flags)
+  get_property(_libraries TARGET Kokkos::kokkos PROPERTY INTERFACE_LINK_LIBRARIES)
+  foreach(_entry ${_libraries})
+    if(${_entry} MATCHES "^-f?openmp")
+      add_flags(_kokkos_openmp_flags "${_entry}")
+    endif()
+  endforeach()
 endif()
 
 #
@@ -159,14 +170,14 @@ endforeach()
 process_feature(TRILINOS
   LIBRARIES
     REQUIRED ${_libraries}
-    OPTIONAL Trilinos_TPL_LIBRARIES MPI_CXX_LIBRARIES KOKKOS_LINK_LIBRARIES
+    OPTIONAL Trilinos_TPL_LIBRARIES MPI_CXX_LIBRARIES
   INCLUDE_DIRS
     REQUIRED Trilinos_INCLUDE_DIRS
     OPTIONAL Trilinos_TPL_INCLUDE_DIRS
   CXX_FLAGS
     OPTIONAL KOKKOS_COMPILE_FLAGS
   LINKER_FLAGS
-    OPTIONAL Trilinos_EXTRA_LD_FLAGS
+  OPTIONAL Trilinos_EXTRA_LD_FLAGS _kokkos_openmp_flags
   CLEAR
     TRILINOS_CONFIG_DIR EPETRA_CONFIG_H SACADO_CMATH_HPP ${_libraries}
     SACADO_CONFIG_H

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.