diff --git a/CMakeLists.txt b/CMakeLists.txt index 3445e00e9..9cc0f06fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ set(DDC_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}) ## Custom cmake modules list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include(DDCCheckRequiredKokkosOptions) include(DDCVendorConfiguration) ## kokkos @@ -301,5 +302,6 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/DDCConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/DDCConfigVersion.cmake + ${CMAKE_CURRENT_BINARY_DIR}/DDCCheckRequiredKokkosOptions.cmake DESTINATION ${DDC_INSTALL_CMAKEDIR} ) diff --git a/cmake/DDCCheckRequiredKokkosOptions.cmake b/cmake/DDCCheckRequiredKokkosOptions.cmake new file mode 100644 index 000000000..81fa97a3a --- /dev/null +++ b/cmake/DDCCheckRequiredKokkosOptions.cmake @@ -0,0 +1,14 @@ +# Copyright (C) The DDC development team, see COPYRIGHT.md file +# +# SPDX-License-Identifier: MIT + +function(ddc_check_required_kokkos_options) + kokkos_check(DEVICES CUDA RETURN_VALUE is_cuda_enabled) + if("${is_cuda_enabled}") + kokkos_check(OPTIONS CUDA_CONSTEXPR CUDA_RELOCATABLE_DEVICE_CODE) + endif() + kokkos_check(DEVICES HIP RETURN_VALUE is_hip_enabled) + if("${is_hip_enabled}") + kokkos_check(OPTIONS HIP_RELOCATABLE_DEVICE_CODE) + endif() +endfunction() diff --git a/cmake/DDCConfig.cmake.in b/cmake/DDCConfig.cmake.in index a79627a27..811e34007 100644 --- a/cmake/DDCConfig.cmake.in +++ b/cmake/DDCConfig.cmake.in @@ -16,6 +16,9 @@ set(DDC_BUILD_DOUBLE_PRECISION @DDC_BUILD_DOUBLE_PRECISION@) ddc_find_dependency(Kokkos 4.4...<5) +include(${CMAKE_CURRENT_LIST_DIR}/DDCCheckRequiredKokkosOptions.cmake) +ddc_check_required_kokkos_options() + if(@DDC_BUILD_KERNELS_FFT@) ddc_find_dependency(KokkosFFT 0.2.1...<1) endif() diff --git a/cmake/DDCVendorConfiguration.cmake b/cmake/DDCVendorConfiguration.cmake index 7fa0b404e..a4da702a0 100644 --- a/cmake/DDCVendorConfiguration.cmake +++ b/cmake/DDCVendorConfiguration.cmake @@ -42,17 +42,6 @@ macro(ddc_configure_kokkos) add_subdirectory(vendor/kokkos) endmacro() -function(ddc_check_required_kokkos_options) - kokkos_check(DEVICES CUDA RETURN_VALUE is_cuda_enabled) - if("${is_cuda_enabled}") - kokkos_check(OPTIONS CUDA_CONSTEXPR CUDA_RELOCATABLE_DEVICE_CODE) - endif() - kokkos_check(DEVICES HIP RETURN_VALUE is_hip_enabled) - if("${is_hip_enabled}") - kokkos_check(OPTIONS HIP_RELOCATABLE_DEVICE_CODE) - endif() -endfunction() - macro(ddc_configure_kokkos_fft) option(KokkosFFT_ENABLE_HOST_AND_DEVICE "Enable FFT on both host and device" ON) add_subdirectory(vendor/kokkos-fft)