Skip to content

Commit

Permalink
Merged in fix_cuda_libs (pull request #211)
Browse files Browse the repository at this point in the history
switch to cmake native find-cuda-libraries
  • Loading branch information
mkstoyanov committed Oct 21, 2022
2 parents 5ea5bf8 + 3697350 commit abb8f0d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
30 changes: 21 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,27 @@ endif()

# build CPU libheffte, the CUDA test comes first to use cuda_add_library() vs add_library()
if (Heffte_ENABLE_CUDA)
find_package(CUDA REQUIRED)

list(APPEND CUDA_NVCC_FLAGS "-std=c++11")
cuda_add_library(Heffte ${Heffte_common_sources}
include/heffte_backend_cuda.h
src/heffte_backend_cuda.cu)

cuda_add_cufft_to_target(Heffte)
target_include_directories(Heffte PUBLIC $<INSTALL_INTERFACE:${CUDA_INCLUDE_DIRS}>)
if (CMAKE_VERSION VERSION_LESS 3.17)
find_package(CUDA REQUIRED)

list(APPEND CUDA_NVCC_FLAGS "-std=c++11")
cuda_add_library(Heffte ${Heffte_common_sources}
include/heffte_backend_cuda.h
src/heffte_backend_cuda.cu)

cuda_add_cufft_to_target(Heffte)
target_include_directories(Heffte PUBLIC $<INSTALL_INTERFACE:${CUDA_INCLUDE_DIRS}>)
else()
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
list(APPEND Heffte_common_sources
include/heffte_backend_cuda.h
src/heffte_backend_cuda.cu
)
set_source_files_properties(include/heffte_backend_cuda.h src/heffte_backend_cuda.cu PROPERTIES LANGUAGE CUDA)
add_library(Heffte ${Heffte_common_sources})
target_link_libraries(Heffte CUDA::cufft CUDA::cudart)
endif()
else()
add_library(Heffte ${Heffte_common_sources})
endif()
Expand Down
12 changes: 9 additions & 3 deletions cmake/HeffteConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ if (@Heffte_ENABLE_ONEAPI@ AND NOT TARGET Heffte::OneMKL)
endif()

if (@Heffte_ENABLE_CUDA@)
if (NOT CUDA_TOOLKIT_ROOT_DIR AND NOT "@CUDA_TOOLKIT_ROOT_DIR@" STREQUAL "")
set(CUDA_TOOLKIT_ROOT_DIR @CUDA_TOOLKIT_ROOT_DIR@)
if (CMAKE_VERSION VERSION_LESS 3.17)
if (NOT CUDA_TOOLKIT_ROOT_DIR AND NOT "@CUDA_TOOLKIT_ROOT_DIR@" STREQUAL "")
set(CUDA_TOOLKIT_ROOT_DIR @CUDA_TOOLKIT_ROOT_DIR@)
endif()
find_package(CUDA REQUIRED)
else()
if (NOT TARGET CUDA::cufft)
find_package(CUDAToolkit REQUIRED)
endif()
endif()
find_package(CUDA REQUIRED)
endif()

if (@Heffte_ENABLE_MAGMA@ AND NOT TARGET Heffte::MAGMA)
Expand Down

0 comments on commit abb8f0d

Please sign in to comment.