Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rapids_cpm_package_override now hooks into FetchContent #164

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions rapids-cmake/cpm/package_override.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ By default when an override for a project is provided no local search
for that project will occur. This is done to make sure that the requested modified
version is used.

If a project is listed in multiple override files, the first file values will be used,
and all later calls for that packaged will be ignored. This "first to record, wins"
approach is used to match FetchContent, and allows parent projects to override child
projects.

.. note::

If the override file doesn't specify a value or package entry the default
Expand All @@ -62,13 +67,25 @@ function(rapids_cpm_package_override filepath)
string(JSON package_count LENGTH "${json_data}" packages)
math(EXPR package_count "${package_count} - 1")

# For each project cache the subset of the json for that project in a global property
# For each project cache the subset of the json for that project in a global property so that
# packasge_details.cmake can fetch that information
if(package_count GREATER_EQUAL 0)
# cmake-lint: disable=E1120
foreach(index RANGE ${package_count})
string(JSON package_name MEMBER "${json_data}" packages ${index})
string(JSON data GET "${json_data}" packages "${package_name}")
set_property(GLOBAL PROPERTY rapids_cpm_${package_name}_override_json "${data}")
get_property(override_exists GLOBAL PROPERTY rapids_cpm_${package_name}_override_json DEFINED)
if(NOT override_exists)
# only add the first override for a project we encounter
set_property(GLOBAL PROPERTY rapids_cpm_${package_name}_override_json "${data}")
endif()
endforeach()

# establish the fetch content
include(FetchContent)
include("${rapids-cmake-dir}/cpm/detail/package_details.cmake")
rapids_cpm_package_details(${package_name} version repository tag shallow exclude)
FetchContent_Declare(${package_name} GIT_REPOSITORY ${repository} GIT_TAG ${tag})

endif()
endfunction()