11cmake_minimum_required (VERSION 3.19...3.25 )
2- project (s2fft LANGUAGES CXX )
2+ project (s2fft LANGUAGES CXX CUDA )
33
44message (STATUS "Using CMake version: ${CMAKE_VERSION} " )
55
@@ -13,15 +13,13 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
1313 set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" )
1414endif ()
1515
16- # Include directories
17- include_directories (${CMAKE_CURRENT_LIST_DIR} /lib )
18-
1916# Check for CUDA
2017include (CheckLanguage )
2118check_language (CUDA )
2219
2320if (CMAKE_CUDA_COMPILER )
2421 enable_language (CUDA )
22+ find_package (CUDAToolkit REQUIRED )
2523 message (STATUS "CUDA compiler found: ${CMAKE_CUDA_COMPILER} " )
2624
2725 if (NOT SKBUILD )
@@ -47,9 +45,15 @@ if(CMAKE_CUDA_COMPILER)
4745 set_target_properties (_s2fftExe PROPERTIES CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES} " )
4846
4947 else ()
48+ find_package (CUDAToolkit REQUIRED )
49+
5050 find_package (Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED )
5151
52- add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /ext/nanobind )
52+ # Detect the installed nanobind package and import it into CMake
53+ execute_process (
54+ COMMAND "${Python_EXECUTABLE} " -m nanobind --cmake_dir
55+ OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE nanobind_ROOT )
56+ find_package (nanobind CONFIG REQUIRED )
5357
5458 nanobind_add_module (_s2fft STABLE_ABI
5559 ${CMAKE_CURRENT_LIST_DIR} /lib/src/extensions.cc
@@ -77,7 +81,10 @@ else()
7781
7882 find_package (Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED )
7983
80- add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /ext/nanobind )
84+ execute_process (
85+ COMMAND "${Python_EXECUTABLE} " -m nanobind --cmake_dir
86+ OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE nanobind_ROOT )
87+ find_package (nanobind CONFIG REQUIRED )
8188
8289 nanobind_add_module (_s2fft STABLE_ABI
8390 ${CMAKE_CURRENT_LIST_DIR} /lib/src/extensions.cc
@@ -94,3 +101,4 @@ else()
94101 endif ()
95102endif ()
96103
104+
0 commit comments