From: Matthias Maier Date: Thu, 1 Dec 2022 16:46:01 +0000 (-0600) Subject: CMake: Bugfix: only add to the linker line what is needed X-Git-Tag: v9.5.0-rc1~773^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f73da44884b2992b08c4829679db24714412a4d3;p=dealii.git CMake: Bugfix: only add to the linker line what is needed 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. --- diff --git a/cmake/modules/FindDEAL_II_TRILINOS.cmake b/cmake/modules/FindDEAL_II_TRILINOS.cmake index 77c82e4153..7753f35ad7 100644 --- a/cmake/modules/FindDEAL_II_TRILINOS.cmake +++ b/cmake/modules/FindDEAL_II_TRILINOS.cmake @@ -132,7 +132,18 @@ if(TARGET Kokkos::kokkos) get_property(KOKKOS_COMPILE_FLAGS_FULL TARGET Kokkos::kokkos PROPERTY INTERFACE_COMPILE_OPTIONS) string(REGEX REPLACE "\\$<\\$:([^>]*)>" "\\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