Skip to content

Commit

Permalink
First pass at enabling CPM download by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasr committed Jan 7, 2025
1 parent 0f958da commit 1b4f436
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
6 changes: 5 additions & 1 deletion rapids-cmake/export/cpm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ given export set
<ExportSet>
CPM_ARGS <standard cpm args>
[GLOBAL_TARGETS <targets...>]
[DEFAULT_DOWNLOAD_OPTION <option_name>]
)
Expand All @@ -53,6 +54,9 @@ generated information will include a :cmake:command:`CPMFindPackage` call for <P
Which targets from this package should be made global. This information
will be propagated to any associated export set.
``DEFAULT_DOWNLOAD_OPTION``
If set, expose an option <option_name> in the config to use CPMAddPackage instead of CPMFindPackage. The option will default to true.
.. note::
It is an anti-pattern to use this command with `INSTALL` as most CMake
based projects should be installed, and :cmake:command:`rapids_export_package(INSTALL` used
Expand All @@ -67,7 +71,7 @@ function(rapids_export_cpm type name export_set)
string(TOLOWER ${type} type)

set(options "")
set(one_value)
set(one_value DEFAULT_DOWNLOAD_OPTION)
set(multi_value GLOBAL_TARGETS CPM_ARGS)
cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN})

Expand Down
19 changes: 16 additions & 3 deletions rapids-cmake/export/template/cpm.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,22 @@ if(possible_package_dir AND NOT DEFINED @name@_DIR)
set(@name@_DIR "${possible_package_dir}")
endif()

CPMFindPackage(
"@_RAPIDS_CPM_ARGS@"
)
if(NOT "@_RAPIDS_DEFAULT_DOWNLOAD_OPTION@" STREQUAL "")
option(@_RAPIDS_DEFAULT_DOWNLOAD_OPTION@ "Whether or not to download @name@" ON)
if(@_RAPIDS_DEFAULT_DOWNLOAD_OPTION@)
CPMAddPackage(
"@_RAPIDS_CPM_ARGS@"
)
else()
CPMFindPackage(
"@_RAPIDS_CPM_ARGS@"
)
endif()
else()
CPMFindPackage(
"@_RAPIDS_CPM_ARGS@"
)
endif()

if(possible_package_dir)
unset(possible_package_dir)
Expand Down

0 comments on commit 1b4f436

Please sign in to comment.