From 6c55942c5ea69e66df4f8abad1d754034a20c00f Mon Sep 17 00:00:00 2001 From: Andrey Prokopenko Date: Mon, 11 Dec 2023 13:31:24 -0500 Subject: [PATCH] Retain the original path to Kokkos and ArborX --- cmake/CabanaConfig.cmakein | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmake/CabanaConfig.cmakein b/cmake/CabanaConfig.cmakein index a6ae0cdce..15b82af58 100644 --- a/cmake/CabanaConfig.cmakein +++ b/cmake/CabanaConfig.cmakein @@ -12,14 +12,24 @@ include(CMakeFindDependencyMacro) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}" ) list(APPEND CMAKE_PREFIX_PATH @CMAKE_PREFIX_PATH@) -find_dependency(Kokkos REQUIRED) +find_package(Kokkos QUIET) +if(NOT Kokkos_FOUND) + # If Kokkos was not found, try to use Kokkos used when building Cabana + set(Kokkos_DIR @Kokkos_DIR@) + find_dependency(Kokkos) +endif() set(Cabana_ENABLE_MPI @Cabana_ENABLE_MPI@) if(Cabana_ENABLE_MPI) find_dependency(MPI REQUIRED CXX) endif() set(Cabana_ENABLE_ARBORX @Cabana_ENABLE_ARBORX@) if(Cabana_ENABLE_ARBORX) - find_dependency(ArborX REQUIRED) + find_package(ArborX QUIET) + if(NOT ArborX_FOUND) + # If ArborX was not found, try to use ArborX used when building Cabana + set(ArborX_DIR @ArborX_DIR@) + find_dependency(ArborX) + endif() endif() set(Cabana_ENABLE_GRID @Cabana_ENABLE_GRID@) set(Cabana_ENABLE_CAJITA @Cabana_ENABLE_CAJITA@) # FIXME: remove in next release