Skip to content

Commit

Permalink
Check PIKA_CUDA_STANDARD and CMAKE_CUDA_STANDARD compatibility only w…
Browse files Browse the repository at this point in the history
…hen building pika itself
  • Loading branch information
msimberg committed Aug 23, 2022
1 parent 82131af commit 52c6bbe
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions cmake/pika_setup_cuda.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ if(PIKA_WITH_CUDA AND NOT TARGET Cuda::cuda)
set(PIKA_WITH_CLANG_CUDA ON)
endif()

# Check CUDA standard
if(DEFINED CMAKE_CUDA_STANDARD AND NOT CMAKE_CUDA_STANDARD STREQUAL
PIKA_WITH_CXX_STANDARD
)
pika_error(
"You've set CMAKE_CUDA_STANDARD to ${CMAKE_CUDA_STANDARD} and PIKA_WITH_CXX_STANDARD to ${PIKA_WITH_CXX_STANDARD}. Please unset CMAKE_CUDA_STANDARD."
# Check and set CUDA standard
if(NOT PIKA_FIND_PACKAGE)
if(DEFINED CMAKE_CUDA_STANDARD AND NOT CMAKE_CUDA_STANDARD STREQUAL
PIKA_WITH_CXX_STANDARD
)
pika_error(
"You've set CMAKE_CUDA_STANDARD to ${CMAKE_CUDA_STANDARD} and PIKA_WITH_CXX_STANDARD to ${PIKA_WITH_CXX_STANDARD}. Please unset CMAKE_CUDA_STANDARD."
)
endif()

set(CMAKE_CUDA_STANDARD ${PIKA_WITH_CXX_STANDARD})
endif()

set(CMAKE_CUDA_STANDARD ${PIKA_WITH_CXX_STANDARD})
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_EXTENSIONS OFF)

Expand All @@ -39,7 +42,9 @@ if(PIKA_WITH_CUDA AND NOT TARGET Cuda::cuda)
target_link_libraries(Cuda::cuda INTERFACE CUDA::cublas CUDA::cusolver)
endif()
# Flag not working for CLANG CUDA
target_compile_features(Cuda::cuda INTERFACE cuda_std_${CMAKE_CUDA_STANDARD})
target_compile_features(
Cuda::cuda INTERFACE cuda_std_${PIKA_WITH_CXX_STANDARD}
)
set_target_properties(
Cuda::cuda PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE ON
)
Expand Down

0 comments on commit 52c6bbe

Please sign in to comment.