Skip to content

Check for CUDA headers rather than compiler#28

Open
sethrj wants to merge 3 commits intoroot-project:masterfrom
sethrj:cuda-header-config
Open

Check for CUDA headers rather than compiler#28
sethrj wants to merge 3 commits intoroot-project:masterfrom
sethrj:cuda-header-config

Conversation

@sethrj
Copy link

@sethrj sethrj commented Mar 4, 2026

Since VecCore is header-only, it needs only to check the CUDA toolkit location. This also avoids some odd side effects that occur with check_language (which can interfere with variables in enable_language). Additionally, use standard reporting for the library being found when loaded via find_package, and update the cmake to avoid warnings with newer versions.

@sethrj sethrj requested a review from amadio as a code owner March 4, 2026 19:42
@sethrj
Copy link
Author

sethrj commented Mar 4, 2026

@amadio I see the following message: is there something I need to do? If it's because of the move to @root-project, then perhaps a CONTRIBUTING.md describing PR requirements would help. Thanks!

Merging is blocked

@amadio
Copy link
Member

amadio commented Mar 4, 2026

@amadio I see the following message: is there something I need to do? If it's because of the move to @root-project, then perhaps a CONTRIBUTING.md describing PR requirements would help. Thanks!

Merging is blocked

This is just a message about commits requiring a GPG signature, I don't think you need to do anything. I will handle the merge when things are ready. The master branch is protected, though, pushing to it directly is restricted. I need to investigate what happened that the CI failed, though. Please make sure your branch is rebased on top of GitHub's tip of master and force-push, as the failure was to check out the commit before your changes, which should not have failed.

endif()
endif()

# Print a pretty message if the caller doesn't have a FindVecGeom.cmake
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/VecGeom/VecCore/

# Print a pretty message if the caller doesn't have a FindVecGeom.cmake
include(FindPackageHandleStandardArgs)
set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG "${CMAKE_CURRENT_LIST_FILE}")
find_package_handle_standard_args(@PROJECT_NAME@ CONFIG_MODE HANDLE_COMPONENTS)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably better to hard-code VecCore in these lines, to ensure things still work when VecCore is used inside another project with add_subdirectory(). However, with ROOT deprecating VecCore, if this is fine for VecGeom/Celeritas, it can stay like this.

set(VecCore_CUDA_FOUND True)
set(VecCore_CUDA_DEFINITIONS -DVECCORE_ENABLE_CUDA)
set(VecCore_CUDA_INCLUDE_DIR ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
set(VecCore_CUDA_INCLUDE_DIR ${CUDAToolkit_INCLUDE_DIRS})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain the motivation for this change? The current way of doing things follows advice from CMake policy CMP0146, which suggests projects should use CMake's first class support for cuda via check_language(CUDA)/enable_language(CUDA). The addition of -DVECCORE_ENABLE_CUDA does require that the CUDA language be enabled if you are compiling CUDA code, because that will enable host/device macros, etc. If you want to handle that yourself, you can always find_package(VecCore) without specifying the CUDA component, then add_definitions(VECCORE_ENABLE_CUDA) yourself, without having to change this logic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, this was last modified in this commit 743566f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants