]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: FindKOKKOS: Work around configuration failure 12044/head
authorMatthias Maier <tamiko@43-1.org>
Thu, 15 Apr 2021 04:48:56 +0000 (23:48 -0500)
committerMatthias Maier <tamiko@43-1.org>
Thu, 15 Apr 2021 04:51:47 +0000 (23:51 -0500)
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.

cmake/modules/FindKOKKOS.cmake

index 05755ef0222baad5abbcdc53692a18c7e3f79429..6c39f3c7d9f5e22a7df013b98eef64f000c223e0 100644 (file)
@@ -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 "\\$<\\$<LINK_LANGUAGE:CXX>:([^>]*)>" "\\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()

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.