From 1b4f436092c6352074645f01c445ffe68141fe94 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 27 Nov 2024 18:17:54 +0000 Subject: [PATCH] First pass at enabling CPM download by default. --- rapids-cmake/export/cpm.cmake | 6 +++++- rapids-cmake/export/template/cpm.cmake.in | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/rapids-cmake/export/cpm.cmake b/rapids-cmake/export/cpm.cmake index 3c55cff3..cb97dece 100644 --- a/rapids-cmake/export/cpm.cmake +++ b/rapids-cmake/export/cpm.cmake @@ -31,6 +31,7 @@ given export set CPM_ARGS [GLOBAL_TARGETS ] + [DEFAULT_DOWNLOAD_OPTION ] ) @@ -53,6 +54,9 @@ generated information will include a :cmake:command:`CPMFindPackage` call for

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 @@ -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}) diff --git a/rapids-cmake/export/template/cpm.cmake.in b/rapids-cmake/export/template/cpm.cmake.in index e293e0f8..5ac2d1fe 100644 --- a/rapids-cmake/export/template/cpm.cmake.in +++ b/rapids-cmake/export/template/cpm.cmake.in @@ -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)