From 06e0b985cfa734365bbb1788025fd9e52a696a09 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 16 Jan 2024 21:52:41 +0000 Subject: [PATCH 01/15] Add test that fails --- testing/cpm/CMakeLists.txt | 1 + .../cpm/cpm_find-patch-command/CMakeLists.txt | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 testing/cpm/cpm_find-patch-command/CMakeLists.txt diff --git a/testing/cpm/CMakeLists.txt b/testing/cpm/CMakeLists.txt index d03f144c0..cecb2502e 100644 --- a/testing/cpm/CMakeLists.txt +++ b/testing/cpm/CMakeLists.txt @@ -23,6 +23,7 @@ add_cmake_config_test( cpm_find-existing-target ) add_cmake_config_test( cpm_find-existing-target-to-export-sets ) add_cmake_config_test( cpm_find-gtest-no-gmock ) add_cmake_config_test( cpm_find-options-escaped ) +add_cmake_config_test( cpm_find-patch-command) add_cmake_config_test( cpm_find-restore-cpm-vars ) add_cmake_config_test( cpm_find-version-explicit-install.cmake ) diff --git a/testing/cpm/cpm_find-patch-command/CMakeLists.txt b/testing/cpm/cpm_find-patch-command/CMakeLists.txt new file mode 100644 index 000000000..83f67b08f --- /dev/null +++ b/testing/cpm/cpm_find-patch-command/CMakeLists.txt @@ -0,0 +1,41 @@ +#============================================================================= +# Copyright (c) 2023, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= +include(${rapids-cmake-dir}/cpm/init.cmake) +include(${rapids-cmake-dir}/cpm/cccl.cmake) + +cmake_minimum_required(VERSION 3.23.1) +project(rapids-cpm_find-patch-command-project LANGUAGES CXX) + +find_package(Git) +set(cccl_parent_dir "${CMAKE_CURRENT_BINARY_DIR}/_cccl_dep") + +if(NOT EXISTS "${cccl_parent_dir}") +file(MAKE_DIRECTORY "${cccl_parent_dir}") +execute_process( + COMMAND ${GIT_EXECUTABLE} clone --depth 1 --branch v2.2.0 https://github.com/NVIDIA/cccl.git + WORKING_DIRECTORY "${cccl_parent_dir}") +endif() + +set(cccl_dir "${cccl_parent_dir}/cccl") +list(APPEND CMAKE_PREFIX_PATH "${cccl_dir}") +unset(CPM_SOURCE_CACHE) +unset(CPM_SOURCE_CACHE CACHE) +rapids_cpm_init() +rapids_cpm_cccl() + +if(NOT "${CCCL_ADDED}") + message(FATAL_ERROR "The found CPM was used rather than downloading and patching a new version") +endif() From a699403c6374b0e9c3a74c1184757f6fc5682212 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 16 Jan 2024 22:09:47 +0000 Subject: [PATCH 02/15] Always add the library when a patch command is present --- rapids-cmake/cpm/find.cmake | 11 ++++++--- .../cpm/cpm_find-patch-command/CMakeLists.txt | 23 +++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/rapids-cmake/cpm/find.cmake b/rapids-cmake/cpm/find.cmake index 592c03fef..59f40c3ed 100644 --- a/rapids-cmake/cpm/find.cmake +++ b/rapids-cmake/cpm/find.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -145,13 +145,18 @@ function(rapids_cpm_find name version) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.find") set(options CPM_ARGS) set(one_value BUILD_EXPORT_SET INSTALL_EXPORT_SET) - set(multi_value COMPONENTS GLOBAL_TARGETS) + set(multi_value COMPONENTS GLOBAL_TARGETS PATCH_COMMAND) cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) if(NOT DEFINED _RAPIDS_CPM_ARGS) message(FATAL_ERROR "rapids_cpm_find requires you to specify CPM_ARGS before any CPM arguments") endif() + # Add the patch command back into the list of commands to forward along. + if(DEFINED _RAPIDS_PATCH_COMMAND) + list(APPEND _RAPIDS_UNPARSED_ARGUMENTS "PATCH_COMMAND" ${_RAPIDS_PATCH_COMMAND}) + endif() + set(package_needs_to_be_added TRUE) if(_RAPIDS_GLOBAL_TARGETS) foreach(target IN LISTS _RAPIDS_GLOBAL_TARGETS) @@ -170,7 +175,7 @@ function(rapids_cpm_find name version) endif() if(package_needs_to_be_added) - if(CPM_${name}_SOURCE) + if(CPM_${name}_SOURCE OR DEFINED _RAPIDS_PATCH_COMMAND) CPMAddPackage(NAME ${name} VERSION ${version} ${_RAPIDS_UNPARSED_ARGUMENTS}) else() CPMFindPackage(NAME ${name} VERSION ${version} ${_RAPIDS_UNPARSED_ARGUMENTS}) diff --git a/testing/cpm/cpm_find-patch-command/CMakeLists.txt b/testing/cpm/cpm_find-patch-command/CMakeLists.txt index 83f67b08f..39f0a62fc 100644 --- a/testing/cpm/cpm_find-patch-command/CMakeLists.txt +++ b/testing/cpm/cpm_find-patch-command/CMakeLists.txt @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,16 +20,16 @@ cmake_minimum_required(VERSION 3.23.1) project(rapids-cpm_find-patch-command-project LANGUAGES CXX) find_package(Git) -set(cccl_parent_dir "${CMAKE_CURRENT_BINARY_DIR}/_cccl_dep") +set(deps_dir "${CMAKE_CURRENT_BINARY_DIR}/_cccl_dep") -if(NOT EXISTS "${cccl_parent_dir}") -file(MAKE_DIRECTORY "${cccl_parent_dir}") +if(NOT EXISTS "${deps_dir}") +file(MAKE_DIRECTORY "${deps_dir}") execute_process( COMMAND ${GIT_EXECUTABLE} clone --depth 1 --branch v2.2.0 https://github.com/NVIDIA/cccl.git - WORKING_DIRECTORY "${cccl_parent_dir}") + WORKING_DIRECTORY "${deps_dir}") endif() -set(cccl_dir "${cccl_parent_dir}/cccl") +set(cccl_dir "${deps_dir}/cccl") list(APPEND CMAKE_PREFIX_PATH "${cccl_dir}") unset(CPM_SOURCE_CACHE) unset(CPM_SOURCE_CACHE CACHE) @@ -37,5 +37,14 @@ rapids_cpm_init() rapids_cpm_cccl() if(NOT "${CCCL_ADDED}") - message(FATAL_ERROR "The found CPM was used rather than downloading and patching a new version") + message(FATAL_ERROR "The found repo was used rather than downloading and patching a new version") +endif() + +execute_process( + COMMAND ${GIT_EXECUTABLE} diff-files --quiet + RESULT_VARIABLE REPO_IS_DIRTY + WORKING_DIRECTORY "${CPM_SOURCE_DIR}") + +if(NOT ${REPO_IS_DIRTY}) + message(FATAL_ERROR "The repo was downloaded but not patched. The value is ${REPO_IS_DIRTY} in ${CPM_SOURCE_DIR}") endif() From 97839e29046c8ab707e73131f55f2c7390b0fcf8 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 16 Jan 2024 22:48:27 +0000 Subject: [PATCH 03/15] Make patch command a string and always quote it --- rapids-cmake/cpm/cccl.cmake | 6 ++++-- rapids-cmake/cpm/cuco.cmake | 4 ++-- rapids-cmake/cpm/detail/generate_patch_command.cmake | 2 +- rapids-cmake/cpm/find.cmake | 4 ++-- rapids-cmake/cpm/fmt.cmake | 4 ++-- rapids-cmake/cpm/gbench.cmake | 4 ++-- rapids-cmake/cpm/gtest.cmake | 4 ++-- rapids-cmake/cpm/libcudacxx.cmake | 4 ++-- rapids-cmake/cpm/nvbench.cmake | 4 ++-- rapids-cmake/cpm/nvcomp.cmake | 4 ++-- rapids-cmake/cpm/rmm.cmake | 4 ++-- rapids-cmake/cpm/spdlog.cmake | 4 ++-- rapids-cmake/cpm/thrust.cmake | 4 ++-- 13 files changed, 27 insertions(+), 25 deletions(-) diff --git a/rapids-cmake/cpm/cccl.cmake b/rapids-cmake/cpm/cccl.cmake index a76e035b5..976a22360 100644 --- a/rapids-cmake/cpm/cccl.cmake +++ b/rapids-cmake/cpm/cccl.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -66,6 +66,7 @@ function(rapids_cpm_cccl) rapids_cpm_package_details(CCCL version repository tag shallow exclude) set(to_install OFF) + cmake_policy(SET CMP0057 NEW) if(INSTALL_EXPORT_SET IN_LIST ARGN AND NOT exclude) set(to_install ON) # Make sure we install CCCL into the `include/rapids` subdirectory instead of the default @@ -82,13 +83,14 @@ function(rapids_cpm_cccl) set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL ON) include("${rapids-cmake-dir}/cpm/find.cmake") + message("The patch command inside is ${patch_command}") rapids_cpm_find(CCCL ${version} ${ARGN} GLOBAL_TARGETS CCCL CCCL::CCCL CCCL::CUB CCCL::libcudacxx CPM_ARGS FIND_PACKAGE_ARGUMENTS EXACT GIT_REPOSITORY ${repository} GIT_TAG ${tag} GIT_SHALLOW ${shallow} - PATCH_COMMAND ${patch_command} + PATCH_COMMAND "${patch_command}" EXCLUDE_FROM_ALL ${exclude} OPTIONS "CCCL_ENABLE_INSTALL_RULES ${to_install}") diff --git a/rapids-cmake/cpm/cuco.cmake b/rapids-cmake/cpm/cuco.cmake index da81bbb65..d3a32342e 100644 --- a/rapids-cmake/cpm/cuco.cmake +++ b/rapids-cmake/cpm/cuco.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ function(rapids_cpm_cuco) GIT_REPOSITORY ${repository} GIT_TAG ${tag} GIT_SHALLOW ${shallow} - PATCH_COMMAND ${patch_command} + PATCH_COMMAND "${patch_command}" EXCLUDE_FROM_ALL ${to_exclude} OPTIONS "BUILD_TESTS OFF" "BUILD_BENCHMARKS OFF" "BUILD_EXAMPLES OFF" "INSTALL_CUCO ${to_install}") diff --git a/rapids-cmake/cpm/detail/generate_patch_command.cmake b/rapids-cmake/cpm/detail/generate_patch_command.cmake index 2319d5239..7f3b60c84 100644 --- a/rapids-cmake/cpm/detail/generate_patch_command.cmake +++ b/rapids-cmake/cpm/detail/generate_patch_command.cmake @@ -103,7 +103,7 @@ function(rapids_cpm_generate_patch_command package_name version patch_command) string(TIMESTAMP current_year "%Y" UTC) configure_file(${rapids-cmake-dir}/cpm/patches/command_template.cmake.in "${patch_script}" @ONLY) - set(${patch_command} ${CMAKE_COMMAND} -P ${patch_script} PARENT_SCOPE) + set(${patch_command} "${CMAKE_COMMAND} -P ${patch_script}" PARENT_SCOPE) else() # remove any old patch / log files that exist and are no longer needed due to a change in the # package version / version.json diff --git a/rapids-cmake/cpm/find.cmake b/rapids-cmake/cpm/find.cmake index 59f40c3ed..9bea4eb87 100644 --- a/rapids-cmake/cpm/find.cmake +++ b/rapids-cmake/cpm/find.cmake @@ -144,8 +144,8 @@ modified version is used. function(rapids_cpm_find name version) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.find") set(options CPM_ARGS) - set(one_value BUILD_EXPORT_SET INSTALL_EXPORT_SET) - set(multi_value COMPONENTS GLOBAL_TARGETS PATCH_COMMAND) + set(one_value BUILD_EXPORT_SET INSTALL_EXPORT_SET PATCH_COMMAND) + set(multi_value COMPONENTS GLOBAL_TARGETS) cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) if(NOT DEFINED _RAPIDS_CPM_ARGS) diff --git a/rapids-cmake/cpm/fmt.cmake b/rapids-cmake/cpm/fmt.cmake index c8be7ca3b..4d982b323 100644 --- a/rapids-cmake/cpm/fmt.cmake +++ b/rapids-cmake/cpm/fmt.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ function(rapids_cpm_fmt) GIT_REPOSITORY ${repository} GIT_TAG ${tag} GIT_SHALLOW ${shallow} - PATCH_COMMAND ${patch_command} + PATCH_COMMAND "${patch_command}" EXCLUDE_FROM_ALL ${exclude} OPTIONS "FMT_INSTALL ${to_install}" "CMAKE_POSITION_INDEPENDENT_CODE ON") diff --git a/rapids-cmake/cpm/gbench.cmake b/rapids-cmake/cpm/gbench.cmake index 0ec2fa575..9644cb20e 100644 --- a/rapids-cmake/cpm/gbench.cmake +++ b/rapids-cmake/cpm/gbench.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -78,7 +78,7 @@ function(rapids_cpm_gbench) GIT_REPOSITORY ${repository} GIT_TAG ${tag} GIT_SHALLOW ${shallow} - PATCH_COMMAND ${patch_command} + PATCH_COMMAND "${patch_command}" EXCLUDE_FROM_ALL ${exclude} OPTIONS "BENCHMARK_ENABLE_GTEST_TESTS OFF" "BENCHMARK_ENABLE_TESTING OFF" "BENCHMARK_ENABLE_INSTALL ${to_install}" diff --git a/rapids-cmake/cpm/gtest.cmake b/rapids-cmake/cpm/gtest.cmake index 9aef28015..c42b740a4 100644 --- a/rapids-cmake/cpm/gtest.cmake +++ b/rapids-cmake/cpm/gtest.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021-2023, NVIDIA CORPORATION. +# Copyright (c) 2021-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ function(rapids_cpm_gtest) GIT_REPOSITORY ${repository} GIT_TAG ${tag} GIT_SHALLOW ${shallow} - PATCH_COMMAND ${patch_command} + PATCH_COMMAND "${patch_command}" EXCLUDE_FROM_ALL ${exclude} OPTIONS "INSTALL_GTEST ${to_install}" "CMAKE_POSITION_INDEPENDENT_CODE ON") diff --git a/rapids-cmake/cpm/libcudacxx.cmake b/rapids-cmake/cpm/libcudacxx.cmake index fc239872b..4c7125d6d 100644 --- a/rapids-cmake/cpm/libcudacxx.cmake +++ b/rapids-cmake/cpm/libcudacxx.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021-2023, NVIDIA CORPORATION. +# Copyright (c) 2021-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -89,7 +89,7 @@ function(rapids_cpm_libcudacxx) GIT_REPOSITORY ${repository} GIT_TAG ${tag} GIT_SHALLOW ${shallow} - PATCH_COMMAND ${patch_command} + PATCH_COMMAND "${patch_command}" EXCLUDE_FROM_ALL ${exclude} OPTIONS "libcudacxx_ENABLE_INSTALL_RULES ${to_install}") diff --git a/rapids-cmake/cpm/nvbench.cmake b/rapids-cmake/cpm/nvbench.cmake index aa3d75596..4247cfc47 100644 --- a/rapids-cmake/cpm/nvbench.cmake +++ b/rapids-cmake/cpm/nvbench.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021-2023, NVIDIA CORPORATION. +# Copyright (c) 2021-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -95,7 +95,7 @@ function(rapids_cpm_nvbench) GIT_REPOSITORY ${repository} GIT_TAG ${tag} GIT_SHALLOW ${shallow} - PATCH_COMMAND ${patch_command} + PATCH_COMMAND "${patch_command}" EXCLUDE_FROM_ALL ${exclude} OPTIONS "NVBench_ENABLE_NVML ${nvbench_with_nvml}" "NVBench_ENABLE_CUPTI OFF" diff --git a/rapids-cmake/cpm/nvcomp.cmake b/rapids-cmake/cpm/nvcomp.cmake index e52cb6b21..2141e37a8 100644 --- a/rapids-cmake/cpm/nvcomp.cmake +++ b/rapids-cmake/cpm/nvcomp.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021-2023, NVIDIA CORPORATION. +# Copyright (c) 2021-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -145,7 +145,7 @@ function(rapids_cpm_nvcomp) GIT_TAG ${tag} GIT_SHALLOW ${shallow} EXCLUDE_FROM_ALL ${to_exclude} - PATCH_COMMAND ${patch_command} + PATCH_COMMAND "${patch_command}" OPTIONS "BUILD_STATIC ON" "BUILD_TESTS OFF" "BUILD_BENCHMARKS OFF" "BUILD_EXAMPLES OFF") diff --git a/rapids-cmake/cpm/rmm.cmake b/rapids-cmake/cpm/rmm.cmake index 772f34582..2fb51eedc 100644 --- a/rapids-cmake/cpm/rmm.cmake +++ b/rapids-cmake/cpm/rmm.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021-2023, NVIDIA CORPORATION. +# Copyright (c) 2021-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -78,7 +78,7 @@ function(rapids_cpm_rmm) GIT_REPOSITORY ${repository} GIT_TAG ${tag} GIT_SHALLOW ${shallow} - PATCH_COMMAND ${patch_command} + PATCH_COMMAND "${patch_command}" EXCLUDE_FROM_ALL ${to_exclude} OPTIONS "BUILD_TESTS OFF" "BUILD_BENCHMARKS OFF") diff --git a/rapids-cmake/cpm/spdlog.cmake b/rapids-cmake/cpm/spdlog.cmake index e6662cba4..108ce2806 100644 --- a/rapids-cmake/cpm/spdlog.cmake +++ b/rapids-cmake/cpm/spdlog.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021-2023, NVIDIA CORPORATION. +# Copyright (c) 2021-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -130,7 +130,7 @@ function(rapids_cpm_spdlog) GIT_REPOSITORY ${repository} GIT_TAG ${tag} GIT_SHALLOW ${shallow} - PATCH_COMMAND ${patch_command} + PATCH_COMMAND "${patch_command}" EXCLUDE_FROM_ALL ${exclude} OPTIONS "SPDLOG_INSTALL ${to_install}" "${spdlog_fmt_option}") diff --git a/rapids-cmake/cpm/thrust.cmake b/rapids-cmake/cpm/thrust.cmake index 04d453b13..991fcdec5 100644 --- a/rapids-cmake/cpm/thrust.cmake +++ b/rapids-cmake/cpm/thrust.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021-2023, NVIDIA CORPORATION. +# Copyright (c) 2021-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ function(rapids_cpm_thrust NAMESPACE namespaces_name) GIT_REPOSITORY ${repository} GIT_TAG ${tag} GIT_SHALLOW ${shallow} - PATCH_COMMAND ${patch_command} + PATCH_COMMAND "${patch_command}" EXCLUDE_FROM_ALL ${exclude} OPTIONS "THRUST_ENABLE_INSTALL_RULES ${to_install}") From 06b9467bfa4b3f39e95e934be9b317df2eedba7d Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 16 Jan 2024 22:52:08 +0000 Subject: [PATCH 04/15] Remove explicit policy statement --- rapids-cmake/cpm/cccl.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/rapids-cmake/cpm/cccl.cmake b/rapids-cmake/cpm/cccl.cmake index 976a22360..84055403c 100644 --- a/rapids-cmake/cpm/cccl.cmake +++ b/rapids-cmake/cpm/cccl.cmake @@ -66,7 +66,6 @@ function(rapids_cpm_cccl) rapids_cpm_package_details(CCCL version repository tag shallow exclude) set(to_install OFF) - cmake_policy(SET CMP0057 NEW) if(INSTALL_EXPORT_SET IN_LIST ARGN AND NOT exclude) set(to_install ON) # Make sure we install CCCL into the `include/rapids` subdirectory instead of the default From f70b438b737b8451d270b009e543f39c4066bf27 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 16 Jan 2024 23:19:20 +0000 Subject: [PATCH 05/15] Cleanup and comments --- rapids-cmake/cpm/cccl.cmake | 1 - rapids-cmake/cpm/find.cmake | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rapids-cmake/cpm/cccl.cmake b/rapids-cmake/cpm/cccl.cmake index 84055403c..2aacbffbb 100644 --- a/rapids-cmake/cpm/cccl.cmake +++ b/rapids-cmake/cpm/cccl.cmake @@ -82,7 +82,6 @@ function(rapids_cpm_cccl) set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL ON) include("${rapids-cmake-dir}/cpm/find.cmake") - message("The patch command inside is ${patch_command}") rapids_cpm_find(CCCL ${version} ${ARGN} GLOBAL_TARGETS CCCL CCCL::CCCL CCCL::CUB CCCL::libcudacxx CPM_ARGS FIND_PACKAGE_ARGUMENTS EXACT diff --git a/rapids-cmake/cpm/find.cmake b/rapids-cmake/cpm/find.cmake index 9bea4eb87..7703a33eb 100644 --- a/rapids-cmake/cpm/find.cmake +++ b/rapids-cmake/cpm/find.cmake @@ -175,7 +175,8 @@ function(rapids_cpm_find name version) endif() if(package_needs_to_be_added) - if(CPM_${name}_SOURCE OR DEFINED _RAPIDS_PATCH_COMMAND) + # Any nonempty patch command should trigger CPMAddPackage. + if(CPM_${name}_SOURCE OR _RAPIDS_PATCH_COMMAND) CPMAddPackage(NAME ${name} VERSION ${version} ${_RAPIDS_UNPARSED_ARGUMENTS}) else() CPMFindPackage(NAME ${name} VERSION ${version} ${_RAPIDS_UNPARSED_ARGUMENTS}) From adf03d54a0698f6994c1ba5dae92d3e37c027dbb Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 17 Jan 2024 17:23:14 +0000 Subject: [PATCH 06/15] Lump the PATCH_COMMAND keyword into the command produced by generate_patch_command. --- rapids-cmake/cpm/cccl.cmake | 4 ++-- rapids-cmake/cpm/cuco.cmake | 3 +-- .../cpm/detail/generate_patch_command.cmake | 2 +- rapids-cmake/cpm/find.cmake | 20 ++++++++++++++----- rapids-cmake/cpm/fmt.cmake | 3 +-- rapids-cmake/cpm/gbench.cmake | 3 +-- rapids-cmake/cpm/gtest.cmake | 3 +-- rapids-cmake/cpm/libcudacxx.cmake | 3 +-- rapids-cmake/cpm/nvbench.cmake | 3 +-- rapids-cmake/cpm/nvcomp.cmake | 3 +-- rapids-cmake/cpm/package_override.cmake | 4 ++-- rapids-cmake/cpm/rmm.cmake | 3 +-- rapids-cmake/cpm/spdlog.cmake | 3 +-- rapids-cmake/cpm/thrust.cmake | 3 +-- 14 files changed, 30 insertions(+), 30 deletions(-) diff --git a/rapids-cmake/cpm/cccl.cmake b/rapids-cmake/cpm/cccl.cmake index 2aacbffbb..1c22507d4 100644 --- a/rapids-cmake/cpm/cccl.cmake +++ b/rapids-cmake/cpm/cccl.cmake @@ -66,6 +66,7 @@ function(rapids_cpm_cccl) rapids_cpm_package_details(CCCL version repository tag shallow exclude) set(to_install OFF) + cmake_policy(SET CMP0057 NEW) if(INSTALL_EXPORT_SET IN_LIST ARGN AND NOT exclude) set(to_install ON) # Make sure we install CCCL into the `include/rapids` subdirectory instead of the default @@ -87,8 +88,7 @@ function(rapids_cpm_cccl) CPM_ARGS FIND_PACKAGE_ARGUMENTS EXACT GIT_REPOSITORY ${repository} GIT_TAG ${tag} - GIT_SHALLOW ${shallow} - PATCH_COMMAND "${patch_command}" + GIT_SHALLOW ${shallow} ${patch_command} EXCLUDE_FROM_ALL ${exclude} OPTIONS "CCCL_ENABLE_INSTALL_RULES ${to_install}") diff --git a/rapids-cmake/cpm/cuco.cmake b/rapids-cmake/cpm/cuco.cmake index d3a32342e..122c4caed 100644 --- a/rapids-cmake/cpm/cuco.cmake +++ b/rapids-cmake/cpm/cuco.cmake @@ -80,8 +80,7 @@ function(rapids_cpm_cuco) CPM_ARGS GIT_REPOSITORY ${repository} GIT_TAG ${tag} - GIT_SHALLOW ${shallow} - PATCH_COMMAND "${patch_command}" + GIT_SHALLOW ${shallow} ${patch_command} EXCLUDE_FROM_ALL ${to_exclude} OPTIONS "BUILD_TESTS OFF" "BUILD_BENCHMARKS OFF" "BUILD_EXAMPLES OFF" "INSTALL_CUCO ${to_install}") diff --git a/rapids-cmake/cpm/detail/generate_patch_command.cmake b/rapids-cmake/cpm/detail/generate_patch_command.cmake index 7f3b60c84..7152a79cc 100644 --- a/rapids-cmake/cpm/detail/generate_patch_command.cmake +++ b/rapids-cmake/cpm/detail/generate_patch_command.cmake @@ -103,7 +103,7 @@ function(rapids_cpm_generate_patch_command package_name version patch_command) string(TIMESTAMP current_year "%Y" UTC) configure_file(${rapids-cmake-dir}/cpm/patches/command_template.cmake.in "${patch_script}" @ONLY) - set(${patch_command} "${CMAKE_COMMAND} -P ${patch_script}" PARENT_SCOPE) + set(${patch_command} "PATCH_COMMAND ${CMAKE_COMMAND} -P ${patch_script}" PARENT_SCOPE) else() # remove any old patch / log files that exist and are no longer needed due to a change in the # package version / version.json diff --git a/rapids-cmake/cpm/find.cmake b/rapids-cmake/cpm/find.cmake index 7703a33eb..5ef60781b 100644 --- a/rapids-cmake/cpm/find.cmake +++ b/rapids-cmake/cpm/find.cmake @@ -80,6 +80,10 @@ consistency. List all targets used by your project in `GLOBAL_TARGET`. Required placeholder to be provided before any extra arguments that need to be passed down to :cmake:command:`CPMFindPackage`. + .. note:: + A ``PATCH_COMMAND`` will always trigger usage of :cmake:command:`CPMAddPackage` instead of :cmake:command:`CPMFindPackage`. *This is true even + if the patch command is empty.* + Result Variables ^^^^^^^^^^^^^^^^ :cmake:variable:`_SOURCE_DIR` is set to the path to the source directory of . @@ -144,7 +148,7 @@ modified version is used. function(rapids_cpm_find name version) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.find") set(options CPM_ARGS) - set(one_value BUILD_EXPORT_SET INSTALL_EXPORT_SET PATCH_COMMAND) + set(one_value BUILD_EXPORT_SET INSTALL_EXPORT_SET) set(multi_value COMPONENTS GLOBAL_TARGETS) cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) @@ -153,9 +157,15 @@ function(rapids_cpm_find name version) endif() # Add the patch command back into the list of commands to forward along. - if(DEFINED _RAPIDS_PATCH_COMMAND) - list(APPEND _RAPIDS_UNPARSED_ARGUMENTS "PATCH_COMMAND" ${_RAPIDS_PATCH_COMMAND}) - endif() + set(has_patch FALSE) + cmake_policy(SET CMP0057 NEW) + message("The unparsed args are ${_RAPIDS_UNPARSED_ARGUMENTS}") + foreach(unparsed_arg IN LISTS _RAPIDS_UNPARSED_ARGUMENTS) + if(unparsed_arg MATCHES "PATCH_COMMAND") + set(has_patch TRUE) + break() + endif() + endforeach() set(package_needs_to_be_added TRUE) if(_RAPIDS_GLOBAL_TARGETS) @@ -176,7 +186,7 @@ function(rapids_cpm_find name version) if(package_needs_to_be_added) # Any nonempty patch command should trigger CPMAddPackage. - if(CPM_${name}_SOURCE OR _RAPIDS_PATCH_COMMAND) + if(CPM_${name}_SOURCE OR has_patch) CPMAddPackage(NAME ${name} VERSION ${version} ${_RAPIDS_UNPARSED_ARGUMENTS}) else() CPMFindPackage(NAME ${name} VERSION ${version} ${_RAPIDS_UNPARSED_ARGUMENTS}) diff --git a/rapids-cmake/cpm/fmt.cmake b/rapids-cmake/cpm/fmt.cmake index 4d982b323..2302d41d3 100644 --- a/rapids-cmake/cpm/fmt.cmake +++ b/rapids-cmake/cpm/fmt.cmake @@ -68,8 +68,7 @@ function(rapids_cpm_fmt) CPM_ARGS GIT_REPOSITORY ${repository} GIT_TAG ${tag} - GIT_SHALLOW ${shallow} - PATCH_COMMAND "${patch_command}" + GIT_SHALLOW ${shallow} ${patch_command} EXCLUDE_FROM_ALL ${exclude} OPTIONS "FMT_INSTALL ${to_install}" "CMAKE_POSITION_INDEPENDENT_CODE ON") diff --git a/rapids-cmake/cpm/gbench.cmake b/rapids-cmake/cpm/gbench.cmake index 9644cb20e..f17c06b6e 100644 --- a/rapids-cmake/cpm/gbench.cmake +++ b/rapids-cmake/cpm/gbench.cmake @@ -77,8 +77,7 @@ function(rapids_cpm_gbench) CPM_ARGS GIT_REPOSITORY ${repository} GIT_TAG ${tag} - GIT_SHALLOW ${shallow} - PATCH_COMMAND "${patch_command}" + GIT_SHALLOW ${shallow} ${patch_command} EXCLUDE_FROM_ALL ${exclude} OPTIONS "BENCHMARK_ENABLE_GTEST_TESTS OFF" "BENCHMARK_ENABLE_TESTING OFF" "BENCHMARK_ENABLE_INSTALL ${to_install}" diff --git a/rapids-cmake/cpm/gtest.cmake b/rapids-cmake/cpm/gtest.cmake index c42b740a4..dd07c4b7a 100644 --- a/rapids-cmake/cpm/gtest.cmake +++ b/rapids-cmake/cpm/gtest.cmake @@ -68,8 +68,7 @@ function(rapids_cpm_gtest) CPM_ARGS FIND_PACKAGE_ARGUMENTS "EXACT" GIT_REPOSITORY ${repository} GIT_TAG ${tag} - GIT_SHALLOW ${shallow} - PATCH_COMMAND "${patch_command}" + GIT_SHALLOW ${shallow} ${patch_command} EXCLUDE_FROM_ALL ${exclude} OPTIONS "INSTALL_GTEST ${to_install}" "CMAKE_POSITION_INDEPENDENT_CODE ON") diff --git a/rapids-cmake/cpm/libcudacxx.cmake b/rapids-cmake/cpm/libcudacxx.cmake index 4c7125d6d..0ec43bbb4 100644 --- a/rapids-cmake/cpm/libcudacxx.cmake +++ b/rapids-cmake/cpm/libcudacxx.cmake @@ -88,8 +88,7 @@ function(rapids_cpm_libcudacxx) CPM_ARGS GIT_REPOSITORY ${repository} GIT_TAG ${tag} - GIT_SHALLOW ${shallow} - PATCH_COMMAND "${patch_command}" + GIT_SHALLOW ${shallow} ${patch_command} EXCLUDE_FROM_ALL ${exclude} OPTIONS "libcudacxx_ENABLE_INSTALL_RULES ${to_install}") diff --git a/rapids-cmake/cpm/nvbench.cmake b/rapids-cmake/cpm/nvbench.cmake index 4247cfc47..cc17ade67 100644 --- a/rapids-cmake/cpm/nvbench.cmake +++ b/rapids-cmake/cpm/nvbench.cmake @@ -94,8 +94,7 @@ function(rapids_cpm_nvbench) CPM_ARGS GIT_REPOSITORY ${repository} GIT_TAG ${tag} - GIT_SHALLOW ${shallow} - PATCH_COMMAND "${patch_command}" + GIT_SHALLOW ${shallow} ${patch_command} EXCLUDE_FROM_ALL ${exclude} OPTIONS "NVBench_ENABLE_NVML ${nvbench_with_nvml}" "NVBench_ENABLE_CUPTI OFF" diff --git a/rapids-cmake/cpm/nvcomp.cmake b/rapids-cmake/cpm/nvcomp.cmake index 2141e37a8..25039ebde 100644 --- a/rapids-cmake/cpm/nvcomp.cmake +++ b/rapids-cmake/cpm/nvcomp.cmake @@ -144,8 +144,7 @@ function(rapids_cpm_nvcomp) GIT_REPOSITORY ${repository} GIT_TAG ${tag} GIT_SHALLOW ${shallow} - EXCLUDE_FROM_ALL ${to_exclude} - PATCH_COMMAND "${patch_command}" + EXCLUDE_FROM_ALL ${to_exclude} ${patch_command} OPTIONS "BUILD_STATIC ON" "BUILD_TESTS OFF" "BUILD_BENCHMARKS OFF" "BUILD_EXAMPLES OFF") diff --git a/rapids-cmake/cpm/package_override.cmake b/rapids-cmake/cpm/package_override.cmake index 29732660f..e804ffeb3 100644 --- a/rapids-cmake/cpm/package_override.cmake +++ b/rapids-cmake/cpm/package_override.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021-2023, NVIDIA CORPORATION. +# Copyright (c) 2021-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -99,7 +99,7 @@ function(rapids_cpm_package_override filepath) GIT_REPOSITORY ${repository} GIT_TAG ${tag} GIT_SHALLOW ${shallow} - PATCH_COMMAND ${patch_command} EXCLUDE_FROM_ALL ${exclude}) + ${patch_command} EXCLUDE_FROM_ALL ${exclude}) endif() endforeach() endif() diff --git a/rapids-cmake/cpm/rmm.cmake b/rapids-cmake/cpm/rmm.cmake index 2fb51eedc..bb78d8bb2 100644 --- a/rapids-cmake/cpm/rmm.cmake +++ b/rapids-cmake/cpm/rmm.cmake @@ -77,8 +77,7 @@ function(rapids_cpm_rmm) CPM_ARGS GIT_REPOSITORY ${repository} GIT_TAG ${tag} - GIT_SHALLOW ${shallow} - PATCH_COMMAND "${patch_command}" + GIT_SHALLOW ${shallow} ${patch_command} EXCLUDE_FROM_ALL ${to_exclude} OPTIONS "BUILD_TESTS OFF" "BUILD_BENCHMARKS OFF") diff --git a/rapids-cmake/cpm/spdlog.cmake b/rapids-cmake/cpm/spdlog.cmake index 108ce2806..704d870d6 100644 --- a/rapids-cmake/cpm/spdlog.cmake +++ b/rapids-cmake/cpm/spdlog.cmake @@ -129,8 +129,7 @@ function(rapids_cpm_spdlog) CPM_ARGS GIT_REPOSITORY ${repository} GIT_TAG ${tag} - GIT_SHALLOW ${shallow} - PATCH_COMMAND "${patch_command}" + GIT_SHALLOW ${shallow} ${patch_command} EXCLUDE_FROM_ALL ${exclude} OPTIONS "SPDLOG_INSTALL ${to_install}" "${spdlog_fmt_option}") diff --git a/rapids-cmake/cpm/thrust.cmake b/rapids-cmake/cpm/thrust.cmake index 991fcdec5..f0d16e4c7 100644 --- a/rapids-cmake/cpm/thrust.cmake +++ b/rapids-cmake/cpm/thrust.cmake @@ -84,8 +84,7 @@ function(rapids_cpm_thrust NAMESPACE namespaces_name) CPM_ARGS FIND_PACKAGE_ARGUMENTS EXACT GIT_REPOSITORY ${repository} GIT_TAG ${tag} - GIT_SHALLOW ${shallow} - PATCH_COMMAND "${patch_command}" + GIT_SHALLOW ${shallow} ${patch_command} EXCLUDE_FROM_ALL ${exclude} OPTIONS "THRUST_ENABLE_INSTALL_RULES ${to_install}") From cea12ab83e22d9f82cccaaea863aa6e3b2197d83 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 17 Jan 2024 17:23:50 +0000 Subject: [PATCH 07/15] Fix one outstanding test --- testing/cpm/cpm_generate_patch_command-current_json_dir.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/cpm/cpm_generate_patch_command-current_json_dir.cmake b/testing/cpm/cpm_generate_patch_command-current_json_dir.cmake index 5cb74788f..8a673dc08 100644 --- a/testing/cpm/cpm_generate_patch_command-current_json_dir.cmake +++ b/testing/cpm/cpm_generate_patch_command-current_json_dir.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -58,6 +58,7 @@ endif() set(to_match_string "set(files \"${CMAKE_CURRENT_BINARY_DIR}/example.diff;${CMAKE_CURRENT_BINARY_DIR}/example2.diff\")") +string(REPLACE " " ";" patch_command ${patch_command}) list(POP_BACK patch_command script_to_run) file(READ "${script_to_run}" contents) string(FIND "${contents}" "${to_match_string}" is_found) From 980a90de7f8c822658a49b0d75ab0367fd02acd6 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 17 Jan 2024 17:46:44 +0000 Subject: [PATCH 08/15] Remove debugging message --- rapids-cmake/cpm/find.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/rapids-cmake/cpm/find.cmake b/rapids-cmake/cpm/find.cmake index 5ef60781b..4ef528799 100644 --- a/rapids-cmake/cpm/find.cmake +++ b/rapids-cmake/cpm/find.cmake @@ -159,7 +159,6 @@ function(rapids_cpm_find name version) # Add the patch command back into the list of commands to forward along. set(has_patch FALSE) cmake_policy(SET CMP0057 NEW) - message("The unparsed args are ${_RAPIDS_UNPARSED_ARGUMENTS}") foreach(unparsed_arg IN LISTS _RAPIDS_UNPARSED_ARGUMENTS) if(unparsed_arg MATCHES "PATCH_COMMAND") set(has_patch TRUE) From f80321288bbc934a7e9eab2864587c467ad90e39 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 17 Jan 2024 17:46:58 +0000 Subject: [PATCH 09/15] Fix my test --- testing/cpm/cpm_find-patch-command/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/cpm/cpm_find-patch-command/CMakeLists.txt b/testing/cpm/cpm_find-patch-command/CMakeLists.txt index 39f0a62fc..76a3becff 100644 --- a/testing/cpm/cpm_find-patch-command/CMakeLists.txt +++ b/testing/cpm/cpm_find-patch-command/CMakeLists.txt @@ -43,8 +43,8 @@ endif() execute_process( COMMAND ${GIT_EXECUTABLE} diff-files --quiet RESULT_VARIABLE REPO_IS_DIRTY - WORKING_DIRECTORY "${CPM_SOURCE_DIR}") + WORKING_DIRECTORY "${CCCL_SOURCE_DIR}") if(NOT ${REPO_IS_DIRTY}) - message(FATAL_ERROR "The repo was downloaded but not patched. The value is ${REPO_IS_DIRTY} in ${CPM_SOURCE_DIR}") + message(FATAL_ERROR "The repo was downloaded to ${CCCL_SOURCE_DIR} but not patched.") endif() From 42049610825b2122ce10f96143c0f40c8a230abf Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 17 Jan 2024 17:56:56 +0000 Subject: [PATCH 10/15] Convert patch command back to list --- rapids-cmake/cpm/detail/generate_patch_command.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rapids-cmake/cpm/detail/generate_patch_command.cmake b/rapids-cmake/cpm/detail/generate_patch_command.cmake index 7152a79cc..880541849 100644 --- a/rapids-cmake/cpm/detail/generate_patch_command.cmake +++ b/rapids-cmake/cpm/detail/generate_patch_command.cmake @@ -103,7 +103,7 @@ function(rapids_cpm_generate_patch_command package_name version patch_command) string(TIMESTAMP current_year "%Y" UTC) configure_file(${rapids-cmake-dir}/cpm/patches/command_template.cmake.in "${patch_script}" @ONLY) - set(${patch_command} "PATCH_COMMAND ${CMAKE_COMMAND} -P ${patch_script}" PARENT_SCOPE) + set(${patch_command} PATCH_COMMAND ${CMAKE_COMMAND} -P ${patch_script} PARENT_SCOPE) else() # remove any old patch / log files that exist and are no longer needed due to a change in the # package version / version.json From 4cebbfa9c9d47c71d969fa5aa88c9588e41584ae Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 17 Jan 2024 17:58:35 +0000 Subject: [PATCH 11/15] Revert "Fix one outstanding test" This reverts commit cea12ab83e22d9f82cccaaea863aa6e3b2197d83. --- testing/cpm/cpm_generate_patch_command-current_json_dir.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/testing/cpm/cpm_generate_patch_command-current_json_dir.cmake b/testing/cpm/cpm_generate_patch_command-current_json_dir.cmake index 8a673dc08..5cb74788f 100644 --- a/testing/cpm/cpm_generate_patch_command-current_json_dir.cmake +++ b/testing/cpm/cpm_generate_patch_command-current_json_dir.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2022-2024, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -58,7 +58,6 @@ endif() set(to_match_string "set(files \"${CMAKE_CURRENT_BINARY_DIR}/example.diff;${CMAKE_CURRENT_BINARY_DIR}/example2.diff\")") -string(REPLACE " " ";" patch_command ${patch_command}) list(POP_BACK patch_command script_to_run) file(READ "${script_to_run}" contents) string(FIND "${contents}" "${to_match_string}" is_found) From 924effdde3e051592f12308e9f6fd888ed957144 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 17 Jan 2024 18:07:36 +0000 Subject: [PATCH 12/15] Final cleanup --- rapids-cmake/cpm/cccl.cmake | 1 - rapids-cmake/cpm/find.cmake | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/rapids-cmake/cpm/cccl.cmake b/rapids-cmake/cpm/cccl.cmake index 1c22507d4..401ad5423 100644 --- a/rapids-cmake/cpm/cccl.cmake +++ b/rapids-cmake/cpm/cccl.cmake @@ -66,7 +66,6 @@ function(rapids_cpm_cccl) rapids_cpm_package_details(CCCL version repository tag shallow exclude) set(to_install OFF) - cmake_policy(SET CMP0057 NEW) if(INSTALL_EXPORT_SET IN_LIST ARGN AND NOT exclude) set(to_install ON) # Make sure we install CCCL into the `include/rapids` subdirectory instead of the default diff --git a/rapids-cmake/cpm/find.cmake b/rapids-cmake/cpm/find.cmake index 4ef528799..128cf2210 100644 --- a/rapids-cmake/cpm/find.cmake +++ b/rapids-cmake/cpm/find.cmake @@ -156,9 +156,7 @@ function(rapids_cpm_find name version) message(FATAL_ERROR "rapids_cpm_find requires you to specify CPM_ARGS before any CPM arguments") endif() - # Add the patch command back into the list of commands to forward along. set(has_patch FALSE) - cmake_policy(SET CMP0057 NEW) foreach(unparsed_arg IN LISTS _RAPIDS_UNPARSED_ARGUMENTS) if(unparsed_arg MATCHES "PATCH_COMMAND") set(has_patch TRUE) @@ -184,7 +182,7 @@ function(rapids_cpm_find name version) endif() if(package_needs_to_be_added) - # Any nonempty patch command should trigger CPMAddPackage. + # Any patch command triggers CPMAddPackage. if(CPM_${name}_SOURCE OR has_patch) CPMAddPackage(NAME ${name} VERSION ${version} ${_RAPIDS_UNPARSED_ARGUMENTS}) else() From a252bde7fb26d5638f59a55965b601c3312d245c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 17 Jan 2024 18:39:04 +0000 Subject: [PATCH 13/15] Don't include modules until after cmake_minimum_required --- .../cpm/cpm_find-patch-command/CMakeLists.txt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/testing/cpm/cpm_find-patch-command/CMakeLists.txt b/testing/cpm/cpm_find-patch-command/CMakeLists.txt index 76a3becff..e4b439ed6 100644 --- a/testing/cpm/cpm_find-patch-command/CMakeLists.txt +++ b/testing/cpm/cpm_find-patch-command/CMakeLists.txt @@ -13,26 +13,25 @@ # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= -include(${rapids-cmake-dir}/cpm/init.cmake) -include(${rapids-cmake-dir}/cpm/cccl.cmake) - cmake_minimum_required(VERSION 3.23.1) project(rapids-cpm_find-patch-command-project LANGUAGES CXX) -find_package(Git) set(deps_dir "${CMAKE_CURRENT_BINARY_DIR}/_cccl_dep") - if(NOT EXISTS "${deps_dir}") -file(MAKE_DIRECTORY "${deps_dir}") -execute_process( - COMMAND ${GIT_EXECUTABLE} clone --depth 1 --branch v2.2.0 https://github.com/NVIDIA/cccl.git - WORKING_DIRECTORY "${deps_dir}") + file(MAKE_DIRECTORY "${deps_dir}") + find_package(Git) + execute_process( + COMMAND ${GIT_EXECUTABLE} clone --depth 1 --branch v2.2.0 https://github.com/NVIDIA/cccl.git + WORKING_DIRECTORY "${deps_dir}") endif() set(cccl_dir "${deps_dir}/cccl") list(APPEND CMAKE_PREFIX_PATH "${cccl_dir}") unset(CPM_SOURCE_CACHE) unset(CPM_SOURCE_CACHE CACHE) + +include(${rapids-cmake-dir}/cpm/init.cmake) +include(${rapids-cmake-dir}/cpm/cccl.cmake) rapids_cpm_init() rapids_cpm_cccl() @@ -41,7 +40,7 @@ if(NOT "${CCCL_ADDED}") endif() execute_process( - COMMAND ${GIT_EXECUTABLE} diff-files --quiet + COMMAND ${GIT_EXECUTABLE} diff-files --quiet RESULT_VARIABLE REPO_IS_DIRTY WORKING_DIRECTORY "${CCCL_SOURCE_DIR}") From ca2c5bdc3951ed1c9fb18e00e71170e0cd86f49b Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 17 Jan 2024 21:06:22 +0000 Subject: [PATCH 14/15] Get project details from rapids-cmake --- testing/cpm/cpm_find-patch-command/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testing/cpm/cpm_find-patch-command/CMakeLists.txt b/testing/cpm/cpm_find-patch-command/CMakeLists.txt index e4b439ed6..bba4324b1 100644 --- a/testing/cpm/cpm_find-patch-command/CMakeLists.txt +++ b/testing/cpm/cpm_find-patch-command/CMakeLists.txt @@ -16,12 +16,15 @@ cmake_minimum_required(VERSION 3.23.1) project(rapids-cpm_find-patch-command-project LANGUAGES CXX) +include("${rapids-cmake-dir}/cpm/detail/package_details.cmake") +rapids_cpm_package_details(CCCL version repository tag shallow exclude) + set(deps_dir "${CMAKE_CURRENT_BINARY_DIR}/_cccl_dep") if(NOT EXISTS "${deps_dir}") file(MAKE_DIRECTORY "${deps_dir}") find_package(Git) execute_process( - COMMAND ${GIT_EXECUTABLE} clone --depth 1 --branch v2.2.0 https://github.com/NVIDIA/cccl.git + COMMAND ${GIT_EXECUTABLE} clone --depth 1 --branch "${tag}" "${repository}" WORKING_DIRECTORY "${deps_dir}") endif() From f4ad409e823f74aceae3ba7bfdcb4ccfdc199998 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 17 Jan 2024 21:07:04 +0000 Subject: [PATCH 15/15] Formatting --- testing/cpm/CMakeLists.txt | 2 +- testing/cpm/cpm_find-patch-command/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/cpm/CMakeLists.txt b/testing/cpm/CMakeLists.txt index cecb2502e..ec4c2e826 100644 --- a/testing/cpm/CMakeLists.txt +++ b/testing/cpm/CMakeLists.txt @@ -23,7 +23,7 @@ add_cmake_config_test( cpm_find-existing-target ) add_cmake_config_test( cpm_find-existing-target-to-export-sets ) add_cmake_config_test( cpm_find-gtest-no-gmock ) add_cmake_config_test( cpm_find-options-escaped ) -add_cmake_config_test( cpm_find-patch-command) +add_cmake_config_test( cpm_find-patch-command ) add_cmake_config_test( cpm_find-restore-cpm-vars ) add_cmake_config_test( cpm_find-version-explicit-install.cmake ) diff --git a/testing/cpm/cpm_find-patch-command/CMakeLists.txt b/testing/cpm/cpm_find-patch-command/CMakeLists.txt index bba4324b1..e5ff71191 100644 --- a/testing/cpm/cpm_find-patch-command/CMakeLists.txt +++ b/testing/cpm/cpm_find-patch-command/CMakeLists.txt @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2023-2024, NVIDIA CORPORATION. +# Copyright (c) 2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.