New in version v21.06.00.
Allow projects to find or build arbitrary projects via CPM with built-in tracking of these dependencies for correct export support.
rapids_cpm_find(<PackageName> <version> [COMPONENTS <components...>] [GLOBAL_TARGETS <targets...>] [BUILD_EXPORT_SET <export-name>] [INSTALL_EXPORT_SET <export-name>] <CPM_ARGS> all normal CPM options )
Generate a CPM FindPackage call and associate this with the listed build and install export set for correct export generation.
Since the visibility of CMake’s targets differ between targets built locally and those
rapids_cpm_find() promotes imported targets to be global so users have
consistency. List all targets used by your project in GLOBAL_TARGET.
rapids_cpm_init() to be called before usage
Name of the package to find.
Version of the package you would like CPM to find.
New in version v22.10.00.
A list of required components that are required to be found for this package to be considered valid when doing a local search.
Which targets from this package should be made global. This information will be propagated to any associated export set.
Changed in version v21.10.00: If any targets listed in GLOBAL_TARGET exist when
rapids_cpm_find()is called no calls to CPM will be executed. This is done for the following reasons:
Removes the need for the calling code to do the conditional checks
Allows BUILD_EXPORT_SET and INSTALL_EXPORT_SET tracking to happen correctly when targets had already been brought it by non-CPM means.
Record that a
CPMFindPackage(<PackageName> ...)call needs to occur as part of our build directory export set.
find_dependency(<PackageName> ...)call needs to occur as part of our install directory export set.
Required placeholder to be provided before any extra arguments that need to be passed down to
<PackageName>_SOURCE_DIRis set to the path to the source directory of <PackageName>.
<PackageName>_BINARY_DIRis set to the path to the build directory of <PackageName>.
<PackageName>_ADDEDis set to a true value if <PackageName> has not been added before.
Adding an export set to
rapids_cpm_find() has different behavior
for build and install. Build exports a respective CPM call, since
we presume other CPM packages don’t generate a correct build directory
config module. While install exports a find_dependency call as
we expect projects to have a valid install setup.
If you need different behavior you will need to use
CPM_<PackageName>_SOURCE is set, we use
CPMAddPackage() instead of
CPMAddPackage() always adds the package at the desired
CPM_<PackageName>_SOURCE location, and won’t attempt to locate it via
Example on how to use
rapids_cpm_find() to include common projects
# fmt rapids_cpm_find(fmt 8.0.1 GLOBAL_TARGETS fmt::fmt CPM_ARGS GITHUB_REPOSITORY fmtlib/fmt GIT_TAG 8.0.1 GIT_SHALLOW TRUE ) # google benchmark, no GIT_TAG required since it uses `v<Version>` tags rapids_cpm_find(benchmark 1.5.2 CPM_ARGS GIT_REPOSITORY https://github.com/google/benchmark.git GIT_SHALLOW TRUE OPTIONS "BENCHMARK_ENABLE_TESTING OFF" "BENCHMARK_ENABLE_INSTALL OFF" )