Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/cpm_download_only' into fea…
Browse files Browse the repository at this point in the history
…t/force_spdlog_clone
  • Loading branch information
vyasr committed Jan 7, 2025
2 parents 7332587 + 33cf814 commit f364d61
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
13 changes: 12 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 @@ -46,6 +47,16 @@ generated information will include a :cmake:command:`CPMFindPackage` call for <P
``INSTALL``
Will record <PackageName> is part of the build directory export set
``CPM_ARGS``
Arguments to be passed to the generated CPM call.
``GLOBAL_TARGETS``
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 @@ -60,7 +71,7 @@ function(rapids_export_cpm type name export_set)
string(TOLOWER ${type} type)

set(options "")
set(one_value EXPORT_SET)
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 f364d61

Please sign in to comment.