Skip to content

Commit

Permalink
Add per package CPM_DOWNLOAD controls (#336)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
robertmaynard authored Feb 11, 2022
1 parent 865648e commit 005f202
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion cmake/CPM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 005f202

Please sign in to comment.