Add per package CPM_DOWNLOAD controls (#336)

* Add per project CPM_DOWNLOAD controls

Introduces support for `CPM_<PACKAGE>_DOWNLOAD` variable ( and env )
which allows finer grained control.

* Address PR feedback on API names
This commit is contained in:
Robert Maynard
2022-02-11 13:37:32 -05:00
committed by GitHub
parent 865648e7bd
commit 005f202655
2 changed files with 8 additions and 1 deletions

View File

@@ -183,6 +183,7 @@ You can use `CPM_SOURCE_CACHE` on GitHub Actions workflows [cache](https://githu
If set, CPM will forward all calls to `CPMFindPackage` as `CPMAddPackage`.
This is useful to create reproducible builds or to determine if the source parameters have all been set correctly.
This can also be set as an environmental variable.
This can be controlled on a per package basis with the `CPM_DOWNLOAD_<dependency name>` variable.
### CPM_USE_LOCAL_PACKAGES

View File

@@ -251,7 +251,13 @@ function(CPMFindPackage)
endif()
endif()
if(CPM_DOWNLOAD_ALL)
set(downloadPackage ${CPM_DOWNLOAD_ALL})
if(DEFINED CPM_DOWNLOAD_${CPM_ARGS_NAME})
set(downloadPackage ${CPM_DOWNLOAD_${CPM_ARGS_NAME}})
elseif(DEFINED ENV{CPM_DOWNLOAD_${CPM_ARGS_NAME}})
set(downloadPackage $ENV{CPM_DOWNLOAD_${CPM_ARGS_NAME}})
endif()
if(downloadPackage)
CPMAddPackage(${ARGN})
cpm_export_variables(${CPM_ARGS_NAME})
return()