Closed dalg24 closed 1 year ago
For me,
diff --git a/Exercises/common.cmake b/Exercises/common.cmake
index ed081b7..933fcf0 100644
--- a/Exercises/common.cmake
+++ b/Exercises/common.cmake
@@ -8,21 +8,12 @@ endif()
set(Kokkos_COMMON_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../dep/Kokkos)
-include(FetchContent)
-if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
- FetchContent_Declare(
- Kokkos
- GIT_REPOSITORY https://github.com/kokkos/kokkos.git
- GIT_TAG 4.0.01
- SOURCE_DIR ${Kokkos_COMMON_SOURCE_DIR}
- FIND_PACKAGE_ARGS
- )
- FetchContent_MakeAvailable(Kokkos)
-
- find_package(Kokkos REQUIRED)
-else()
- find_package(Kokkos)
- if(NOT Kokkos_FOUND)
+find_package(Kokkos QUIET)
+if(NOT Kokkos_FOUND)
+ if(EXISTS ${Kokkos_COMMON_SOURCE_DIR})
+ add_subdirectory(${Kokkos_COMMON_SOURCE_DIR} Kokkos)
+ else()
+ include(FetchContent)
FetchContent_Declare(
Kokkos
GIT_REPOSITORY https://github.com/kokkos/kokkos.git
works well and only downloads Kokkos once.
One downside with the approach you suggested is that if Kokkos is found, because of the QUIET option, it will not print what backends are enabled.
One downside with the approach you suggested is that if Kokkos is found, because of the QUIET option, it will not print what backends are enabled.
Then do
find_package (Kokkos CONFIG)
Enables doing
One caveat is that, as currently proposed would download Kokkos instead of using an external install. If using CMake 3.24 one can do
which would bypass the fetch content.
Let me know what you think. I would do the same for KokkosKernels once we can agree on something