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

multiple entry overrides now sets FetchContent for all entries #494

Merged
Show file tree
Hide file tree
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
27 changes: 13 additions & 14 deletions rapids-cmake/cpm/package_override.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,21 @@ function(rapids_cpm_package_override filepath)
string(JSON data GET "${json_data}" packages "${package_name}")
set_property(GLOBAL PROPERTY rapids_cpm_${package_name}_override_json "${data}")
set_property(GLOBAL PROPERTY rapids_cpm_${package_name}_override_json_file "${filepath}")
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)

include("${rapids-cmake-dir}/cpm/detail/generate_patch_command.cmake")
rapids_cpm_generate_patch_command(${package_name} ${version} patch_command)
# 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}
GIT_SHALLOW ${shallow}
PATCH_COMMAND ${patch_command} EXCLUDE_FROM_ALL ${exclude})
include("${rapids-cmake-dir}/cpm/detail/generate_patch_command.cmake")
rapids_cpm_generate_patch_command(${package_name} ${version} patch_command)

FetchContent_Declare(${package_name}
GIT_REPOSITORY ${repository}
GIT_TAG ${tag}
GIT_SHALLOW ${shallow}
PATCH_COMMAND ${patch_command} EXCLUDE_FROM_ALL ${exclude})
endif()
endforeach()
endif()
endfunction()
19 changes: 19 additions & 0 deletions testing/cpm/cpm_init-override-multiple.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,28 @@
#=============================================================================
include(${rapids-cmake-dir}/cpm/init.cmake)

function(expect_fetch_content_details project expected)
string(TOLOWER ${project} project)
set(internal_fetch_content_var_name "_FetchContent_${project}_savedDetails")
get_property(exists GLOBAL PROPERTY ${internal_fetch_content_var_name} DEFINED)
if(expected AND NOT exists)
message(FATAL_ERROR "FetchContent expected ${project} doesn't match expected[${exists}!=${expected})")
elseif(NOT expected AND exists)
message(FATAL_ERROR "FetchContent expected ${project} doesn't match expected[${exists}!=${expected})")
endif()
endfunction()

rapids_cpm_init()

# Load the default values for nvbench and GTest projects
include("${rapids-cmake-dir}/cpm/detail/package_details.cmake")
rapids_cpm_package_details(nvbench nvbench_version nvbench_repository nvbench_tag nvbench_shallow nvbench_exclude)
rapids_cpm_package_details(GTest GTest_version GTest_repository GTest_tag GTest_shallow GTest_exclude)

expect_fetch_content_details(nvbench NO)
expect_fetch_content_details(rmm NO)
expect_fetch_content_details(GTest NO)


# Need to write out an override file
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/override.json
Expand All @@ -43,6 +58,10 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/override.json
]=])

rapids_cpm_init(OVERRIDE "${CMAKE_CURRENT_BINARY_DIR}/override.json")
expect_fetch_content_details(nvbench YES)
expect_fetch_content_details(rmm YES)
expect_fetch_content_details(GTest YES)


# Verify that the override works
rapids_cpm_package_details(nvbench version repository tag shallow exclude)
Expand Down
2 changes: 2 additions & 0 deletions testing/cpm/cpm_package_override-obey-cpm-source-var.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/override.json
"exclude_from_all" : "ON"
},
"not_in_base" : {
"version" : "1.0",
"git_url" : "new_rmm_url",
"git_tag" : "main",
"git_shallow" : "OFF",
"exclude_from_all" : "ON"
}
Expand Down