CPM.cmake
CPM.cmake copied to clipboard
Interaction between CPM_USE_LOCAL_PACKAGES and VERSION in CPMAddPackage
I am trying to get the following use case to work:
- Set CPM_USE_LOCAL_PACKAGES to ON
- Use CPMAddPackage to add a package, with a specific version
- Use the local package if it exists and is the right version, otherwise fallback to downloading it.
It seems to me that CPM_USE_LOCAL_PACKAGES will use a local package if it exists, regardless of the version.
For example, the following code:
set(CPM_USE_LOCAL_PACKAGES ON)
CPMAddPackage(
NAME benchmark
GITHUB_REPOSITORY google/benchmark
VERSION 1.5.2
OPTIONS "BENCHMARK_ENABLE_TESTING Off"
)
will use (and identify the version of) version 1.8.2 of benchmark on my machine if it's a local package, when CPM_USE_LOCAL_PACKAGES is ON. If CPM_USE_LOCAL_PACKAGES is OFF, it will download version 1.5.2, meaning that the versions differ between CPM_USE_LOCAL_PACKAGES ON vs OFF.
Is this intended behaviour? Is there any way to accomplish a version based fallback to downloading? Maybe I've missed something.
Thanks!