Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check PIKA_WITH_CXX_STANDARD and CMAKE_CUDA_STANDARD compatibility only when building pika itself #396

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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