Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions rapids-cmake/export/export.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2021-2024, NVIDIA CORPORATION.
# Copyright (c) 2021-2025, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -213,7 +213,10 @@ function(rapids_export type project_name)
unset(_RAPIDS_VERSION) # unset this so we don't export a version value of `OFF`
elseif(NOT DEFINED _RAPIDS_VERSION AND NOT DEFINED PROJECT_VERSION)
set(rapids_version_set OFF)
elseif(DEFINED PROJECT_VERSION AND NOT DEFINED _RAPIDS_VERSION)
elseif(DEFINED PROJECT_VERSION AND NOT PROJECT_VERSION)
# PROJECT_VERSION is defined as a empty string / false value
set(rapids_version_set OFF)
elseif(DEFINED PROJECT_VERSION AND PROJECT_VERSION AND NOT DEFINED _RAPIDS_VERSION)
# Choose the project version when an explicit version isn't provided
set(_RAPIDS_VERSION "${PROJECT_VERSION}")
endif()
Expand Down
12 changes: 10 additions & 2 deletions rapids-cmake/export/template/build_package.cmake.in
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#=============================================================================
# find_dependency Search for @name@
# __find_dependency_no_return Search for @name@
#
# Make sure we search for a build-dir config module for the project
set(possible_package_dir "@possible_dir@")
if(possible_package_dir AND NOT DEFINED @name@_DIR)
set(@name@_DIR "${possible_package_dir}")
endif()

find_dependency(@name@)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.2.0)
__find_dependency_no_return(@name@)
Copy link
Member

Choose a reason for hiding this comment

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

I'm hesitant to sign off on using an undocumented command like this. How much assurance do we have that its interface won't change? Do we at least have a way to test that it's still working properly?

Copy link

@nickelpro nickelpro Aug 4, 2025

Choose a reason for hiding this comment

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

It's now used by CMake's own EXPORT_PACKAGE_DEPENENCIES, so its no less stable than that.

But EXPORT_PACKAGE_DEPENDENCIES is still gated, so might change. I think it's reasonable for us to promote this to a non-underscore name within CMake.

Choose a reason for hiding this comment

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

It might be reasonable to accept this while 4.2.0 is still in the oven (4.1.0 is still in rc status), so it can get some "real-world" testing, and re-visit prior to 4.2.0 full release.

As I'm not sure what __find_dependency_no_return's final form will be just yet.

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 now used by CMake's own EXPORT_PACKAGE_DEPENENCIES, so its no less stable than that.

I disagree. I worked on CMake long enough to know that even if the interface to EXPORT_PACKAGE_DEPENDENCIES is stable, the underlying implementation details (which include this function) are not. If we're going to use an undocumented function in this manner, I want assurance that we have some sort of unit test that will tell us when the functionality is broken because the interface to the internal API changed.

Copy link
Member

Choose a reason for hiding this comment

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

It might be reasonable to accept this while 4.2.0 is still in the oven (4.1.0 is still in rc status), so it can get some "real-world" testing, and re-visit prior to 4.2.0 full release.

Unfortunately, this won't work. The master branch of CMake has version number 4.1.20250804, and won't roll over to 4.2 until we get to 4.2.0-rc1. If we want real-world testing before 4.2, we need to change the version number to 4.1.20250804 (or whatever nightly build introduced the internal function that we're using.)

Copy link
Contributor Author

@robertmaynard robertmaynard Aug 4, 2025

Choose a reason for hiding this comment

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

Our other option is to use find_package only in our generated code. We would use ${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED and ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY to match the behavior of find_dependency but wouldn't tie us to this undocumented function

Copy link
Member

Choose a reason for hiding this comment

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

That sounds reasonable to me.

Choose a reason for hiding this comment

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

I disagree. I worked on CMake long enough to know that even if the interface to EXPORT_PACKAGE_DEPENDENCIES is stable, the underlying implementation details (which include this function) are not.

Because this function is exposed in generated export files that get shipped in downstream packages, we have an obligation to maintain whatever interface gets shipped once EXPORT_PACKAGE_DEPENDENCIES gets out of experimental gate. If that happened today it would be __cmake_find_dependencies_no_return. I'm just not sure what it will be when the gate is actually removed.

if(NOT @name@_FOUND)
unset(_cmake_unwind_arg)
return()
endif()
else()
find_dependency(@name@)
endif()

if(possible_package_dir)
unset(possible_package_dir)
Expand Down
14 changes: 12 additions & 2 deletions rapids-cmake/export/template/build_package_components.cmake.in
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
#=============================================================================
# find_dependency Search for @name@
# __find_dependency_no_return Search for @name@
#
# Make sure we search for a build-dir config module for the project
set(possible_package_dir "@possible_dir@")
if(possible_package_dir AND NOT DEFINED @name@_DIR)
set(@name@_DIR "${possible_package_dir}")
endif()

find_dependency(@name@ COMPONENTS @components@)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.2.0)
__find_dependency_no_return(@name@ COMPONENTS @components@)
if(NOT @name@_FOUND)
unset(_cmake_unwind_arg)
return()
endif()
else()
find_dependency(@name@ COMPONENTS @components@)
endif()



if(possible_package_dir)
unset(possible_package_dir)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
#=============================================================================
# find_dependency Search for @name@
# __find_dependency_no_return Search for @name@
#
# Make sure we search for a build-dir config module for the project
set(possible_package_dir "@possible_dir@")
if(possible_package_dir AND NOT DEFINED @name@_DIR)
set(@name@_DIR "${possible_package_dir}")
endif()

find_package(@name@ @version@ QUIET COMPONENTS @components@)
find_dependency(@name@ COMPONENTS @components@)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.2.0)
find_package(@name@ @version@ QUIET UNWIND_INCLUDE COMPONENTS @components@)
__find_dependency_no_return(@name@ COMPONENTS @components@)
if(NOT @name@_FOUND)
unset(_cmake_unwind_arg)
return()
endif()
else()
find_package(@name@ @version@ QUIET COMPONENTS @components@)
find_dependency(@name@ COMPONENTS @components@)
endif()


if(possible_package_dir)
unset(possible_package_dir)
Expand Down
15 changes: 12 additions & 3 deletions rapids-cmake/export/template/build_package_versioned.cmake.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
#=============================================================================
# find_dependency Search for @name@
# __find_dependency_no_return Search for @name@
#
# Make sure we search for a build-dir config module for the project
set(possible_package_dir "@possible_dir@")
if(possible_package_dir AND NOT DEFINED @name@_DIR)
set(@name@_DIR "${possible_package_dir}")
endif()

find_package(@name@ @version@ QUIET)
find_dependency(@name@)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.2.0)
find_package(@name@ @version@ QUIET UNWIND_INCLUDE)
__find_dependency_no_return(@name@)
if(NOT @name@_FOUND)
unset(_cmake_unwind_arg)
return()
endif()
else()
find_package(@name@ @version@ QUIET)
find_dependency(@name@)
endif()

if(possible_package_dir)
unset(possible_package_dir)
Expand Down
10 changes: 9 additions & 1 deletion rapids-cmake/export/template/install_package.cmake.in
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
find_dependency(@name@)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.2.0)
__find_dependency_no_return(@name@)
if(NOT @name@_FOUND)
unset(_cmake_unwind_arg)
return()
endif()
else
find_dependency(@name@)
endif()
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
find_dependency(@name@ COMPONENTS @components@)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.2.0)
__find_dependency_no_return(@name@ COMPONENTS @components@)
if(NOT @name@_FOUND)
unset(_cmake_unwind_arg)
return()
endif()
else
find_dependency(@name@)
endif()
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
find_package(@name@ @version@ QUIET COMPONENTS @components@)
find_dependency(@name@ COMPONENTS @components@)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.2.0)
find_package(@name@ @version@ QUIET UNWIND_INCLUDE COMPONENTS @components@)
__find_dependency_no_return(@name@ COMPONENTS @components@)
if(NOT @name@_FOUND)
unset(_cmake_unwind_arg)
return()
endif()
else
find_package(@name@ @version@ QUIET COMPONENTS @components@)
find_dependency(@name@ COMPONENTS @components@)
endif()
13 changes: 11 additions & 2 deletions rapids-cmake/export/template/install_package_versioned.cmake.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
find_package(@name@ @version@ QUIET)
find_dependency(@name@)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.2.0)
find_package(@name@ @version@ QUIET UNWIND_INCLUDE)
__find_dependency_no_return(@name@)
if(NOT @name@_FOUND)
unset(_cmake_unwind_arg)
return()
endif()
else()
find_package(@name@ @version@ QUIET)
find_dependency(@name@)
endif()
1 change: 1 addition & 0 deletions testing/cuda/init_arch-all-via-undef/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ include(${rapids-cmake-dir}/cuda/init_architectures.cmake)
cmake_minimum_required(VERSION 3.30.4)

unset(CMAKE_CUDA_ARCHITECTURES)
unset(CMAKE_CUDA_ARCHITECTURES CACHE)
unset(ENV{CUDAARCHS})

rapids_cuda_init_architectures(rapids-project)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ endif()

# verify that the expected version is in FAKE_PACKAGE.cmake
set(to_match_string [=[22.08 QUIET]=])
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.1.0)
string(APPEND to_match_string [=[ UNWIND_INCLUDE]=])
endif()
file(READ "${path}" contents)
string(FIND "${contents}" "${to_match_string}" is_found)
if(is_found EQUAL -1)
Expand Down
6 changes: 5 additions & 1 deletion testing/export/export_package-build-with-version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ if(NOT EXISTS "${path}")
endif()

# verify that the expected version is in FAKE_PACKAGE.cmake
set(to_match_string [=[22.08 QUIET)]=])
set(to_match_string [=[22.08 QUIET]=])
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.1.0)
string(APPEND to_match_string [=[ UNWIND_INCLUDE]=])
endif()

file(READ "${path}" contents)
string(FIND "${contents}" "${to_match_string}" is_found)
if(is_found EQUAL -1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ if(NOT EXISTS "${path}")
endif()

# verify that the expected version exists in FAKE_PACKAGE.cmake
set(to_match_string [=[14.7.2 QUIET)]=])
set(to_match_string [=[14.7.2 QUIET]=])
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.1.0)
string(APPEND to_match_string [=[ UNWIND_INCLUDE]=])
endif()

file(READ "${path}" contents)
string(FIND "${contents}" "${to_match_string}" is_found)
if(is_found EQUAL -1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ rapids_export_write_dependencies(install test_set "${CMAKE_CURRENT_BINARY_DIR}/e
file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/export_set.cmake" text)

set(cpm_command_count 0)
set(find_dependency_no_return_command_count 0)
set(find_dependency_command_count 0)
foreach(line IN LISTS text)
# message(STATUS "1. line: ${line}")
if(line MATCHES "CPMFindPackage")
math(EXPR cpm_command_count "${cpm_command_count} + 1")
elseif(line MATCHES "__find_dependency_no_return")
math(EXPR find_dependency_no_return_command_count
"${find_dependency_no_return_command_count} + 1")
elseif(line MATCHES "find_dependency")
math(EXPR find_dependency_command_count "${find_dependency_command_count} + 1")
endif()
Expand All @@ -46,6 +50,11 @@ if(NOT cpm_command_count EQUAL 1)
)
endif()

if(NOT find_dependency_no_return_command_count EQUAL 2)
message(FATAL_ERROR "Incorrect number of find_dependency entries found. Expected 2, counted ${find_dependency_no_return_command_count}"
)
endif()

if(NOT find_dependency_command_count EQUAL 2)
message(FATAL_ERROR "Incorrect number of find_dependency entries found. Expected 2, counted ${find_dependency_command_count}"
)
Expand Down
6 changes: 5 additions & 1 deletion testing/find/find_package-components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ if(NOT (DEFINED FakeDependency_A_FOUND AND DEFINED FakeDependency_B_FOUND AND DE
message(FATAL_ERROR "rapids_find_package() failed to propagate COMPONENT A B C")
endif()

set(to_match_string "find_package(FakeDependency 11 QUIET COMPONENTS A;B;C)")
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.1.0)
set(to_match_string "find_package(FakeDependency 11 QUIET UNWIND_INCLUDE COMPONENTS A;B;C)")
else()
set(to_match_string "find_package(FakeDependency 11 QUIET COMPONENTS A;B;C)")
endif()

set(path "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/build/package_FakeDependency.cmake")
file(READ "${path}" contents)
Expand Down
8 changes: 7 additions & 1 deletion testing/find/find_package-version-explicit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ include(${rapids-cmake-dir}/find/package.cmake)
rapids_find_package(CUDAToolkit 11 REQUIRED INSTALL_EXPORT_SET test_export_set
BUILD_EXPORT_SET test_export_set)

set(to_match_string "find_package(CUDAToolkit 11 QUIET)")
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.1.0)
set(to_match_string "find_package(CUDAToolkit 11 QUIET UNWIND_INCLUDE)")
else()
set(to_match_string "find_package(CUDAToolkit 11 QUIET)")
endif()

set(path "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/build/package_CUDAToolkit.cmake")
file(READ "${path}" contents)
Expand All @@ -45,6 +49,8 @@ endif()

set(path "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/install/package_CUDAToolkit.cmake")
file(READ "${path}" contents)
message(STATUS "contents: ${contents}")
message(STATUS "to_match_string: ${to_match_string}")
string(FIND "${contents}" "${to_match_string}" is_found)
if(is_found EQUAL -1)
message(FATAL_ERROR "rapids_find_package(INSTALL) failed to preserve version information in exported file"
Expand Down
6 changes: 5 additions & 1 deletion testing/find/find_package-version-none.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ rapids_find_package(CUDAToolkit REQUIRED INSTALL_EXPORT_SET test_export_set

# no version specified at find time, verify none recorded If we record the found version we break
# things like CUDA backwards runtime compat
set(to_match_string "find_dependency(CUDAToolkit)")
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.1.0)
set(to_match_string "__find_dependency_no_return(CUDAToolkit)")
else()
set(to_match_string "find_dependency(CUDAToolkit)")
endif()

set(path "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/build/package_CUDAToolkit.cmake")
file(READ "${path}" contents)
Expand Down
Loading