From: Matthias Maier Date: Thu, 15 Apr 2021 04:48:56 +0000 (-0500) Subject: CMake: FindKOKKOS: Work around configuration failure X-Git-Tag: v9.3.0-rc1~223^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6158449cad959201962cba5a124c1d4bdfb9da57;p=dealii.git CMake: FindKOKKOS: Work around configuration failure Configuration did fail in the following situation - Kokkos installed via Trilinos (MPI enabled) - deal.II configured without MPI In this situation FindTRILINOS.cmake bails out because of an MPI configuration mismatch, so the manual search for Kokkos in FindKOKKOS.cmake is triggered. The latter one fails because Kokkos installed via Trilinos did export a valid project configuration only containing the Kokkos::kokkos target and not the Kokkos::kokkoscore target. Work around this issue by only configuring if Kokkos::kokkoscore has indeed been imported. --- diff --git a/cmake/modules/FindKOKKOS.cmake b/cmake/modules/FindKOKKOS.cmake index 05755ef022..6c39f3c7d9 100644 --- a/cmake/modules/FindKOKKOS.cmake +++ b/cmake/modules/FindKOKKOS.cmake @@ -35,10 +35,10 @@ ELSE() FIND_PACKAGE(Kokkos HINTS ${KOKKOS_DIR} ${Kokkos_DIR} $ENV{Kokkos_DIR} ) - + IF(Kokkos_FOUND) # We are only interested in Kokkos if it is not part of Trilinos - IF(TARGET Kokkos::kokkos) + IF(TARGET Kokkos::kokkos AND TARGET Kokkos::kokkoscore) GET_PROPERTY(KOKKOS_INSTALL_INCLUDE_DIR TARGET Kokkos::kokkos PROPERTY INTERFACE_INCLUDE_DIRECTORIES) GET_PROPERTY(KOKKOS_EXTRA_LD_FLAGS_FULL TARGET Kokkos::kokkoscore PROPERTY INTERFACE_LINK_OPTIONS) STRING(REGEX REPLACE "\\$<\\$:([^>]*)>" "\\1" KOKKOS_EXTRA_LD_FLAGS "${KOKKOS_EXTRA_LD_FLAGS_FULL}") @@ -49,14 +49,14 @@ ELSE() IF(KOKKOS_COMPILE_FLAGS) ADD_FLAGS(DEAL_II_CXX_FLAGS ${KOKKOS_COMPILE_FLAGS}) ENDIF() - + DEAL_II_FIND_LIBRARY(KOKKOS_CORE_LIBRARY NAMES kokkoscore HINTS ${KOKKOS_DIR}/lib ${Kokkos_DIR}/lib $ENV{Kokkos_DIR}/lib PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib ) - + DEAL_II_FIND_LIBRARY(KOKKOS_CONTAINERS_LIBRARY NAMES kokkoscontainers HINTS ${KOKKOS_DIR}/lib ${Kokkos_DIR}/lib $ENV{Kokkos_DIR}/lib @@ -67,7 +67,7 @@ ELSE() SET(Kokkos_FOUND FALSE) ENDIF() ENDIF() - + DEAL_II_PACKAGE_HANDLE(KOKKOS LIBRARIES REQUIRED KOKKOS_CORE_LIBRARY KOKKOS_CONTAINERS_LIBRARY INCLUDE_DIRS REQUIRED KOKKOS_INSTALL_INCLUDE_DIR @@ -75,5 +75,4 @@ ELSE() LINKER_FLAGS OPTIONAL KOKKOS_EXTRA_LD_FLAGS CLEAR KOKKOS_DIR KOKKOS_CORE_LIBRARY KOKKOS_CONTAINERS_LIBRARY ) - ENDIF()