From 1bcafd859ea59e920466266b1097c8bfd773a762 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Fri, 19 May 2023 09:51:47 -0400 Subject: [PATCH 01/24] DOC --- .github/workflows/build.yaml | 4 ++-- .github/workflows/pr.yaml | 10 +++++----- .github/workflows/test.yaml | 2 +- RAPIDS.cmake | 2 +- ci/build_docs.sh | 2 +- docs/basics.rst | 4 ++-- docs/conf.py | 4 ++-- rapids-cmake/rapids-version.cmake | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5b87fba0d..64f66cd2f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} repo: rapidsai/rapids-cmake @@ -38,7 +38,7 @@ jobs: docs-build: if: github.ref_type == 'branch' secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 with: arch: "amd64" branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 86b683b2a..2977ce28b 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -17,26 +17,26 @@ jobs: - conda-cpp-tests - docs-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.08 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.08 conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 with: build_type: pull-request docs-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 with: build_type: pull-request node_type: "cpu4" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c396f77bd..7751977aa 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 with: build_type: nightly repo: rapidsai/rapids-cmake diff --git a/RAPIDS.cmake b/RAPIDS.cmake index 3dc967790..2d8205e21 100644 --- a/RAPIDS.cmake +++ b/RAPIDS.cmake @@ -20,7 +20,7 @@ # Allow users to control which version is used if(NOT rapids-cmake-version) # Define a default version if the user doesn't set one - set(rapids-cmake-version 23.06) + set(rapids-cmake-version 23.08) endif() # Allow users to control which GitHub repo is fetched diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 9b70864b5..a4c380b6e 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -16,7 +16,7 @@ conda activate docs rapids-print-env -VERSION_NUMBER="23.06" +VERSION_NUMBER="23.08" rapids-logger "Build Sphinx docs" pushd docs diff --git a/docs/basics.rst b/docs/basics.rst index 4efd91c9a..bda2006b7 100644 --- a/docs/basics.rst +++ b/docs/basics.rst @@ -13,7 +13,7 @@ Content `_ into yo cmake_minimum_required(...) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.06/RAPIDS.cmake + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.08/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/_RAPIDS.cmake) endif() include(${CMAKE_CURRENT_BINARY_DIR}/_RAPIDS.cmake) @@ -58,7 +58,7 @@ like this: GIT_REPOSITORY https://github.com//rapids-cmake.git GIT_TAG ) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.06/RAPIDS.cmake + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.08/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake) diff --git a/docs/conf.py b/docs/conf.py index 4bb05d55b..56d801de8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,9 +25,9 @@ # built documents. # # The short X.Y version. -version = "23.06" +version = "23.08" # The full version, including alpha/beta/rc tags. -release = "23.06.00" +release = "23.08.00" # -- General configuration --------------------------------------------------- diff --git a/rapids-cmake/rapids-version.cmake b/rapids-cmake/rapids-version.cmake index 14111c182..2fe83c160 100644 --- a/rapids-cmake/rapids-version.cmake +++ b/rapids-cmake/rapids-version.cmake @@ -17,5 +17,5 @@ # that breaks its usage by cpm/detail/package_details if(NOT DEFINED rapids-cmake-version) - set(rapids-cmake-version 23.06) + set(rapids-cmake-version 23.08) endif() From a63aa0e2fe511d7450f306da06a9a80ed32f8a0c Mon Sep 17 00:00:00 2001 From: Manolis Papadakis Date: Tue, 30 May 2023 13:44:09 -0700 Subject: [PATCH 02/24] Use @loader_path instead of $ORIGIN on MacOS (#403) The dynamic libraries currently produced by rapids-cmake on MacOS for cython modules don't work, because the wrong "ORIGIN" marker is used. The typical suggestion appears to be to use `@loader_path` in place of `$ORIGIN` on MacOS, although there is one more option that I can't currently recall. Please excuse my ignorance around your processes. Please feel free to make/request changes. Authors: - Manolis Papadakis (https://github.com/manopapad) - Bradley Dice (https://github.com/bdice) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rapids-cmake/pull/403 --- example/CMakeLists.txt | 4 ++-- rapids-cmake/cython/add_rpath_entries.cmake | 7 ++++++- rapids-cmake/cython/create_modules.cmake | 7 ++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 00f94e4f6..a6315c8ba 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -98,8 +98,8 @@ rapids_cpm_find(fmt 7.1.3 add_library(example SHARED source.cu) set_target_properties(example - PROPERTIES BUILD_RPATH "\$ORIGIN" - INSTALL_RPATH "\$ORIGIN" + PROPERTIES BUILD_RPATH "$ORIGIN" + INSTALL_RPATH "$ORIGIN" # set target compile options CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON diff --git a/rapids-cmake/cython/add_rpath_entries.cmake b/rapids-cmake/cython/add_rpath_entries.cmake index 387727ab2..58884f9c1 100644 --- a/rapids-cmake/cython/add_rpath_entries.cmake +++ b/rapids-cmake/cython/add_rpath_entries.cmake @@ -72,6 +72,11 @@ function(rapids_cython_add_rpath_entries) list(APPEND cleaned_paths "${path}") endforeach() + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(platform_rpath_origin "@loader_path") + else() + set(platform_rpath_origin "$ORIGIN") + endif() get_property(targets GLOBAL PROPERTY "rapids_cython_associations_${_RAPIDS_CYTHON_TARGET}") foreach(target IN LISTS targets) # Compute the path relative to the current target. @@ -79,7 +84,7 @@ function(rapids_cython_add_rpath_entries) get_target_property(target_source_dir ${target} SOURCE_DIR) foreach(target_path IN LISTS cleaned_paths) cmake_path(RELATIVE_PATH target_path BASE_DIRECTORY "${target_source_dir}") - list(APPEND target_paths "$ORIGIN/${target_path}") + list(APPEND target_paths "${platform_rpath_origin}/${target_path}") endforeach() list(JOIN target_paths ";" target_paths) diff --git a/rapids-cmake/cython/create_modules.cmake b/rapids-cmake/cython/create_modules.cmake index 45272e9c3..91f9614dd 100644 --- a/rapids-cmake/cython/create_modules.cmake +++ b/rapids-cmake/cython/create_modules.cmake @@ -127,7 +127,12 @@ function(rapids_cython_create_modules) install(TARGETS ${cython_module} DESTINATION ${_RAPIDS_CYTHON_INSTALL_DIR}) # Default the INSTALL_RPATH for all modules to $ORIGIN. - set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN") + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(platform_rpath_origin "@loader_path") + else() + set(platform_rpath_origin "$ORIGIN") + endif() + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "${platform_rpath_origin}") # Store any provided associated targets in a global list foreach(associated_target IN LISTS _RAPIDS_CYTHON_ASSOCIATED_TARGETS) From 77435a289ce70b136d49ccded4993829dc18ac52 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 31 May 2023 15:32:49 -0400 Subject: [PATCH 03/24] Fea/move to latest nvbench (#417) Move to latest version of nvbench which includes a fix for a CMake error when using static fmt with a conda env. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rapids-cmake/pull/417 --- .../nvbench/public_fmt_dep_in_conda.diff | 31 ---------- rapids-cmake/cpm/versions.json | 7 +-- testing/cpm/CMakeLists.txt | 1 + testing/cpm/cpm_nvbench-conda.cmake | 59 +++++++++++++++++++ 4 files changed, 61 insertions(+), 37 deletions(-) delete mode 100644 rapids-cmake/cpm/patches/nvbench/public_fmt_dep_in_conda.diff create mode 100644 testing/cpm/cpm_nvbench-conda.cmake diff --git a/rapids-cmake/cpm/patches/nvbench/public_fmt_dep_in_conda.diff b/rapids-cmake/cpm/patches/nvbench/public_fmt_dep_in_conda.diff deleted file mode 100644 index 590a393e3..000000000 --- a/rapids-cmake/cpm/patches/nvbench/public_fmt_dep_in_conda.diff +++ /dev/null @@ -1,31 +0,0 @@ -diff --git a/nvbench/CMakeLists.txt b/nvbench/CMakeLists.txt -index f86bd41..ba6418f 100644 ---- a/nvbench/CMakeLists.txt -+++ b/nvbench/CMakeLists.txt -@@ -76,10 +76,25 @@ target_link_libraries(nvbench - PUBLIC - ${ctk_libraries} - PRIVATE -- fmt::fmt - nvbench_json - nvbench_git_revision - ) -+ -+# ################################################################################################## -+# * conda environment ----------------------------------------------------------------------------- -+rapids_cmake_support_conda_env(conda_env MODIFY_PREFIX_PATH) -+if(TARGET conda_env) -+ # When we are inside a conda env the linker will be set to -+ # `ld.bfd` which will try to resolve all undefined symbols at link time. -+ # -+ # Since we could be using a shared library version of fmt we need -+ # it on the final link line of consumers -+ target_link_libraries(nvbench PRIVATE $ -+ PUBLIC fmt::fmt) -+else() -+ target_link_libraries(nvbench PRIVATE fmt::fmt) -+endif() -+ - target_compile_features(nvbench PUBLIC cuda_std_17 PRIVATE cxx_std_17) - add_dependencies(nvbench.all nvbench) - diff --git a/rapids-cmake/cpm/versions.json b/rapids-cmake/cpm/versions.json index 6276356a9..544b81308 100644 --- a/rapids-cmake/cpm/versions.json +++ b/rapids-cmake/cpm/versions.json @@ -38,17 +38,12 @@ "version" : "0.0", "git_shallow" : false, "git_url" : "https://github.com/NVIDIA/nvbench.git", - "git_tag" : "e477bb386289a11ad8d7e358cff6527cfc593974", + "git_tag" : "083fdc2fc130d84805827c0129f84bb7449ec059", "patches" : [ { "file" : "nvbench/use_existing_fmt.diff", "issue" : "Fix add support for using an existing fmt [https://github.com/NVIDIA/nvbench/pull/125]", "fixed_in" : "" - }, - { - "file" : "nvbench/public_fmt_dep_in_conda.diff", - "issue" : "Propagate fmt requirement in conda envs [https://github.com/NVIDIA/nvbench/pull/127]", - "fixed_in" : "" } ] }, diff --git a/testing/cpm/CMakeLists.txt b/testing/cpm/CMakeLists.txt index bbc6f1927..1120e47f5 100644 --- a/testing/cpm/CMakeLists.txt +++ b/testing/cpm/CMakeLists.txt @@ -64,6 +64,7 @@ add_cmake_build_test( cpm_libcudacxx-verify-install-custom-libdir ) add_cmake_config_test( cpm_nvbench-export.cmake ) add_cmake_config_test( cpm_nvbench-simple.cmake ) add_cmake_config_test( cpm_nvbench-already-found-fmt.cmake ) +add_cmake_build_test( cpm_nvbench-conda.cmake ) add_cmake_build_test( cpm_nvbench-conda-fmt.cmake ) add_cmake_config_test( cpm_nvcomp-export.cmake ) diff --git a/testing/cpm/cpm_nvbench-conda.cmake b/testing/cpm/cpm_nvbench-conda.cmake new file mode 100644 index 000000000..b1604ff03 --- /dev/null +++ b/testing/cpm/cpm_nvbench-conda.cmake @@ -0,0 +1,59 @@ +#============================================================================= +# 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/rmm.cmake) +include(${rapids-cmake-dir}/cpm/nvbench.cmake) + +enable_language(CUDA) +enable_language(CXX) + +include(${rapids-cmake-dir}/cuda/set_architectures.cmake) +rapids_cuda_set_architectures(RAPIDS) + +# Make sure that nvbench can build static fmt from inside +# a conda env +set(ENV{CONDA_BUILD} "1") +set(ENV{BUILD_PREFIX} "/usr/local/build_prefix") +set(ENV{PREFIX} "/opt/local/prefix") +set(ENV{CONDA_PREFIX} "/opt/conda/prefix") +set(NVBench_ENABLE_CUPTI OFF) +rapids_cpm_init() +rapids_cpm_nvbench() + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/use_fmt.cpp" [=[ +#include + +#include + +template +void nvbench_distinct(nvbench::state& state, nvbench::type_list) +{ +} + +using data_type = nvbench::type_list; + +NVBENCH_BENCH_TYPES(nvbench_distinct, NVBENCH_TYPE_AXES(data_type)) + .set_name("distinct") + .set_type_axes_names({"Type"}) + .add_int64_axis("NumRows", {10'000, 100'000, 1'000'000, 10'000'000}); + +int main() { return 0; } +]=]) + + +add_library(uses_fmt SHARED "${CMAKE_CURRENT_BINARY_DIR}/use_fmt.cpp") +target_link_libraries(uses_fmt PRIVATE nvbench::nvbench) +target_compile_features(uses_fmt PRIVATE cxx_std_17) From ec72f2e3605f3a962e81eeb1834c28a968f66530 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Thu, 1 Jun 2023 17:39:02 -0400 Subject: [PATCH 04/24] Remove documentation build scripts for Jenkins (#418) We recently created new scripts for building documentation with GitHub Actions. This PR removes the old scripts that were used by Jenkins and are no longer in use. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rapids-cmake/pull/418 --- ci/docs/build.sh | 60 ------------------------------------------------ 1 file changed, 60 deletions(-) delete mode 100644 ci/docs/build.sh diff --git a/ci/docs/build.sh b/ci/docs/build.sh deleted file mode 100644 index de72f94ef..000000000 --- a/ci/docs/build.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# Copyright (c) 2021, NVIDIA CORPORATION. -######################################### -# rapids-cmake Docs build script for CI # -######################################### - -if [ -z "$PROJECT_WORKSPACE" ]; then - echo ">>>> ERROR: Could not detect PROJECT_WORKSPACE in environment" - echo ">>>> WARNING: This script contains git commands meant for automated building, do not run locally" - exit 1 -fi - -export DOCS_WORKSPACE=$WORKSPACE/docs -export PATH=/opt/conda/bin:/usr/local/cuda/bin:$PATH -export HOME=$WORKSPACE -export PROJECT_WORKSPACE=/rapids/rapids-cmake -export LIBCUDF_KERNEL_CACHE_PATH="$HOME/.jitify-cache" -export NIGHTLY_VERSION=$(echo $BRANCH_VERSION | awk -F. '{print $2}') -export PROJECTS=(rapids-cmake) - -gpuci_logger "Check environment" -env - -gpuci_logger "Check GPU usage" -nvidia-smi - -gpuci_logger "Activate conda env" -. /opt/conda/etc/profile.d/conda.sh -conda activate rapids - -# Using absolute path of python executable to avoid obtaining wrong version of package -gpuci_logger "Install pip only package" -/opt/conda/envs/rapids/bin/python -m pip install sphinxcontrib-moderncmakedomain - -gpuci_logger "Check versions" -python --version -$CC --version -$CXX --version - -gpuci_logger "Check conda environment" -conda info -conda config --show-sources -conda list --show-channel-urls - -# Build Doxygen docs -gpuci_logger "Build Sphinx docs" -cd $PROJECT_WORKSPACE/docs -make html - -#Commit to Website -cd $DOCS_WORKSPACE - -for PROJECT in ${PROJECTS[@]}; do - if [ ! -d "api/$PROJECT/$BRANCH_VERSION" ]; then - mkdir -p api/$PROJECT/$BRANCH_VERSION - fi - rm -rf $DOCS_WORKSPACE/api/$PROJECT/$BRANCH_VERSION/* -done - -mv $PROJECT_WORKSPACE/docs/_build/html/* $DOCS_WORKSPACE/api/rapids-cmake/$BRANCH_VERSION From fbbf6ea27fe0383921454abbb43d268c83de5c3a Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 1 Jun 2023 17:22:47 -0500 Subject: [PATCH 05/24] Upload conda packages for rapids_core_dependencies. (#414) This PR uploads conda packages as CI artifacts for `rapids_core_dependencies`. I also aligned some bits of rapids-cmake's testing scripts/workflows with other RAPIDS repos. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rapids-cmake/pull/414 --- .github/workflows/build.yaml | 10 +++++++++- .github/workflows/test.yaml | 3 +-- ci/build_cpp.sh | 5 +++++ ci/test_cpp.sh | 7 +++++-- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 64f66cd2f..b2de1180a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -31,7 +31,15 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} - repo: rapidsai/rapids-cmake + branch: ${{ inputs.branch }} + date: ${{ inputs.date }} + sha: ${{ inputs.sha }} + upload-conda: + needs: [cpp-build] + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.06 + with: + build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7751977aa..fba047b13 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,4 +1,4 @@ -name: nightly +name: test on: workflow_dispatch: @@ -19,7 +19,6 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 with: build_type: nightly - repo: rapidsai/rapids-cmake branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 0967624e4..1daef26b7 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -1,11 +1,16 @@ #!/bin/bash +# Copyright (c) 2023, NVIDIA CORPORATION. set -euo pipefail source rapids-env-update +export CMAKE_GENERATOR=Ninja + rapids-print-env rapids-logger "Begin cpp build" rapids-mamba-retry mambabuild conda/recipes/rapids_core_dependencies + +rapids-upload-conda-to-s3 cpp diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index d36dc004d..df9f3af7b 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -1,17 +1,20 @@ #!/bin/bash # Copyright (c) 2023, NVIDIA CORPORATION. + set -euo pipefail -rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh +rapids-logger "Generate C++ testing dependencies" rapids-dependency-file-generator \ --output conda \ --file_key test \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch)" | tee env.yaml rapids-mamba-retry env create --force -f env.yaml -n test -set +eu + +# Temporarily allow unbound variables for conda activation. +set +u conda activate test set -u From a4d1abab80b7571c74af51bd7826c864efeec856 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 2 Jun 2023 14:57:17 -0400 Subject: [PATCH 06/24] rapids_find_generate_module Support user code blocks (#415) At times people need to have custom code blocks in a find module. This offers the ability to have a pre-amble or post-able to handle all use cases. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rapids-cmake/pull/415 --- rapids-cmake/find/generate_module.cmake | 55 ++++++++++++++++++- .../find/template/find_module.cmake.in | 5 ++ testing/find/CMakeLists.txt | 6 +- ...ate_module-back-final-code-block-var.cmake | 22 ++++++++ ...e_module-back-initial-code-block-var.cmake | 22 ++++++++ .../CMakeLists.txt | 40 ++++++++++++++ .../include/rapids-cmake-test-header_only.hpp | 0 7 files changed, 148 insertions(+), 2 deletions(-) create mode 100644 testing/find/find_generate_module-back-final-code-block-var.cmake create mode 100644 testing/find/find_generate_module-back-initial-code-block-var.cmake create mode 100644 testing/find/find_generate_module-code-blocks/CMakeLists.txt create mode 100644 testing/find/find_generate_module-code-blocks/include/rapids-cmake-test-header_only.hpp diff --git a/rapids-cmake/find/generate_module.cmake b/rapids-cmake/find/generate_module.cmake index 4ef57aa26..8b2694d2a 100644 --- a/rapids-cmake/find/generate_module.cmake +++ b/rapids-cmake/find/generate_module.cmake @@ -34,6 +34,8 @@ Generate a Find*.cmake module for the requested package [INCLUDE_SUFFIXES ] [VERSION ] [NO_CONFIG] + [INITIAL_CODE_BLOCK ] + [FINAL_CODE_BLOCK ] [BUILD_EXPORT_SET ] [INSTALL_EXPORT_SET ] ) @@ -87,6 +89,20 @@ when installed. When provided will stop the generated Find Module from first searching for the projects shipped Find Config. +``INITIAL_CODE_BLOCK`` + Optional value of the variable that holds a string of code that will + be executed as the first step of this config file. + + Note: This requires the code block variable instead of the contents + so that we can properly insert CMake code + + ``FINAL_CODE_BLOCK`` + Optional value of the variable that holds a string of code that will + be executed as the last step of this config file. + + Note: This requires the code block variable instead of the contents + so that we can properly insert CMake code + ``BUILD_EXPORT_SET`` Record that this custom FindPackage module needs to be part of our build directory export set. This means that it will be @@ -103,12 +119,34 @@ Result Variables :cmake:variable:`CMAKE_MODULE_PATH` will be modified to include the folder where `Find.cmake` is located. + +Example on how to properly use :cmake:command:`rapids_find_generate_module`: + +.. code-block:: cmake + + ... + + rapids_find_generate_module( + RDKAFKA + HEADER_NAMES rdkafkacpp.h + LIBRARY_NAMES rdkafka++ + BUILD_EXPORT_SET consumer-exports + INSTALL_EXPORT_SET consumer-exports + ) + rapids_find_package( + RDKAFKA REQUIRED + BUILD_EXPORT_SET consumer-exports + INSTALL_EXPORT_SET consumer-exports + ) + + #]=======================================================================] +# cmake-lint: disable=R0915 function(rapids_find_generate_module name) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.find.generate_module") set(options NO_CONFIG) - set(one_value VERSION BUILD_EXPORT_SET INSTALL_EXPORT_SET) + set(one_value VERSION BUILD_EXPORT_SET INSTALL_EXPORT_SET INITIAL_CODE_BLOCK FINAL_CODE_BLOCK) set(multi_value HEADER_NAMES LIBRARY_NAMES INCLUDE_SUFFIXES) cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) @@ -147,6 +185,21 @@ function(rapids_find_generate_module name) endif() endif() + if(DEFINED _RAPIDS_INITIAL_CODE_BLOCK) + if(NOT DEFINED ${_RAPIDS_INITIAL_CODE_BLOCK}) + message(FATAL_ERROR "INITIAL_CODE_BLOCK variable `${_RAPIDS_INITIAL_CODE_BLOCK}` doesn't exist" + ) + endif() + set(_RAPIDS_FIND_INITIAL_CODE_BLOCK "${${_RAPIDS_INITIAL_CODE_BLOCK}}") + endif() + + if(DEFINED _RAPIDS_FINAL_CODE_BLOCK) + if(NOT DEFINED ${_RAPIDS_FINAL_CODE_BLOCK}) + message(FATAL_ERROR "FINAL_CODE_BLOCK variable `${_RAPIDS_FINAL_CODE_BLOCK}` doesn't exist") + endif() + set(_RAPIDS_FIND_FINAL_CODE_BLOCK "${${_RAPIDS_FINAL_CODE_BLOCK}}") + endif() + # Need to generate the module configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/find_module.cmake.in" "${CMAKE_BINARY_DIR}/cmake/find_modules/Find${name}.cmake" @ONLY) diff --git a/rapids-cmake/find/template/find_module.cmake.in b/rapids-cmake/find/template/find_module.cmake.in index 9a7a2d5a4..3ab78f70a 100644 --- a/rapids-cmake/find/template/find_module.cmake.in +++ b/rapids-cmake/find/template/find_module.cmake.in @@ -45,6 +45,9 @@ This module will set the following variables in your project: #]=======================================================================] # Prefer using a Config module if it exists for this project + +@_RAPIDS_FIND_INITIAL_CODE_BLOCK@ + set(@_RAPIDS_PKG_NAME@_NO_CONFIG @_RAPIDS_NO_CONFIG@) if(NOT @_RAPIDS_PKG_NAME@_NO_CONFIG) find_package(@_RAPIDS_PKG_NAME@ CONFIG QUIET) @@ -113,5 +116,7 @@ if(@_RAPIDS_PKG_NAME@_FOUND) endif() endif() +@_RAPIDS_FIND_FINAL_CODE_BLOCK@ + unset(@_RAPIDS_PKG_NAME@_NO_CONFIG) unset(@_RAPIDS_PKG_NAME@_IS_HEADER_ONLY) diff --git a/testing/find/CMakeLists.txt b/testing/find/CMakeLists.txt index eb5eb7e3d..0684cb03d 100644 --- a/testing/find/CMakeLists.txt +++ b/testing/find/CMakeLists.txt @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-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. @@ -40,3 +40,7 @@ add_cmake_config_test( find_package-version-required-explicit-failed.cmake SHOUL add_cmake_config_test( find_generate_module-build ) add_cmake_config_test( find_generate_module-install ) add_cmake_config_test( find_generate_module-header-only ) + +add_cmake_config_test( find_generate_module-code-blocks ) +add_cmake_config_test( find_generate_module-back-initial-code-block-var.cmake SHOULD_FAIL "INITIAL_CODE_BLOCK variable `var_doesn't_exist` doesn't exist") +add_cmake_config_test( find_generate_module-back-final-code-block-var.cmake SHOULD_FAIL "FINAL_CODE_BLOCK variable `var_doesn't_exist` doesn't exist") diff --git a/testing/find/find_generate_module-back-final-code-block-var.cmake b/testing/find/find_generate_module-back-final-code-block-var.cmake new file mode 100644 index 000000000..abcdc7a1f --- /dev/null +++ b/testing/find/find_generate_module-back-final-code-block-var.cmake @@ -0,0 +1,22 @@ +#============================================================================= +# 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}/find/generate_module.cmake) + +rapids_find_generate_module( RapidsTest + HEADER_NAMES rapids-cmake-test-header_only.hpp + FINAL_CODE_BLOCK var_doesn't_exist + INSTALL_EXPORT_SET test_set + ) diff --git a/testing/find/find_generate_module-back-initial-code-block-var.cmake b/testing/find/find_generate_module-back-initial-code-block-var.cmake new file mode 100644 index 000000000..241116599 --- /dev/null +++ b/testing/find/find_generate_module-back-initial-code-block-var.cmake @@ -0,0 +1,22 @@ +#============================================================================= +# 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}/find/generate_module.cmake) + +rapids_find_generate_module( RapidsTest + HEADER_NAMES rapids-cmake-test-header_only.hpp + INITIAL_CODE_BLOCK var_doesn't_exist + INSTALL_EXPORT_SET test_set + ) diff --git a/testing/find/find_generate_module-code-blocks/CMakeLists.txt b/testing/find/find_generate_module-code-blocks/CMakeLists.txt new file mode 100644 index 000000000..77a1d768f --- /dev/null +++ b/testing/find/find_generate_module-code-blocks/CMakeLists.txt @@ -0,0 +1,40 @@ +#============================================================================= +# 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}/find/generate_module.cmake) + +cmake_minimum_required(VERSION 3.23.1) +project(rapids-test-project LANGUAGES CXX) + +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +# Generate the find module +set(initial_code_block [[set(RapidsTest_INITIAL_CODE_BLOCK TRUE)]]) +set(final_code_block [[set(RapidsTest_FINAL_CODE_BLOCK TRUE)]]) +rapids_find_generate_module( RapidsTest + HEADER_NAMES rapids-cmake-test-header_only.hpp + INITIAL_CODE_BLOCK initial_code_block + FINAL_CODE_BLOCK final_code_block + INSTALL_EXPORT_SET test_set + ) + +find_package(RapidsTest REQUIRED) + +if(NOT RapidsTest_INITIAL_CODE_BLOCK) + message(FATAL_ERROR "RapidsTest_FOUND should be set to TRUE") +endif() +if(NOT RapidsTest_FINAL_CODE_BLOCK) + message(FATAL_ERROR "RAPIDSTEST_FOUND should be set to TRUE") +endif() diff --git a/testing/find/find_generate_module-code-blocks/include/rapids-cmake-test-header_only.hpp b/testing/find/find_generate_module-code-blocks/include/rapids-cmake-test-header_only.hpp new file mode 100644 index 000000000..e69de29bb From a8eb3f1134986bf7850a9c85a6d6e2b0d55dd347 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 5 Jun 2023 20:04:12 -0400 Subject: [PATCH 07/24] Rewrite of rapids_test_install_relocatable to support genex expressions (#410) Complete new implementation of how we install tests and make sure all the referenced paths are re-rooted to the install location. We do this by injecting install time code that re-parses the test files and reconstructs versions for installation with properly re-rooted paths. The major upside for this implementation is it allows us to support abitrary generator expressions since we now parse the output from CMake after generator expression evaluation. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rapids-cmake/pull/410 --- rapids-cmake/test/add.cmake | 24 +- .../generate_installed_CTestTestfile.cmake | 249 ++++++++++++++++++ .../test/detail/record_test_command.cmake | 40 --- .../test/detail/record_test_component.cmake | 3 + rapids-cmake/test/install_relocatable.cmake | 58 ++-- testing/test/CMakeLists.txt | 2 +- testing/test/add-with-install-component.cmake | 6 - .../install_relocatable-include-in-all.cmake | 25 +- testing/test/install_relocatable-labels.cmake | 14 +- testing/test/install_relocatable-simple.cmake | 31 ++- 10 files changed, 332 insertions(+), 120 deletions(-) create mode 100644 rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake delete mode 100644 rapids-cmake/test/detail/record_test_command.cmake diff --git a/rapids-cmake/test/add.cmake b/rapids-cmake/test/add.cmake index a78174689..f36a64adf 100644 --- a/rapids-cmake/test/add.cmake +++ b/rapids-cmake/test/add.cmake @@ -104,8 +104,8 @@ function(rapids_test_add) endif() add_test(NAME ${_RAPIDS_TEST_NAME} - COMMAND ${CMAKE_COMMAND} "-Dcommand_to_run=${command}" "-Dcommand_args=${args}" -P - "${_rapids_run_gpu_test_script_dir}${_rapids_run_gpu_test_script}" + COMMAND ${CMAKE_COMMAND} "-Dcommand_to_run=${command}" "-Dcommand_args=${args}" + "-P=${_rapids_run_gpu_test_script_dir}${_rapids_run_gpu_test_script}" WORKING_DIRECTORY "${_RAPIDS_TEST_WORKING_DIRECTORY}") include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/gpu_requirements.cmake) @@ -116,29 +116,13 @@ function(rapids_test_add) if(_RAPIDS_TEST_INSTALL_COMPONENT_SET) include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/record_test_component.cmake) - include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/record_test_command.cmake) include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/record_install.cmake) - if(NOT TARGET rapids_test_install_${_RAPIDS_TEST_INSTALL_COMPONENT_SET}) - add_library(rapids_test_install_${_RAPIDS_TEST_INSTALL_COMPONENT_SET} INTERFACE) - endif() - + rapids_test_record_test_component(NAME ${_RAPIDS_TEST_NAME} COMPONENT + ${_RAPIDS_TEST_INSTALL_COMPONENT_SET}) if(TARGET ${command_or_target}) - get_target_property(output_name ${command_or_target} OUTPUT_NAME) - if(output_name) - set(command_for_install "./${output_name}") - else() - set(command_for_install "./${command_or_target}") - endif() rapids_test_record_install(TARGET ${command_or_target} COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET}) - else() - set(command_for_install ${command_or_target}) endif() - rapids_test_record_test_component(NAME ${_RAPIDS_TEST_NAME} COMPONENT - ${_RAPIDS_TEST_INSTALL_COMPONENT_SET}) - rapids_test_record_test_command(NAME ${_RAPIDS_TEST_NAME} COMMAND cmake - "-Dcommand_to_run=${command_for_install}" - "-Dcommand_args=${args}" -P "${_rapids_run_gpu_test_script}") endif() endfunction() diff --git a/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake b/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake new file mode 100644 index 000000000..54fd2ddff --- /dev/null +++ b/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake @@ -0,0 +1,249 @@ +#============================================================================= +# 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_guard(GLOBAL) + +cmake_policy(SET CMP0007 NEW) # allow empty list entries +cmake_policy(SET CMP0009 NEW) # don't follow symlinks +cmake_policy(SET CMP0057 NEW) # allow `if( IN_LIST )` + +#[=[ +The goal of this script is to re-parse the `CTestTestfile` +and record each test and relevant properties for execution +once installed. + +This is done as part of the install process so that CMake's +generator expressions have been fully evaluated, and therefore +we can support them in rapids-cmake-test + +Since in CMake Script mode we have no support for `add_test`, +`set_tests_properties` and `subdirs` we write our own version +of those functions which will allow us re-parse the information +in the `CTestTestfile` when we include it. + + +]=] + +# ============================================================================= +# ============== Helper Function ==================== +# ============================================================================= + +# Convert values from CMake properties so that any path build directory paths become re-rooted in +# the install tree +# +# cmake-lint: disable=W0106 +function(convert_paths_to_install_dir prop_var) + set(possible_build_path "${${prop_var}}") + cmake_path(GET possible_build_path FILENAME name) + + get_property(install_loc GLOBAL PROPERTY ${name}_install) + if(install_loc) + get_property(build_loc GLOBAL PROPERTY ${name}_build) + string(REPLACE "${build_loc}" "${install_loc}/${name}" install_value "${possible_build_path}") + else() + string(REPLACE "${_RAPIDS_BUILD_DIR}" "\${CMAKE_INSTALL_PREFIX}" install_value + "${possible_build_path}") + endif() + set(${prop_var} "${install_value}" PARENT_SCOPE) +endfunction() + +# Convert a list of `=` entries +# +# cmake-lint: disable=W0105 +function(find_and_convert_paths_from_var_list prop_var) + set(test_env_vars_and_values "${${prop_var}}") + foreach(env_tuple IN LISTS test_env_vars_and_values) + string(REPLACE "\"" "" env_tuple "${env_tuple}") + string(REPLACE "=" ";" env_tuple "${env_tuple}") + + list(GET env_tuple 0 env_var) # get the name + list(LENGTH env_tuple length) + if(length EQUAL 1) + list(APPEND transformed_vars_and_values "${env_var}=") + else() + list(GET env_tuple 1 env_value) # get the value + convert_paths_to_install_dir(env_value) + list(APPEND transformed_vars_and_values "${env_var}=${env_value}") + endif() + endforeach() + set(${prop_var} "${transformed_vars_and_values}" PARENT_SCOPE) +endfunction() + +# ============================================================================= +# ============== Function Overrides ==================== +# ============================================================================= + +# Provide an `add_test` function signature since the built-in version doesn't exist in script mode +function(add_test name command) + if(NOT name IN_LIST _RAPIDS_TESTS_TO_RUN) + return() + endif() + + string(APPEND test_file_content "add_test([=[${name}]=]") + + # Transform absolute path to relative install path + cmake_path(GET command FILENAME cname) + if(cname STREQUAL cmake) + # rewrite the abs path to cmake to a relative version so that we don't care where cmake is + set(command "cmake") + else() + get_property(install_loc GLOBAL PROPERTY ${name}_install) + if(install_loc) + get_property(build_loc GLOBAL PROPERTY ${name}_build) + string(REPLACE "${build_loc}" "${install_loc}/${name}" command "${command}") + endif() + endif() + + # convert paths from args to be re-rooted in the install tree + set(args "${ARGN}") + find_and_convert_paths_from_var_list(args) + + # convert args from a list to a single string that is space separated + string(JOIN " " args ${args}) + + string(APPEND test_file_content " \"${command}\" ${args})\n") + set(test_file_content "${test_file_content}" PARENT_SCOPE) +endfunction() + +# Provide a `set_tests_properties` function signature since the built-in version doesn't exist in +# script mode +function(set_tests_properties name) + if(NOT name IN_LIST _RAPIDS_TESTS_TO_RUN) + return() + endif() + + set(options PROPERTIES) + set(env_props ENVIRONMENT # + ENVIRONMENT_MODIFICATION) + set(one_value + FIXTURES_CLEANUP # + FIXTURES_REQUIRED # + FIXTURES_SETUP # + LABELS # + MEASUREMENT # + PASS_REGULAR_EXPRESSION # + PROCESSOR_AFFINITY # + PROCESSORS # + REQUIRED_FILES # + RESOURCE_GROUPS # + RESOURCE_LOCK # + RUN_SERIAL # + SKIP_REGULAR_EXPRESSION # + SKIP_RETURN_CODE # + TIMEOUT # + TIMEOUT_AFTER_MATCH # + WILL_FAIL) + set(multi_value_no_propagate + _BACKTRACE_TRIPLES # + ATTACHED_FILES # + ATTACHED_FILES_ON_FAIL # + WORKING_DIRECTORY) + cmake_parse_arguments(_RAPIDS_TEST "${options}" "${one_value}" + "${env_props};${multi_value_no_propagate}" ${ARGN}) + foreach(prop IN LISTS env_props) + if(_RAPIDS_TEST_${prop}) + set(prop_value "${_RAPIDS_TEST_${prop}}") + find_and_convert_paths_from_var_list(prop_value) + string(APPEND test_prop_content + "set_tests_properties([=[${name}]=] PROPERTIES ${prop} ${prop_value})\n") + endif() + endforeach() + + foreach(prop IN LISTS one_value) + if(_RAPIDS_TEST_${prop}) + set(prop_value "${_RAPIDS_TEST_${prop}}") + convert_paths_to_install_dir(prop_value) + string(APPEND test_prop_content + "set_tests_properties([=[${name}]=] PROPERTIES ${prop} ${prop_value})\n") + endif() + endforeach() + + string(APPEND test_file_content "${test_prop_content}\n") + set(test_file_content "${test_file_content}" PARENT_SCOPE) +endfunction() + +# Provide a `subdirs` function signature since the built-in version doesn't exist in script mode +function(subdirs name) + string(APPEND test_file_content "\n") + if(EXISTS "${name}/CTestTestfile.cmake") + include("${name}/CTestTestfile.cmake") + endif() + set(test_file_content "${test_file_content}" PARENT_SCOPE) +endfunction() + +# ============================================================================= +# ============== Parse Install Location Functions ==================== +# ============================================================================= +function(extract_install_info line) + # We have a problem where we want to split on spaces but only when it is between two UPPER CASE + # letters and not in quotes :( We can't use string(REPLACE " ") since that will split paths with + # spaces + + # what we can do is split on quotes and make this in a list. At that point we can split all other + # entries again + string(REPLACE "\"" ";" line "${line}") + # item 1 is the install location item 2 is the filter if valid item 3+ are the lists of files + # being installed + list(GET line 2 type) + if(type STREQUAL " TYPE SHARED_LIBRARY FILES " OR type STREQUAL " TYPE STATIC_LIBRARY FILES " + OR type STREQUAL " TYPE OBJECT_LIBRARY FILES " OR type STREQUAL " TYPE EXECUTABLE FILES ") + list(GET line 1 install_loc) + list(GET line 3 build_loc) + cmake_path(GET build_loc FILENAME name) + set_property(GLOBAL PROPERTY ${name}_install ${install_loc}) + set_property(GLOBAL PROPERTY ${name}_build ${build_loc}) + endif() +endfunction() + +# +# Find all the cmake_install.cmake files in the install directory and parse them for install rules +function(determine_install_location_of_all_targets) + file(GLOB_RECURSE install_rule_files "${_RAPIDS_BUILD_DIR}/cmake_install.cmake") + foreach(file IN LISTS install_rule_files) + file(STRINGS "${file}" contents REGEX "INSTALL DESTINATION") + foreach(line IN LISTS contents) + extract_install_info("${line}") + endforeach() + endforeach() +endfunction() + +# ============================================================================= +# ============== Generate Install CTestTestfile ==================== +# ============================================================================= +determine_install_location_of_all_targets() +# Setup the install location of `run_gpu_test` +set_property(GLOBAL PROPERTY run_gpu_test.cmake_install ".") +set_property(GLOBAL PROPERTY run_gpu_test.cmake_build + "${_RAPIDS_BUILD_DIR}/rapids-cmake/./run_gpu_test.cmake") + +include(${CMAKE_CURRENT_LIST_DIR}/default_names.cmake) +set(test_file_content + " +set(CTEST_SCRIPT_DIRECTORY \".\") +set(CMAKE_INSTALL_PREFIX \"./${_RAPIDS_INSTALL_PREFIX}\") +set(CTEST_RESOURCE_SPEC_FILE \"./${rapids_test_json_file_name}\") +execute_process(COMMAND ./${rapids_test_generate_exe_name} OUTPUT_FILE \"\${CTEST_RESOURCE_SPEC_FILE}\") +\n\n +") + +# will cause the above `add_test`, etc hooks to trigger filling up the contents of +# `test_file_content` +if(EXISTS "${_RAPIDS_BUILD_DIR}/CTestTestfile.cmake") + # Support multi-generators by setting the CTest config mode to be equal to the install mode + set(CTEST_CONFIGURATION_TYPE "${CMAKE_INSTALL_CONFIG_NAME}") + include("${_RAPIDS_BUILD_DIR}/CTestTestfile.cmake") +endif() + +file(WRITE "${test_launcher_file}" "${test_file_content}") diff --git a/rapids-cmake/test/detail/record_test_command.cmake b/rapids-cmake/test/detail/record_test_command.cmake deleted file mode 100644 index 4b740a1ff..000000000 --- a/rapids-cmake/test/detail/record_test_command.cmake +++ /dev/null @@ -1,40 +0,0 @@ -#============================================================================= -# 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. -# 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_guard(GLOBAL) - -#[=======================================================================[.rst: -rapids_test_record_test_command -------------------------------- - -.. versionadded:: v23.04.00 - -Record the test command that needs to run when executed via ctest after installation - - .. code-block:: cmake - - rapids_test_record_test_command(NAME COMMAND command ...) - -#]=======================================================================] -function(rapids_test_record_test_command) - list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.record_test_command") - - set(options) - set(one_value NAME) - set(multi_value COMMAND) - cmake_parse_arguments(_RAPIDS_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) - - set_property(TEST ${_RAPIDS_TEST_NAME} PROPERTY INSTALL_COMMAND "${_RAPIDS_TEST_COMMAND}") -endfunction() diff --git a/rapids-cmake/test/detail/record_test_component.cmake b/rapids-cmake/test/detail/record_test_component.cmake index cd68302c3..fb65a9d59 100644 --- a/rapids-cmake/test/detail/record_test_component.cmake +++ b/rapids-cmake/test/detail/record_test_component.cmake @@ -37,6 +37,9 @@ function(rapids_test_record_test_component) cmake_parse_arguments(_RAPIDS_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) set(component ${_RAPIDS_TEST_COMPONENT}) + if(NOT TARGET rapids_test_install_${component}) + add_library(rapids_test_install_${component} INTERFACE) + endif() set_property(TARGET rapids_test_install_${component} APPEND PROPERTY "TESTS_TO_RUN" "${_RAPIDS_TEST_NAME}") endfunction() diff --git a/rapids-cmake/test/install_relocatable.cmake b/rapids-cmake/test/install_relocatable.cmake index 6e6495a71..c0f0b4179 100644 --- a/rapids-cmake/test/install_relocatable.cmake +++ b/rapids-cmake/test/install_relocatable.cmake @@ -33,8 +33,9 @@ by `ctest` in parallel with GPU awareness. Will install all tests created by :cmake:command:`rapids_test_add` that are part of the provided ``INSTALL_COMPONENT_SET``. -The :cmake:command:`rapids_test_install_relocatable` presumes that all -arguments provided to the tests are machine independent (no absolute paths). +The :cmake:command:`rapids_test_install_relocatable` will transform all +test arguments or properties on install tests that reference the build directory to reference +the install directory. ``INSTALL_COMPONENT_SET`` Record which test component infrastructure to be installed @@ -69,40 +70,35 @@ function(rapids_test_install_relocatable) get_target_property(targets_to_install rapids_test_install_${component} TARGETS_TO_INSTALL) get_target_property(tests_to_run rapids_test_install_${component} TESTS_TO_RUN) - include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/default_names.cmake) - set(content - " - set(CTEST_SCRIPT_DIRECTORY \".\") - set(CTEST_RESOURCE_SPEC_FILE \"./${rapids_test_json_file_name}\") - execute_process(COMMAND ./${rapids_test_generate_exe_name} OUTPUT_FILE \"\${CTEST_RESOURCE_SPEC_FILE}\") - ") - - foreach(test IN LISTS tests_to_run) - get_test_property(${test} INSTALL_COMMAND command) - get_test_property(${test} RESOURCE_GROUPS resources) - get_test_property(${test} LABELS labels) - string(APPEND content "add_test([=[${test}]=] ${command})\n") - if(resources) - string(APPEND content - "set_tests_properties([=[${test}]=] PROPERTIES RESOURCE_GROUPS ${resources})\n") - endif() - if(labels) - string(APPEND content "set_tests_properties([=[${test}]=] PROPERTIES LABELS ${labels})\n") - endif() - endforeach() - - set(test_launcher_file - "${CMAKE_CURRENT_BINARY_DIR}/rapids-cmake/${_RAPIDS_TEST_INSTALL_COMPONENT_SET}/CTestTestfile.cmake.to_install" - ) - file(WRITE "${test_launcher_file}" "${content}") - install(FILES "${test_launcher_file}" + string(REGEX REPLACE "/" ";" from_install_prefix "${_RAPIDS_TEST_DESTINATION}") + list(TRANSFORM from_install_prefix REPLACE ".+" "../") + list(JOIN from_install_prefix "" from_install_prefix) + + # cmake-lint: disable=W0106 + install(CODE " + # set variables needed by `generate_installed_CTestTestfile.cmake` + set(_RAPIDS_TEST_DESTINATION \"${_RAPIDS_TEST_DESTINATION}\") + set(_RAPIDS_INSTALL_PREFIX \"${from_install_prefix}\") + set(_RAPIDS_BUILD_DIR \"${CMAKE_CURRENT_BINARY_DIR}\") + set(_RAPIDS_INSTALL_COMPONENT_SET \"${_RAPIDS_TEST_INSTALL_COMPONENT_SET}\") + set(_RAPIDS_TARGETS_INSTALLED \"${targets_to_install}\") + set(_RAPIDS_TESTS_TO_RUN \"${tests_to_run}\") + set(test_launcher_file \"${CMAKE_CURRENT_BINARY_DIR}/rapids-cmake/testing/CTestTestfile.cmake.to_install\") + + # parse the CTestTestfile and store installable version in `test_launcher_file` + message(STATUS \"Generating install version of CTestTestfile.cmake\") + cmake_policy(SET CMP0011 NEW) # PUSH/POP for `include` + include(\"${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/generate_installed_CTestTestfile.cmake\") + + # install `test_launcher_file` + file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${_RAPIDS_TEST_DESTINATION}\" TYPE FILE RENAME \"CTestTestfile.cmake\" FILES \"\${test_launcher_file}\") + " COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET} - DESTINATION ${_RAPIDS_TEST_DESTINATION} - RENAME "CTestTestfile.cmake" ${to_exclude}) # We need to install the rapids-test gpu detector, and the json script we also need to write out / # install the new CTestTestfile.cmake + include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/default_names.cmake) if(EXISTS "${PROJECT_BINARY_DIR}/rapids-cmake/${rapids_test_generate_exe_name}") install(PROGRAMS "${PROJECT_BINARY_DIR}/rapids-cmake/${rapids_test_generate_exe_name}" COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET} DESTINATION ${_RAPIDS_TEST_DESTINATION} diff --git a/testing/test/CMakeLists.txt b/testing/test/CMakeLists.txt index cbcc02fb4..7eee56e58 100644 --- a/testing/test/CMakeLists.txt +++ b/testing/test/CMakeLists.txt @@ -42,7 +42,7 @@ set(wrong_component_message "No install component set [wrong_component] can be f add_cmake_build_test(install_relocatable-include-in-all.cmake) add_cmake_build_test(install_relocatable-labels.cmake) add_cmake_build_test(install_relocatable-no-tests.cmake) -add_cmake_config_test(install_relocatable-simple.cmake) +add_cmake_build_test(install_relocatable-simple.cmake) add_cmake_config_test(install_relocatable-wrong-component.cmake SHOULD_FAIL "${wrong_component_message}") add_cmake_ctest_test(add-impossible-allocation SHOULD_FAIL "Insufficient resources for test") diff --git a/testing/test/add-with-install-component.cmake b/testing/test/add-with-install-component.cmake index 688305c96..dc0feee96 100644 --- a/testing/test/add-with-install-component.cmake +++ b/testing/test/add-with-install-component.cmake @@ -37,9 +37,3 @@ get_target_property(names rapids_test_install_testing TARGETS_TO_INSTALL) if(NOT "verify_alloc" IN_LIST names) message(FATAL_ERROR "Failed to record `verify_alloc` as a target to be installed in the testing component") endif() - -# Verify we recorded some install command for `simple_test` -get_test_property(simple_test INSTALL_COMMAND install_command) -if(NOT install_command) - message(FATAL_ERROR "Failed to record the command to run `simple_test` after installing it") -endif() diff --git a/testing/test/install_relocatable-include-in-all.cmake b/testing/test/install_relocatable-include-in-all.cmake index 44f3c0eef..06227a5e9 100644 --- a/testing/test/install_relocatable-include-in-all.cmake +++ b/testing/test/install_relocatable-include-in-all.cmake @@ -18,18 +18,18 @@ include(${rapids-cmake-dir}/test/add.cmake) include(${rapids-cmake-dir}/test/install_relocatable.cmake) enable_language(CUDA) -rapids_test_init() +enable_testing() +rapids_test_init() rapids_test_add(NAME verify_ COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing) rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/testing INCLUDE_IN_ALL) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake" +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install_rules.cmake" "set(install_rules_file \"${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake\")") - -file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake" +file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install_rules.cmake" [=[ file(READ "${install_rules_file}" contents) @@ -39,14 +39,25 @@ if(is_found EQUAL -1) message(FATAL_ERROR "`rapids_test_install_relocatable` failed to mark items as EXCLUDE_FROM_ALL") endif() ]=]) + add_custom_target(verify_install_rule ALL - COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake") + COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install_rules.cmake") -set(generated_testfile "${CMAKE_CURRENT_BINARY_DIR}/rapids-cmake/testing/CTestTestfile.cmake.to_install") -file(READ "${generated_testfile}" contents) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" + "set(installed_test_file \"${CMAKE_CURRENT_BINARY_DIR}/install/bin/testing/CTestTestfile.cmake\")") +file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" +[=[ + +file(READ "${installed_test_file}" contents) set(execute_process_match_string [===[execute_process(COMMAND ./generate_ctest_json OUTPUT_FILE "${CTEST_RESOURCE_SPEC_FILE}")]===]) string(FIND "${contents}" ${execute_process_match_string} is_found) if(is_found EQUAL -1) message(FATAL_ERROR "Failed to generate a `execute_process` with escaped CTEST_RESOURCE_SPEC_FILE") endif() +]=]) + +add_custom_target(install_testing_component ALL + COMMAND ${CMAKE_COMMAND} --install "${CMAKE_CURRENT_BINARY_DIR}" --component testing --prefix install/ + COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" + ) diff --git a/testing/test/install_relocatable-labels.cmake b/testing/test/install_relocatable-labels.cmake index cadcb6cdf..11c682675 100644 --- a/testing/test/install_relocatable-labels.cmake +++ b/testing/test/install_relocatable-labels.cmake @@ -18,6 +18,7 @@ include(${rapids-cmake-dir}/test/add.cmake) include(${rapids-cmake-dir}/test/install_relocatable.cmake) enable_language(CUDA) +enable_testing() rapids_test_init() rapids_test_add(NAME verify_labels COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing) @@ -26,11 +27,20 @@ set_tests_properties(verify_labels PROPERTIES LABELS "has_label") rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/testing) -set(generated_testfile "${CMAKE_CURRENT_BINARY_DIR}/rapids-cmake/testing/CTestTestfile.cmake.to_install") -file(READ "${generated_testfile}" contents) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" + "set(installed_test_file \"${CMAKE_CURRENT_BINARY_DIR}/install/bin/testing/CTestTestfile.cmake\")") +file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" +[==[ +file(READ "${installed_test_file}" contents) set(labels_match_string [===[PROPERTIES LABELS has_label]===]) string(FIND "${contents}" "${labels_match_string}" is_found) if(is_found EQUAL -1) message(FATAL_ERROR "Failed to record the LABELS property") endif() +]==]) + +add_custom_target(install_testing_component ALL + COMMAND ${CMAKE_COMMAND} --install "${CMAKE_CURRENT_BINARY_DIR}" --component testing --prefix install/ + COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" + ) diff --git a/testing/test/install_relocatable-simple.cmake b/testing/test/install_relocatable-simple.cmake index 910ef7c99..387ee13db 100644 --- a/testing/test/install_relocatable-simple.cmake +++ b/testing/test/install_relocatable-simple.cmake @@ -18,6 +18,7 @@ include(${rapids-cmake-dir}/test/add.cmake) include(${rapids-cmake-dir}/test/install_relocatable.cmake) enable_language(CUDA) +enable_testing() rapids_test_init() rapids_test_add(NAME verify_ COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing) @@ -27,7 +28,6 @@ rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake" "set(install_rules_file \"${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake\")") - file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake" [=[ @@ -41,25 +41,30 @@ endif() add_custom_target(verify_install_rule ALL COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake") -set(generated_testfile "${CMAKE_CURRENT_BINARY_DIR}/rapids-cmake/testing/CTestTestfile.cmake.to_install") -file(READ "${generated_testfile}" contents) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" + "set(installed_test_file \"${CMAKE_CURRENT_BINARY_DIR}/install/bin/testing/CTestTestfile.cmake\")") +file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" +[==[ +file(READ "${installed_test_file}" contents) set(execute_process_match_string [===[execute_process(COMMAND ./generate_ctest_json OUTPUT_FILE "${CTEST_RESOURCE_SPEC_FILE}")]===]) string(FIND "${contents}" ${execute_process_match_string} is_found) if(is_found EQUAL -1) message(FATAL_ERROR "Failed to generate a `execute_process` with escaped CTEST_RESOURCE_SPEC_FILE") endif() - -set(add_test_match_strings [===[add_test([=[verify_]=] cmake;-Dcommand_to_run=ls;-Dcommand_args=;-P;./run_gpu_test.cmake)]===]) -foreach(item IN LISTS add_test_match_strings) - string(FIND "${contents}" ${item} is_found) - if(is_found EQUAL -1) - message(FATAL_ERROR "Failed to generate an installed `add_test` for verify_") - endif() -endforeach() - +set(add_test_match_string [===[add_test([=[verify_]=] "cmake" -Dcommand_to_run=ls -Dcommand_args= -P=./run_gpu_test.cmake)]===]) +string(FIND "${contents}" ${add_test_match_string} is_found) +if(is_found EQUAL -1) + message(FATAL_ERROR "Failed to generate an installed `add_test` for verify_") +endif() set(properties_match_string [===[PROPERTIES RESOURCE_GROUPS 1,gpus:100]===]) string(FIND "${contents}" ${properties_match_string} is_found) if(is_found EQUAL -1) - message(FATAL_ERROR "Failed to generate an installed `GPU` requirements for verify_") + message(FATAL_ERROR "${contents}\nFailed to generate an installed `GPU` requirements for verify_") endif() +]==]) + +add_custom_target(install_testing_component ALL + COMMAND ${CMAKE_COMMAND} --install "${CMAKE_CURRENT_BINARY_DIR}" --component testing --prefix install/ + COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" + ) From 5aa00a9ce3147df5855b0ff1eece840619f0a133 Mon Sep 17 00:00:00 2001 From: Alexis Girault Date: Tue, 6 Jun 2023 15:01:19 -0400 Subject: [PATCH 08/24] Make NAMESPACE property truly optional in rapids_export (#358) This tackles two issues, broken down in two commits: 1. If no `NAMESPACE` is given (optional), the configured `config.cmake` file had invalid CMake code which would fail on import: ``` CMake Error at -config.cmake:90 (list): list sub-command TRANSFORM, action PREPEND expects 1 argument(s). ``` 2. Even with (1) fixed, `NAMESPACE` is not a true opt-in property (as per [guidelines](https://github.com/rapidsai/rapids-cmake/blob/branch-23.04/CONTRIBUTING.md#code-contributions)) even if optional, as it uses a default value when not set (`${project_name}::`) which can conflict with the property `EXPORT_NAME` set on targets, outside of `rapids_export`. The second commit of this MR changes the default behavior to set no additional namespace (see commit message for details). Authors: - Alexis Girault (https://github.com/agirault) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/rapids-cmake/pull/358 --- ci/test_cpp.sh | 2 +- rapids-cmake/export/detail/component.cmake | 24 ++++++--- rapids-cmake/export/export.cmake | 47 ++++++++++------ rapids-cmake/export/template/config.cmake.in | 4 +- testing/export/CMakeLists.txt | 1 + .../export-verify-no-namespace/CMakeLists.txt | 53 +++++++++++++++++++ 6 files changed, 106 insertions(+), 25 deletions(-) create mode 100644 testing/export/export-verify-no-namespace/CMakeLists.txt diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index df9f3af7b..2ad6f5c23 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -35,7 +35,7 @@ EXITCODE=0 trap "EXITCODE=1" ERR set +e -ctest --schedule-random --output-on-failure +ctest -j20 --schedule-random --output-on-failure rapids-logger "Test script exiting with value: $EXITCODE" exit ${EXITCODE} diff --git a/rapids-cmake/export/detail/component.cmake b/rapids-cmake/export/detail/component.cmake index 2e35ea8c6..c6a93c057 100644 --- a/rapids-cmake/export/detail/component.cmake +++ b/rapids-cmake/export/detail/component.cmake @@ -51,18 +51,28 @@ function(rapids_export_component type project_name component_name export_set uni file(MAKE_DIRECTORY "${deps_destination}") install(DIRECTORY "${deps_destination}" DESTINATION "${install_location}" COMPONENT ${component_name}) - install(EXPORT ${export_set} - FILE ${project_name}-${unique_name}-targets.cmake - NAMESPACE ${namespace} - DESTINATION "${install_location}" - COMPONENT ${component_name}) + if(namespace STREQUAL "") + install(EXPORT ${export_set} FILE ${project_name}-${unique_name}-targets.cmake + DESTINATION "${install_location}" COMPONENT ${component_name}) + else() + install(EXPORT ${export_set} + FILE ${project_name}-${unique_name}-targets.cmake + DESTINATION "${install_location}" + COMPONENT ${component_name} + NAMESPACE ${namespace}) + endif() else() set(install_location "${PROJECT_BINARY_DIR}") set(deps_destination "${install_location}/") - export(EXPORT ${export_set} NAMESPACE ${namespace} - FILE "${install_location}/${project_name}-${unique_name}-targets.cmake") + if(namespace STREQUAL "") + export(EXPORT ${export_set} + FILE "${install_location}/${project_name}-${unique_name}-targets.cmake") + else() + export(EXPORT ${export_set} NAMESPACE ${namespace} + FILE "${install_location}/${project_name}-${unique_name}-targets.cmake") + endif() endif() diff --git a/rapids-cmake/export/export.cmake b/rapids-cmake/export/export.cmake index 97f094b97..3ea73f4a8 100644 --- a/rapids-cmake/export/export.cmake +++ b/rapids-cmake/export/export.cmake @@ -114,11 +114,14 @@ calls to :cmake:command:`find_dependency`, or :cmake:command:`CPMFindPackage`. Optional value to specify what namespace all targets from the EXPORT_SET will be placed into. When provided must match the pattern of `::`. - If not provided all targets will be placed in the `::` - namespace + A recommended namespace could be `::`. + If not provided, no namespace is used. - Note: When exporting with `BUILD` type, only `GLOBAL_TARGETS` will - be placed in the namespace. + Note: + - When exporting with `BUILD` type, only `GLOBAL_TARGETS` will be placed + in the namespace. + - The namespace can be configured on a per-target basis instead using the + :cmake:prop_tgt:`EXPORT_NAME ` property. ``DOCUMENTATION`` Optional value of the variable that holds the documentation @@ -220,9 +223,10 @@ function(rapids_export type project_name) rapids_export_parse_version(${_RAPIDS_VERSION} rapids_orig rapids_project_version) endif() - set(_RAPIDS_PROJECT_NAMESPACE "${project_name}::") - if(DEFINED _RAPIDS_NAMESPACE) - set(_RAPIDS_PROJECT_NAMESPACE ${_RAPIDS_NAMESPACE}) + if(NOT DEFINED _RAPIDS_NAMESPACE) + message(VERBOSE + "rapids-cmake EXPORT: no NAMESPACE was provided. `${project_name}::` is recommended \ +if EXPORT_NAME isn't set for the export targets.") endif() if(_RAPIDS_COMPONENTS AND NOT _RAPIDS_COMPONENTS_EXPORT_SET) @@ -246,8 +250,12 @@ function(rapids_export type project_name) else() string(PREPEND nice_export_name "${comp}-") endif() + set(_RAPIDS_COMPONENT_NAMESPACE) + if(DEFINED _RAPIDS_NAMESPACE) + set(_RAPIDS_COMPONENT_NAMESPACE "${_RAPIDS_NAMESPACE}") + endif() rapids_export_component(${type} ${project_name} ${comp} ${comp_export_set} - ${nice_export_name} ${_RAPIDS_PROJECT_NAMESPACE}) + ${nice_export_name} "${_RAPIDS_COMPONENT_NAMESPACE}") endforeach() endif() @@ -284,11 +292,16 @@ function(rapids_export type project_name) COMPATIBILITY ${rapids_project_version_compat}) endif() - install(EXPORT ${_RAPIDS_EXPORT_SET} - FILE ${project_name}-targets.cmake - NAMESPACE ${_RAPIDS_PROJECT_NAMESPACE} - DESTINATION "${install_location}" - COMPONENT ${project_name}) + if(DEFINED _RAPIDS_NAMESPACE) + install(EXPORT ${_RAPIDS_EXPORT_SET} + FILE ${project_name}-targets.cmake + NAMESPACE ${_RAPIDS_NAMESPACE} + DESTINATION "${install_location}" + COMPONENT ${project_name}) + else() + install(EXPORT ${_RAPIDS_EXPORT_SET} FILE ${project_name}-targets.cmake + DESTINATION "${install_location}" COMPONENT ${project_name}) + endif() if(TARGET rapids_export_install_${_RAPIDS_EXPORT_SET}) include("${rapids-cmake-dir}/export/write_dependencies.cmake") @@ -319,8 +332,12 @@ function(rapids_export type project_name) COMPATIBILITY ${rapids_project_version_compat}) endif() - export(EXPORT ${_RAPIDS_EXPORT_SET} NAMESPACE ${_RAPIDS_PROJECT_NAMESPACE} - FILE "${install_location}/${project_name}-targets.cmake") + if(DEFINED _RAPIDS_NAMESPACE) + export(EXPORT ${_RAPIDS_EXPORT_SET} NAMESPACE "${_RAPIDS_NAMESPACE}" + FILE "${install_location}/${project_name}-targets.cmake") + else() + export(EXPORT ${_RAPIDS_EXPORT_SET} FILE "${install_location}/${project_name}-targets.cmake") + endif() if(TARGET rapids_export_build_${_RAPIDS_EXPORT_SET}) include("${rapids-cmake-dir}/export/write_dependencies.cmake") diff --git a/rapids-cmake/export/template/config.cmake.in b/rapids-cmake/export/template/config.cmake.in index a97fcda67..95f0b00fd 100644 --- a/rapids-cmake/export/template/config.cmake.in +++ b/rapids-cmake/export/template/config.cmake.in @@ -80,8 +80,8 @@ set(@project_name_uppercase@_VERSION @rapids_orig_version@) set(rapids_global_targets @_RAPIDS_GLOBAL_TARGETS@) set(rapids_namespaced_global_targets @_RAPIDS_GLOBAL_TARGETS@) -if(rapids_namespaced_global_targets) - list(TRANSFORM rapids_namespaced_global_targets PREPEND @_RAPIDS_PROJECT_NAMESPACE@ ) +if((NOT "@_RAPIDS_NAMESPACE@" STREQUAL "") AND rapids_namespaced_global_targets) + list(TRANSFORM rapids_namespaced_global_targets PREPEND "@_RAPIDS_NAMESPACE@") endif() foreach(target IN LISTS rapids_namespaced_global_targets) diff --git a/testing/export/CMakeLists.txt b/testing/export/CMakeLists.txt index 29da46113..78d48dc0c 100644 --- a/testing/export/CMakeLists.txt +++ b/testing/export/CMakeLists.txt @@ -28,6 +28,7 @@ add_cmake_build_test( export-verify-code-block ) add_cmake_build_test( export-verify-doc-string ) add_cmake_build_test( export-verify-global-targets ) add_cmake_build_test( export-verify-install-components ) +add_cmake_build_test( export-verify-no-namespace ) add_cmake_config_test( export-verify-bad-code-block-var.cmake SHOULD_FAIL "FINAL_CODE_BLOCK variable `var_doesn't_exist` doesn't exist") add_cmake_config_test( export-verify-missing-components.cmake SHOULD_FAIL "is missing COMPONENTS as COMPONENTS_EXPORT_SET was provided") diff --git a/testing/export/export-verify-no-namespace/CMakeLists.txt b/testing/export/export-verify-no-namespace/CMakeLists.txt new file mode 100644 index 000000000..6984ac0de --- /dev/null +++ b/testing/export/export-verify-no-namespace/CMakeLists.txt @@ -0,0 +1,53 @@ +#============================================================================= +# 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}/export/export.cmake) + +cmake_minimum_required(VERSION 3.23.1) +project(FakEProJecT LANGUAGES CXX VERSION 3.1.4) + +add_library(fakeLib1 INTERFACE) +add_library(fakeLib2 INTERFACE) +set_target_properties(fakeLib2 PROPERTIES EXPORT_NAME namespacefor2only) +install(TARGETS fakeLib1 fakeLib2 EXPORT fake_set) + +rapids_export(BUILD FakEProJecT + EXPORT_SET fake_set + LANGUAGES CXX +) + +# Add a custom command that generates a second project +# that verifies our target was exported with the correct +# namespace +file(WRITE "${CMAKE_BINARY_DIR}/verify/CMakeLists.txt" [=[ +cmake_minimum_required(VERSION 3.23.1) +project(verify_build_targets LANGUAGES CXX) +message(STATUS "${CMAKE_CURRENT_LIST_DIR}/../fakeproject-targets.cmake") +if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../fakeproject-targets.cmake") + message(FATAL_ERROR "rapids_export failed to generate correct config file name") +endif() +include("${CMAKE_CURRENT_LIST_DIR}/../fakeproject-targets.cmake") +if(NOT TARGET fakeLib1) + message(FATAL_ERROR "rapids_export failed to generate correct namespace targets") +endif() +if(NOT TARGET namespacefor2only) + message(FATAL_ERROR "rapids_export failed to generate correct namespace targets") +endif() + ]=]) + +add_custom_target(verify_target_file ALL + COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/verify/build" + COMMAND ${CMAKE_COMMAND} -S="${CMAKE_BINARY_DIR}/verify" -B="${CMAKE_BINARY_DIR}/verify/build" + ) From 5d3482001db6efa0f15d1813df5a53267a7d3e73 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 6 Jun 2023 15:08:51 -0400 Subject: [PATCH 09/24] test_install_relocatable correct run_gpu_test.cmake location (#420) When tests are added in a subdirectory of a project the compuation for where the `run_gpu_test.cmake` would be in the build directory was wrong. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rapids-cmake/pull/420 --- rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake | 2 +- rapids-cmake/test/install_relocatable.cmake | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake b/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake index 54fd2ddff..300c07f26 100644 --- a/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake +++ b/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake @@ -226,7 +226,7 @@ determine_install_location_of_all_targets() # Setup the install location of `run_gpu_test` set_property(GLOBAL PROPERTY run_gpu_test.cmake_install ".") set_property(GLOBAL PROPERTY run_gpu_test.cmake_build - "${_RAPIDS_BUILD_DIR}/rapids-cmake/./run_gpu_test.cmake") + "${_RAPIDS_PROJECT_DIR}/rapids-cmake/./run_gpu_test.cmake") include(${CMAKE_CURRENT_LIST_DIR}/default_names.cmake) set(test_file_content diff --git a/rapids-cmake/test/install_relocatable.cmake b/rapids-cmake/test/install_relocatable.cmake index c0f0b4179..c1740e657 100644 --- a/rapids-cmake/test/install_relocatable.cmake +++ b/rapids-cmake/test/install_relocatable.cmake @@ -80,6 +80,7 @@ function(rapids_test_install_relocatable) set(_RAPIDS_TEST_DESTINATION \"${_RAPIDS_TEST_DESTINATION}\") set(_RAPIDS_INSTALL_PREFIX \"${from_install_prefix}\") set(_RAPIDS_BUILD_DIR \"${CMAKE_CURRENT_BINARY_DIR}\") + set(_RAPIDS_PROJECT_DIR \"${PROJECT_BINARY_DIR}\") set(_RAPIDS_INSTALL_COMPONENT_SET \"${_RAPIDS_TEST_INSTALL_COMPONENT_SET}\") set(_RAPIDS_TARGETS_INSTALLED \"${targets_to_install}\") set(_RAPIDS_TESTS_TO_RUN \"${tests_to_run}\") From aba6b1f879f82ae64e45125d4ec904e21fd828cb Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Wed, 7 Jun 2023 15:42:56 -0500 Subject: [PATCH 10/24] use rapids-upload-docs script (#419) This PR updates the `build_docs.sh` script to use the new consolidatory `rapids-upload-script` [shared script](https://github.com/rapidsai/gha-tools/pull/56). The shared script enables docs uploads to applicable S3 buckets for branch. nightly and PR builds. Authors: - Jake Awe (https://github.com/AyodeAwe) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rapids-cmake/pull/419 --- ci/build_docs.sh | 13 ++++++------- ci/release/update-version.sh | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index a4c380b6e..afb8f4db1 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -16,17 +16,16 @@ conda activate docs rapids-print-env -VERSION_NUMBER="23.08" +export RAPIDS_VERSION_NUMBER="23.08" +export RAPIDS_DOCS_DIR="$(mktemp -d)" rapids-logger "Build Sphinx docs" pushd docs sphinx-build -b dirhtml . _html -W sphinx-build -b text . _text -W +mkdir -p "${RAPIDS_DOCS_DIR}/rapids-cmake/"{html,txt} +mv _html/* "${RAPIDS_DOCS_DIR}/rapids-cmake/html" +mv _text/* "${RAPIDS_DOCS_DIR}/rapids-cmake/txt" popd - -if [[ ${RAPIDS_BUILD_TYPE} != "pull-request" ]]; then - rapids-logger "Upload Docs to S3" - aws s3 sync --no-progress --delete docs/_html "s3://rapidsai-docs/rapids-cmake/${VERSION_NUMBER}/html" - aws s3 sync --no-progress --delete docs/_text "s3://rapidsai-docs/rapids-cmake/${VERSION_NUMBER}/txt" -fi +rapids-upload-docs diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 90b73a892..a2748cf28 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -41,4 +41,4 @@ sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cma for FILE in .github/workflows/*.yaml; do sed_runner "/shared-action-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}" done -sed_runner "s/VERSION_NUMBER=\".*/VERSION_NUMBER=\"${NEXT_SHORT_TAG}\"/g" ci/build_docs.sh +sed_runner "s/RAPIDS_VERSION_NUMBER=\".*/RAPIDS_VERSION_NUMBER=\"${NEXT_SHORT_TAG}\"/g" ci/build_docs.sh From bf471a7db72cc99790ffa6ebba7b422b66cf9a63 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 8 Jun 2023 10:44:28 -0700 Subject: [PATCH 11/24] Fix google benchmark name and update version (#425) The google benchmark package name was incorrect, making it impossible to find benchmark if it was previously installed. However, the currently pinned version of benchmark has a broken CMake config on conda-forge (it claims it is version 0.0.0) so it cannot be found even with the name fix. This is as good a time as any to go ahead and update to the latest version. Resolves #424 Authors: - Vyas Ramasubramani (https://github.com/vyasr) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rapids-cmake/pull/425 --- rapids-cmake/cpm/gbench.cmake | 16 ++++++++-------- rapids-cmake/cpm/versions.json | 10 +++++----- testing/cpm/cpm_gbench-export.cmake | 10 +++++----- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/rapids-cmake/cpm/gbench.cmake b/rapids-cmake/cpm/gbench.cmake index f7864f434..d21dc6306 100644 --- a/rapids-cmake/cpm/gbench.cmake +++ b/rapids-cmake/cpm/gbench.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2022, 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. @@ -21,10 +21,10 @@ rapids_cpm_gbench .. versionadded:: v22.12.00 -Allow projects to find or build `Google Benchmark` via `CPM` with built-in +Allow projects to find or build Google Benchmark via `CPM` with built-in tracking of these dependencies for correct export support. -Uses the version of GBench :ref:`specified in the version file ` for consistency +Uses the version of Google benchmark :ref:`specified in the version file ` for consistency across all RAPIDS projects. .. code-block:: cmake @@ -33,7 +33,7 @@ across all RAPIDS projects. [INSTALL_EXPORT_SET ] [ ...]) -.. |PKG_NAME| replace:: GBench +.. |PKG_NAME| replace:: benchmark .. include:: common_package_args.txt Result Targets @@ -50,16 +50,16 @@ function(rapids_cpm_gbench) endif() include("${rapids-cmake-dir}/cpm/detail/package_details.cmake") - rapids_cpm_package_details(GBench version repository tag shallow exclude) + rapids_cpm_package_details(benchmark version repository tag shallow exclude) include("${rapids-cmake-dir}/cpm/detail/generate_patch_command.cmake") - rapids_cpm_generate_patch_command(GBench ${version} patch_command) + rapids_cpm_generate_patch_command(benchmark ${version} patch_command) include("${rapids-cmake-dir}/cmake/install_lib_dir.cmake") rapids_cmake_install_lib_dir(lib_dir) include("${rapids-cmake-dir}/cpm/find.cmake") - rapids_cpm_find(GBench ${version} ${ARGN} + rapids_cpm_find(benchmark ${version} ${ARGN} GLOBAL_TARGETS benchmark::benchmark benchmark::benchmark_main CPM_ARGS GIT_REPOSITORY ${repository} @@ -72,7 +72,7 @@ function(rapids_cpm_gbench) "CMAKE_INSTALL_LIBDIR ${lib_dir}") include("${rapids-cmake-dir}/cpm/detail/display_patch_status.cmake") - rapids_cpm_display_patch_status(GBench) + rapids_cpm_display_patch_status(benchmark) if(NOT TARGET benchmark::benchmark AND TARGET benchmark) add_library(benchmark::benchmark ALIAS benchmark) diff --git a/rapids-cmake/cpm/versions.json b/rapids-cmake/cpm/versions.json index 544b81308..465ef7907 100644 --- a/rapids-cmake/cpm/versions.json +++ b/rapids-cmake/cpm/versions.json @@ -1,6 +1,11 @@ { "packages" : { + "benchmark" : { + "version" : "1.8.0", + "git_url" : "https://github.com/google/benchmark.git", + "git_tag" : "v${version}" + }, "cuco" : { "version" : "0.0.1", "git_shallow" : false, @@ -12,11 +17,6 @@ "git_url" : "https://github.com/fmtlib/fmt.git", "git_tag" : "${version}" }, - "GBench" : { - "version" : "1.5.3", - "git_url" : "https://github.com/google/benchmark.git", - "git_tag" : "v1.5.3" - }, "GTest" : { "version" : "1.13.0", "git_url" : "https://github.com/google/googletest.git", diff --git a/testing/cpm/cpm_gbench-export.cmake b/testing/cpm/cpm_gbench-export.cmake index 6567c1f54..ae0a669c9 100644 --- a/testing/cpm/cpm_gbench-export.cmake +++ b/testing/cpm/cpm_gbench-export.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2022, 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. @@ -22,11 +22,11 @@ rapids_cpm_gbench(BUILD_EXPORT_SET bench) rapids_cpm_gbench(BUILD_EXPORT_SET bench2) get_target_property(packages rapids_export_build_bench PACKAGE_NAMES) -if(NOT GBench IN_LIST packages) - message(FATAL_ERROR "rapids_cpm_gbench failed to record gbench needs to be exported") +if(NOT benchmark IN_LIST packages) + message(FATAL_ERROR "rapids_cpm_gbench failed to record benchmark needs to be exported") endif() get_target_property(packages rapids_export_build_bench2 PACKAGE_NAMES) -if(NOT GBench IN_LIST packages) - message(FATAL_ERROR "rapids_cpm_gbench failed to record gbench needs to be exported") +if(NOT benchmark IN_LIST packages) + message(FATAL_ERROR "rapids_cpm_gbench failed to record benchmark needs to be exported") endif() From 707f9ad5ae29c443cf5e7b542e46dbe39d4434ba Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 8 Jun 2023 13:45:12 -0400 Subject: [PATCH 12/24] Correct install_relocatable issues found by libcudf (#423) https://github.com/rapidsai/cudf/pull/13513 found 2 issues in the `install_relocatable` logic that caused LD_PRELOAD setup to fail. This PR corrects those two issues: 1. The `ENVIRONMENT` value always needs to be quoted to properly support multiple variables to be set 2. We need to scan for all `cmake_install.cmake` starting from the root build directory Authors: - Robert Maynard (https://github.com/robertmaynard) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rapids-cmake/pull/423 --- .../generate_installed_CTestTestfile.cmake | 4 +- rapids-cmake/test/install_relocatable.cmake | 6 +- testing/test/CMakeLists.txt | 1 + .../CMakeLists.txt | 25 ++++++++ .../tests/CMakeLists.txt | 61 +++++++++++++++++++ .../test/install_relocatable-complex/usage.cu | 0 6 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 testing/test/install_relocatable-complex/CMakeLists.txt create mode 100644 testing/test/install_relocatable-complex/tests/CMakeLists.txt create mode 100644 testing/test/install_relocatable-complex/usage.cu diff --git a/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake b/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake index 300c07f26..54a9a522a 100644 --- a/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake +++ b/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake @@ -157,7 +157,7 @@ function(set_tests_properties name) set(prop_value "${_RAPIDS_TEST_${prop}}") find_and_convert_paths_from_var_list(prop_value) string(APPEND test_prop_content - "set_tests_properties([=[${name}]=] PROPERTIES ${prop} ${prop_value})\n") + "set_tests_properties([=[${name}]=] PROPERTIES ${prop} \"${prop_value}\")\n") endif() endforeach() @@ -210,7 +210,7 @@ endfunction() # # Find all the cmake_install.cmake files in the install directory and parse them for install rules function(determine_install_location_of_all_targets) - file(GLOB_RECURSE install_rule_files "${_RAPIDS_BUILD_DIR}/cmake_install.cmake") + file(GLOB_RECURSE install_rule_files "${_RAPIDS_PROJECT_DIR}/cmake_install.cmake") foreach(file IN LISTS install_rule_files) file(STRINGS "${file}" contents REGEX "INSTALL DESTINATION") foreach(line IN LISTS contents) diff --git a/rapids-cmake/test/install_relocatable.cmake b/rapids-cmake/test/install_relocatable.cmake index c1740e657..8f1333dc9 100644 --- a/rapids-cmake/test/install_relocatable.cmake +++ b/rapids-cmake/test/install_relocatable.cmake @@ -48,6 +48,10 @@ the install directory. State that these install rules should be part of the default install set. By default tests are not part of the default install set. +.. note:: + rapids_test_install_relocatable behavior is undefined when used with + multi-config generators such as "Visual Studio" and "Ninja Multi-Config" + #]=======================================================================] function(rapids_test_install_relocatable) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.install_relocatable") @@ -80,7 +84,7 @@ function(rapids_test_install_relocatable) set(_RAPIDS_TEST_DESTINATION \"${_RAPIDS_TEST_DESTINATION}\") set(_RAPIDS_INSTALL_PREFIX \"${from_install_prefix}\") set(_RAPIDS_BUILD_DIR \"${CMAKE_CURRENT_BINARY_DIR}\") - set(_RAPIDS_PROJECT_DIR \"${PROJECT_BINARY_DIR}\") + set(_RAPIDS_PROJECT_DIR \"${CMAKE_BINARY_DIR}\") set(_RAPIDS_INSTALL_COMPONENT_SET \"${_RAPIDS_TEST_INSTALL_COMPONENT_SET}\") set(_RAPIDS_TARGETS_INSTALLED \"${targets_to_install}\") set(_RAPIDS_TESTS_TO_RUN \"${tests_to_run}\") diff --git a/testing/test/CMakeLists.txt b/testing/test/CMakeLists.txt index 7eee56e58..9953c36e5 100644 --- a/testing/test/CMakeLists.txt +++ b/testing/test/CMakeLists.txt @@ -43,6 +43,7 @@ add_cmake_build_test(install_relocatable-include-in-all.cmake) add_cmake_build_test(install_relocatable-labels.cmake) add_cmake_build_test(install_relocatable-no-tests.cmake) add_cmake_build_test(install_relocatable-simple.cmake) +add_cmake_build_test(install_relocatable-complex) add_cmake_config_test(install_relocatable-wrong-component.cmake SHOULD_FAIL "${wrong_component_message}") add_cmake_ctest_test(add-impossible-allocation SHOULD_FAIL "Insufficient resources for test") diff --git a/testing/test/install_relocatable-complex/CMakeLists.txt b/testing/test/install_relocatable-complex/CMakeLists.txt new file mode 100644 index 000000000..339167d3c --- /dev/null +++ b/testing/test/install_relocatable-complex/CMakeLists.txt @@ -0,0 +1,25 @@ +#============================================================================= +# 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. +#============================================================================= +cmake_minimum_required(VERSION 3.20) +set(CMAKE_CONFIGURATION_TYPES Debug) +project(rapids-test-project LANGUAGES CUDA) + +include(${rapids-cmake-dir}/rapids-test.cmake) + +add_library(preload SHARED usage.cu) +add_subdirectory(tests) + +install(TARGETS preload DESTINATION lib) diff --git a/testing/test/install_relocatable-complex/tests/CMakeLists.txt b/testing/test/install_relocatable-complex/tests/CMakeLists.txt new file mode 100644 index 000000000..8ed76f13e --- /dev/null +++ b/testing/test/install_relocatable-complex/tests/CMakeLists.txt @@ -0,0 +1,61 @@ +#============================================================================= +# 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}/rapids-test.cmake) + +enable_testing() +rapids_test_init() + +rapids_test_add(NAME verify_ COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing) +set_tests_properties( + verify_ + PROPERTIES + ENVIRONMENT + "STREAM_MODE=new_mode;LD_PRELOAD=$" + ) + +rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing + DESTINATION bin/testing + INCLUDE_IN_ALL) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" + "set(installed_test_file \"${CMAKE_CURRENT_BINARY_DIR}/install/bin/testing/CTestTestfile.cmake\")") +file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" +[==[ + +file(READ "${installed_test_file}" contents) +set(execute_process_match_string [===[execute_process(COMMAND ./generate_ctest_json OUTPUT_FILE "${CTEST_RESOURCE_SPEC_FILE}")]===]) +string(FIND "${contents}" ${execute_process_match_string} is_found) +if(is_found EQUAL -1) + message(FATAL_ERROR "Failed to generate a `execute_process` with escaped CTEST_RESOURCE_SPEC_FILE") +endif() + +set(properties_match_strings [===[PROPERTIES ENVIRONMENT "STREAM_MODE]===] + [===[LD_PRELOAD=${CMAKE_INSTALL_PREFIX}/lib/libpreload]===]) +foreach(to_match IN LISTS properties_match_strings) + string(FIND "${contents}" ${to_match} is_found) + if(is_found EQUAL -1) + message(FATAL_ERROR "${contents}\nFailed to generate a proper set of test properties") + endif() +endforeach() +]==]) + +add_custom_target(install_testing_component ALL + COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --prefix install/ --config Debug + COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" + ) + +add_dependencies(install_testing_component preload) diff --git a/testing/test/install_relocatable-complex/usage.cu b/testing/test/install_relocatable-complex/usage.cu new file mode 100644 index 000000000..e69de29bb From 207d1263fbeafd3b695cc5784988a7e71bd96994 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 13 Jun 2023 14:37:51 -0400 Subject: [PATCH 13/24] support_conda_env support host and build CTK 12 locations (#428) For cuda 12+ the conda layout has CTK components in both host and build. Update the CMAKE_PREFIX search locations and rpath-link entries for this new layout. Authors: - Robert Maynard (https://github.com/robertmaynard) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rapids-cmake/pull/428 --- rapids-cmake/cmake/support_conda_env.cmake | 39 +++++++- testing/cmake/CMakeLists.txt | 4 +- testing/cmake/conda_env-cross-build-arm.cmake | 98 ++++++++++++++++++ testing/cmake/conda_env-cross-build-x86.cmake | 99 +++++++++++++++++++ 4 files changed, 235 insertions(+), 5 deletions(-) create mode 100644 testing/cmake/conda_env-cross-build-arm.cmake create mode 100644 testing/cmake/conda_env-cross-build-x86.cmake diff --git a/rapids-cmake/cmake/support_conda_env.cmake b/rapids-cmake/cmake/support_conda_env.cmake index af995e904..e5e18614e 100644 --- a/rapids-cmake/cmake/support_conda_env.cmake +++ b/rapids-cmake/cmake/support_conda_env.cmake @@ -31,12 +31,20 @@ Creates a global interface target called `target_name` that holds the CONDA include and link directories, when executed. Also offers the ability to modify :cmake:variable:`CMAKE_PREFIX_PATH ` to -include the paths in environment variables `PREFIX`, `BUILD_PREFIX`, -and `CONDA_PREFIX` based on the current CONDA environment. +include the following paths based on the current conda environment: + + - `PREFIX` + - `BUILD_PREFIX` + - `CONDA_PREFIX` + + .. versionadded:: v23.08.00 + + - `PREFIX`/targets// ``MODIFY_PREFIX_PATH`` - When in a conda build environment the contents of `$ENV{PREFIX}` and `$ENV{BUILD_PREFIX}` - will be inserted to the front of :cmake:variable:`CMAKE_PREFIX_PATH `. + When in a conda build environment the contents of `$ENV{PREFIX}`, + `$ENV{PREFIX}`/targets//`, and `$ENV{BUILD_PREFIX}` will be inserted to the + front of :cmake:variable:`CMAKE_PREFIX_PATH `. When in a conda environment the contents of `$ENV{CONDA_PREFIX}` will be inserted to the front of :cmake:variable:`CMAKE_PREFIX_PATH `. @@ -51,6 +59,7 @@ Result Targets `target_name` target will be created only if called from a conda environment. #]=======================================================================] +# cmake-lint: disable=R0912,R0915 function(rapids_cmake_support_conda_env target) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cmake.support_conda_env") @@ -75,12 +84,31 @@ function(rapids_cmake_support_conda_env target) set(prefix_paths) if(in_conda_build) + # For conda-build we add the host conda environment prefix to the cmake search paths so that + # raw `find_file` or `find_library` calls will find CUDA components in the host environment + set(target_platform $ENV{cross_target_platform}) # when target != cross_target + if(NOT target_platform) + set(target_platform $ENV{target_platform}) + endif() + if("${target_platform}" STREQUAL "linux-64") + set(targetsDir "targets/x86_64-linux") + elseif("${target_platform}" STREQUAL "linux-ppc64le") + set(targetsDir "targets/ppc64le-linux") + elseif("${target_platform}" STREQUAL "linux-aarch64") + set(targetsDir "targets/sbsa-linux") + endif() + target_include_directories(${target} INTERFACE "$ENV{PREFIX}/include" "$ENV{BUILD_PREFIX}/include") target_link_directories(${target} INTERFACE "$ENV{PREFIX}/lib" "$ENV{BUILD_PREFIX}/lib") if(DEFINED CMAKE_SHARED_LIBRARY_RPATH_LINK_CUDA_FLAG OR DEFINED CMAKE_SHARED_LIBRARY_RPATH_LINK_CXX_FLAG) + if(DEFINED targetsDir) + target_link_options(${target} INTERFACE + "$" + ) + endif() target_link_options(${target} INTERFACE "$") target_link_options(${target} INTERFACE @@ -89,6 +117,9 @@ function(rapids_cmake_support_conda_env target) if(modify_prefix_path) list(PREPEND CMAKE_PREFIX_PATH "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}") + if(DEFINED targetsDir) + list(PREPEND CMAKE_PREFIX_PATH "$ENV{PREFIX}/${targetsDir}") + endif() set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" PARENT_SCOPE) message(VERBOSE "Conda build detected, CMAKE_PREFIX_PATH set to: ${CMAKE_PREFIX_PATH}") endif() diff --git a/testing/cmake/CMakeLists.txt b/testing/cmake/CMakeLists.txt index 463cd2168..a75944e6f 100644 --- a/testing/cmake/CMakeLists.txt +++ b/testing/cmake/CMakeLists.txt @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-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. @@ -21,6 +21,8 @@ add_cmake_config_test( build_type-multiple.cmake ) add_cmake_config_test( build_type-user-specified.cmake) add_cmake_config_test( conda_env-build.cmake ) +add_cmake_config_test( conda_env-cross-build-arm.cmake ) +add_cmake_config_test( conda_env-cross-build-x86.cmake ) add_cmake_config_test( conda_env-invalid.cmake ) add_cmake_config_test( conda_env-prefix.cmake ) diff --git a/testing/cmake/conda_env-cross-build-arm.cmake b/testing/cmake/conda_env-cross-build-arm.cmake new file mode 100644 index 000000000..86a8ffc8d --- /dev/null +++ b/testing/cmake/conda_env-cross-build-arm.cmake @@ -0,0 +1,98 @@ +#============================================================================= +# 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}/cmake/support_conda_env.cmake) + + +set(ENV{CONDA_BUILD} "1") +set(ENV{BUILD_PREFIX} "/usr/local/build_prefix") +set(ENV{cross_target_platform} "linux-aarch64") +set(ENV{PREFIX} "/opt/local/prefix") +set(ENV{CONDA_PREFIX} "/opt/conda/prefix") + +rapids_cmake_support_conda_env(conda_env) +if(NOT TARGET conda_env) + message(FATAL_ERROR "Expected target conda_env to exist") +endif() + +get_target_property(include_dirs conda_env INTERFACE_INCLUDE_DIRECTORIES) +if( NOT "$ENV{BUILD_PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Expected env{BUILD_PREFIX} to be in the include dirs of `conda_env`") +endif() +if( NOT "$ENV{PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Expected env{PREFIX} to be in the include dirs of `conda_env`") +endif() +if("$ENV{CONDA_PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Not expected for env{CONDA_PREFIX} to be in the include dirs of `conda_env`") +endif() + +get_target_property(link_dirs conda_env INTERFACE_LINK_DIRECTORIES) +if( NOT "$ENV{BUILD_PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Expected env{BUILD_PREFIX} to be in the link dirs of `conda_env`") +endif() +if( NOT "$ENV{PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Expected env{PREFIX} to be in the link dirs of `conda_env`") +endif() +if("$ENV{CONDA_PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Not expected for env{CONDA_PREFIX} to be in the link dirs of `conda_env`") +endif() + +get_target_property(link_options conda_env INTERFACE_LINK_OPTIONS) +message(STATUS "link_options: ${link_options}") +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{BUILD_PREFIX} to be in the link options of `conda_env`") +endif() +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{PREFIX} to be in the link options of `conda_env`") +endif() +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{PREFIX}/targets/sbsa-linux/ to be in the link options of `conda_env`") +endif() +if("$" IN_LIST link_options) + message(FATAL_ERROR "Not expected for rpath-link=env{CONDA_PREFIX} to be in the link options of `conda_env`") +endif() + +# No effect as the target already exists +set(before_call_value "${CMAKE_PREFIX_PATH}" ) +rapids_cmake_support_conda_env(conda_env MODIFY_PREFIX_PATH) +if(NOT ("${before_call_value}" STREQUAL "${CMAKE_PREFIX_PATH}") ) + message(FATAL_ERROR "Expected rapids_cmake_support_conda_env not to change CMAKE_PREFIX_PATH") +endif() + +# New target being used, so this should modify CMAKE_PREFIX_PATH +set(CMAKE_PREFIX_PATH "placeholder" ) +rapids_cmake_support_conda_env(conda_env_modify MODIFY_PREFIX_PATH) +if(NOT TARGET conda_env_modify) + message(FATAL_ERROR "Expected target conda_env_modify to exist") +endif() + +list(LENGTH CMAKE_PREFIX_PATH len) +if( len GREATER 4) + message(FATAL_ERROR "CMAKE_PREFIX_PATH length is wrong after MODIFY_PREFIX_PATH") +endif() + +list(GET CMAKE_PREFIX_PATH 0 first_value) +list(GET CMAKE_PREFIX_PATH 1 second_value) +list(GET CMAKE_PREFIX_PATH 2 third_value) +list(GET CMAKE_PREFIX_PATH 3 fourth_value) +set(correct_list "$ENV{PREFIX}/targets/sbsa-linux" "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}" "placeholder") +set(actual_list "${first_value}" "${second_value}" "${third_value}" "${fourth_value}") +foreach(correct actual IN ZIP_LISTS correct_list actual_list) + if(NOT correct STREQUAL actual) + message(STATUS "correct: ${correct}") + message(STATUS "actual: ${actual}") + message(FATAL_ERROR "MODIFY_PREFIX_PATH failed") + endif() +endforeach() diff --git a/testing/cmake/conda_env-cross-build-x86.cmake b/testing/cmake/conda_env-cross-build-x86.cmake new file mode 100644 index 000000000..a8501f3c2 --- /dev/null +++ b/testing/cmake/conda_env-cross-build-x86.cmake @@ -0,0 +1,99 @@ +#============================================================================= +# 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}/cmake/support_conda_env.cmake) + + +set(ENV{CONDA_BUILD} "1") +set(ENV{BUILD_PREFIX} "/usr/local/build_prefix") +set(ENV{target_platform} "linux-64") +set(ENV{PREFIX} "/opt/local/prefix") +set(ENV{CONDA_PREFIX} "/opt/conda/prefix") + +rapids_cmake_support_conda_env(conda_env) +if(NOT TARGET conda_env) + message(FATAL_ERROR "Expected target conda_env to exist") +endif() + +get_target_property(include_dirs conda_env INTERFACE_INCLUDE_DIRECTORIES) +if( NOT "$ENV{BUILD_PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Expected env{BUILD_PREFIX} to be in the include dirs of `conda_env`") +endif() +if( NOT "$ENV{PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Expected env{PREFIX} to be in the include dirs of `conda_env`") +endif() +if("$ENV{CONDA_PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Not expected for env{CONDA_PREFIX} to be in the include dirs of `conda_env`") +endif() + +get_target_property(link_dirs conda_env INTERFACE_LINK_DIRECTORIES) +if( NOT "$ENV{BUILD_PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Expected env{BUILD_PREFIX} to be in the link dirs of `conda_env`") +endif() +if( NOT "$ENV{PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Expected env{PREFIX} to be in the link dirs of `conda_env`") +endif() +if("$ENV{CONDA_PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Not expected for env{CONDA_PREFIX} to be in the link dirs of `conda_env`") +endif() + +get_target_property(link_options conda_env INTERFACE_LINK_OPTIONS) +message(STATUS "link_options: ${link_options}") +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{BUILD_PREFIX} to be in the link options of `conda_env`") +endif() +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{PREFIX} to be in the link options of `conda_env`") +endif() +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{PREFIX}/targets/x86_64-linux/ to be in the link options of `conda_env`") +endif() +if("$" IN_LIST link_options) + message(FATAL_ERROR "Not expected for rpath-link=env{CONDA_PREFIX} to be in the link options of `conda_env`") +endif() + +# No effect as the target already exists +set(before_call_value "${CMAKE_PREFIX_PATH}" ) +rapids_cmake_support_conda_env(conda_env MODIFY_PREFIX_PATH) +if(NOT ("${before_call_value}" STREQUAL "${CMAKE_PREFIX_PATH}") ) + message(FATAL_ERROR "Expected rapids_cmake_support_conda_env not to change CMAKE_PREFIX_PATH") +endif() + +# New target being used, so this should modify CMAKE_PREFIX_PATH +set(CMAKE_PREFIX_PATH "placeholder" ) +rapids_cmake_support_conda_env(conda_env_modify MODIFY_PREFIX_PATH) +if(NOT TARGET conda_env_modify) + message(FATAL_ERROR "Expected target conda_env_modify to exist") +endif() + +list(LENGTH CMAKE_PREFIX_PATH len) +if( len GREATER 4) + message(FATAL_ERROR "CMAKE_PREFIX_PATH length is wrong after MODIFY_PREFIX_PATH") +endif() + +list(GET CMAKE_PREFIX_PATH 0 first_value) +list(GET CMAKE_PREFIX_PATH 1 second_value) +list(GET CMAKE_PREFIX_PATH 2 third_value) +list(GET CMAKE_PREFIX_PATH 3 fourth_value) +set(correct_list "$ENV{PREFIX}/targets/x86_64-linux" "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}" "placeholder") +set(actual_list "${first_value}" "${second_value}" "${third_value}" "${fourth_value}") + +foreach(correct actual IN ZIP_LISTS correct_list actual_list) + if(NOT correct STREQUAL actual) + message(STATUS "correct: ${correct}") + message(STATUS "actual: ${actual}") + message(FATAL_ERROR "MODIFY_PREFIX_PATH failed") + endif() +endforeach() From 213d124602f3853cfacd2b87bc64aad4ca056ec5 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 23 Jun 2023 08:09:05 -0400 Subject: [PATCH 14/24] Bug/proprietary binary obeys `always_download` (#430) Update rapids_cpm_nvcomp to check for a local version before downloading the properitary version Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rapids-cmake/pull/430 --- docs/packages/rapids_cpm_versions.rst | 11 +++++-- rapids-cmake/cpm/detail/package_details.cmake | 8 ++++- rapids-cmake/cpm/nvcomp.cmake | 19 ++++++++--- rapids-cmake/find/package.cmake | 33 ++++++++++--------- 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/docs/packages/rapids_cpm_versions.rst b/docs/packages/rapids_cpm_versions.rst index 5f29221f1..3fdb1fed2 100644 --- a/docs/packages/rapids_cpm_versions.rst +++ b/docs/packages/rapids_cpm_versions.rst @@ -106,8 +106,15 @@ as needed. ``proprietary_binary`` - An optional dictionary of cpu architecture and operating system keys to url values that represents a download for a pre-built proprietary version of the library. - If a matching key exists the binary will be used instead of the specified git url and tag. + An optional dictionary of cpu architecture and operating system keys to url values that represents a download for a pre-built proprietary version of the library. This creates a new entry in the search + logic for a project: + + - Search for a local version matching the `version` key + - disabled by `always_download` + - Download proprietary version if a valid OS + CPU Arch exists + - disabled by `USE_PROPRIETARY_BLOB` being off + - Fallback to using git url and tag + To determine the correct key, CMake will query for a key that matches the lower case value of `-` where `arch` maps to :cmake:variable:`CMAKE_SYSTEM_PROCESSOR ` and `os` maps to :cmake:variable:`CMAKE_SYSTEM_NAME `. diff --git a/rapids-cmake/cpm/detail/package_details.cmake b/rapids-cmake/cpm/detail/package_details.cmake index 6cb150398..8d3acc995 100644 --- a/rapids-cmake/cpm/detail/package_details.cmake +++ b/rapids-cmake/cpm/detail/package_details.cmake @@ -29,8 +29,13 @@ rapids_cpm_package_details ) +Result Variables +^^^^^^^^^^^^^^^^ + :cmake:variable:`rapids_cmake_always_download` will contain the value of the `always_download` entry if it exists. + :cmake:variable:`CPM_DOWNLOAD_ALL` will contain the value of the `always_download` entry if it exists. + #]=======================================================================] -# cmake-lint: disable=R0913 +# cmake-lint: disable=R0913,R0915 function(rapids_cpm_package_details package_name version_var url_var tag_var shallow_var exclude_from_all_var) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.rapids_cpm_package_details") @@ -99,6 +104,7 @@ function(rapids_cpm_package_details package_name version_var url_var tag_var sha set(${shallow_var} ${git_shallow} PARENT_SCOPE) set(${exclude_from_all_var} ${exclude_from_all} PARENT_SCOPE) if(DEFINED always_download) + set(rapids_cmake_always_download ${always_download} PARENT_SCOPE) set(CPM_DOWNLOAD_ALL ${always_download} PARENT_SCOPE) endif() diff --git a/rapids-cmake/cpm/nvcomp.cmake b/rapids-cmake/cpm/nvcomp.cmake index 605942509..2021aec35 100644 --- a/rapids-cmake/cpm/nvcomp.cmake +++ b/rapids-cmake/cpm/nvcomp.cmake @@ -63,7 +63,7 @@ Result Variables :cmake:variable:`nvcomp_proprietary_binary` is set to ON if the proprietary binary is being used #]=======================================================================] -# cmake-lint: disable=R0915 +# cmake-lint: disable=R0915,R0912 function(rapids_cpm_nvcomp) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.nvcomp") @@ -74,11 +74,12 @@ function(rapids_cpm_nvcomp) # Fix up _RAPIDS_UNPARSED_ARGUMENTS to have EXPORT_SETS as this is need for rapids_cpm_find if(_RAPIDS_INSTALL_EXPORT_SET) - list(APPEND _RAPIDS_UNPARSED_ARGUMENTS INSTALL_EXPORT_SET ${_RAPIDS_INSTALL_EXPORT_SET}) + list(APPEND _RAPIDS_EXPORT_ARGUMENTS INSTALL_EXPORT_SET ${_RAPIDS_INSTALL_EXPORT_SET}) endif() if(_RAPIDS_BUILD_EXPORT_SET) - list(APPEND _RAPIDS_UNPARSED_ARGUMENTS BUILD_EXPORT_SET ${_RAPIDS_BUILD_EXPORT_SET}) + list(APPEND _RAPIDS_EXPORT_ARGUMENTS BUILD_EXPORT_SET ${_RAPIDS_BUILD_EXPORT_SET}) endif() + set(_RAPIDS_UNPARSED_ARGUMENTS ${_RAPIDS_EXPORT_ARGUMENTS}) include("${rapids-cmake-dir}/cpm/detail/package_details.cmake") rapids_cpm_package_details(nvcomp version repository tag shallow exclude) @@ -87,9 +88,17 @@ function(rapids_cpm_nvcomp) set(to_exclude ON) endif() - # first see if we have a proprietary pre-built binary listed in versions.json and it if requested. + # first search locally if `rapids_cmake_always_download` is false + if(NOT rapids_cmake_always_download) + include("${rapids-cmake-dir}/find/package.cmake") + rapids_find_package(nvcomp ${version} GLOBAL_TARGETS nvcomp::nvcomp ${_RAPIDS_EXPORT_ARGUMENTS} + FIND_ARGS QUIET) + endif() + + # second see if we have a proprietary pre-built binary listed in versions.json and it if + # requested. set(nvcomp_proprietary_binary OFF) # will be set to true by rapids_cpm_get_proprietary_binary - if(_RAPIDS_USE_PROPRIETARY_BINARY) + if(_RAPIDS_USE_PROPRIETARY_BINARY AND NOT nvcomp_FOUND) include("${rapids-cmake-dir}/cpm/detail/get_proprietary_binary_url.cmake") include("${rapids-cmake-dir}/cpm/detail/download_proprietary_binary.cmake") rapids_cpm_get_proprietary_binary_url(nvcomp ${version} nvcomp_url) diff --git a/rapids-cmake/find/package.cmake b/rapids-cmake/find/package.cmake index 24595b0ea..7970e6df0 100644 --- a/rapids-cmake/find/package.cmake +++ b/rapids-cmake/find/package.cmake @@ -115,18 +115,18 @@ macro(rapids_find_package name) set(_rapids_options FIND_ARGS) set(_rapids_one_value BUILD_EXPORT_SET INSTALL_EXPORT_SET) set(_rapids_multi_value COMPONENTS GLOBAL_TARGETS) - cmake_parse_arguments(_RAPIDS "${_rapids_options}" "${_rapids_one_value}" + cmake_parse_arguments(_RAPIDS_FIND "${_rapids_options}" "${_rapids_one_value}" "${_rapids_multi_value}" ${ARGN}) - if(_RAPIDS_COMPONENTS) - list(APPEND _RAPIDS_UNPARSED_ARGUMENTS COMPONENTS ${_RAPIDS_COMPONENTS}) + if(_RAPIDS_FIND_COMPONENTS) + list(APPEND _RAPIDS_FIND_UNPARSED_ARGUMENTS COMPONENTS ${_RAPIDS_FIND_COMPONENTS}) endif() - find_package(${name} ${_RAPIDS_UNPARSED_ARGUMENTS}) + find_package(${name} ${_RAPIDS_FIND_UNPARSED_ARGUMENTS}) - if(_RAPIDS_GLOBAL_TARGETS) + if(_RAPIDS_FIND_GLOBAL_TARGETS) include("${rapids-cmake-dir}/cmake/make_global.cmake") - rapids_cmake_make_global(_RAPIDS_GLOBAL_TARGETS) + rapids_cmake_make_global(_RAPIDS_FIND_GLOBAL_TARGETS) endif() # Only record the export requirements if the package was found This allows us to handle implicit @@ -139,11 +139,11 @@ macro(rapids_find_package name) endif() set(_rapids_extra_info) - if(_RAPIDS_GLOBAL_TARGETS) - list(APPEND _rapids_extra_info "GLOBAL_TARGETS" ${_RAPIDS_GLOBAL_TARGETS}) + if(_RAPIDS_FIND_GLOBAL_TARGETS) + list(APPEND _rapids_extra_info "GLOBAL_TARGETS" ${_RAPIDS_FIND_GLOBAL_TARGETS}) endif() - if(_RAPIDS_COMPONENTS) - list(APPEND _rapids_extra_info "COMPONENTS" ${_RAPIDS_COMPONENTS}) + if(_RAPIDS_FIND_COMPONENTS) + list(APPEND _rapids_extra_info "COMPONENTS" ${_RAPIDS_FIND_COMPONENTS}) endif() # Record the version we found to be what consumers need to find as well @@ -152,14 +152,15 @@ macro(rapids_find_package name) list(APPEND _rapids_extra_info "VERSION" ${possible_version}) endif() - if(_RAPIDS_BUILD_EXPORT_SET) + if(_RAPIDS_FIND_BUILD_EXPORT_SET) include("${rapids-cmake-dir}/export/package.cmake") - rapids_export_package(BUILD ${name} ${_RAPIDS_BUILD_EXPORT_SET} ${_rapids_extra_info}) + rapids_export_package(BUILD ${name} ${_RAPIDS_FIND_BUILD_EXPORT_SET} ${_rapids_extra_info}) endif() - if(_RAPIDS_INSTALL_EXPORT_SET) + if(_RAPIDS_FIND_INSTALL_EXPORT_SET) include("${rapids-cmake-dir}/export/package.cmake") - rapids_export_package(INSTALL ${name} ${_RAPIDS_INSTALL_EXPORT_SET} ${_rapids_extra_info}) + rapids_export_package(INSTALL ${name} ${_RAPIDS_FIND_INSTALL_EXPORT_SET} + ${_rapids_extra_info}) endif() unset(_rapids_extra_info) @@ -167,8 +168,8 @@ macro(rapids_find_package name) # Cleanup all our local variables foreach(_rapids_local_var IN LISTS _rapids_options _rapids_one_value _rapids_multi_value) - if(DEFINED _RAPIDS_${_rapids_local_var}) - unset(_RAPIDS_${_rapids_local_var}) + if(DEFINED _RAPIDS_FIND_${_rapids_local_var}) + unset(_RAPIDS_FIND_${_rapids_local_var}) endif() endforeach() unset(_rapids_local_var) From a7d1fa0299ad98ffb54774eb7f75b7dbe558ea90 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 27 Jun 2023 14:32:51 -0400 Subject: [PATCH 15/24] Correct two issues found when testing CMake 3.27 rc2 (#432) Corrects two small logic errors that became exposed due to changes in `ExternalProject` in CMake 3.27 which made it less robust to invalid inputs. The `rapids_cpm_thrust` function now properly supports the `DOWNLOAD_ONLY` parameter, and `rapids_cpm_rmm` now propagates arguments correctly to the underlying CPMFindPackage. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rapids-cmake/pull/432 --- rapids-cmake/cpm/rmm.cmake | 4 ++-- rapids-cmake/cpm/thrust.cmake | 3 ++- testing/utils/fill_cache/CMakeLists.txt | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rapids-cmake/cpm/rmm.cmake b/rapids-cmake/cpm/rmm.cmake index fbb145715..772f34582 100644 --- a/rapids-cmake/cpm/rmm.cmake +++ b/rapids-cmake/cpm/rmm.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-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. @@ -72,7 +72,7 @@ function(rapids_cpm_rmm) rapids_cpm_generate_patch_command(rmm ${version} patch_command) include("${rapids-cmake-dir}/cpm/find.cmake") - rapids_cpm_find(rmm ${version} ${ARGN} {_RAPIDS_UNPARSED_ARGUMENTS} + rapids_cpm_find(rmm ${version} ${ARGN} ${_RAPIDS_UNPARSED_ARGUMENTS} GLOBAL_TARGETS rmm::rmm CPM_ARGS GIT_REPOSITORY ${repository} diff --git a/rapids-cmake/cpm/thrust.cmake b/rapids-cmake/cpm/thrust.cmake index ebd0f46e7..7e9f923c8 100644 --- a/rapids-cmake/cpm/thrust.cmake +++ b/rapids-cmake/cpm/thrust.cmake @@ -104,7 +104,8 @@ function(rapids_cpm_thrust NAMESPACE namespaces_name) ${_RAPIDS_INSTALL_EXPORT_SET}) endif() - if(NOT TARGET ${namespaces_name}::Thrust) + # Check for the existence of thrust_create_target so we support fetching Thrust with DOWNLOAD_ONLY + if(NOT TARGET ${namespaces_name}::Thrust AND COMMAND thrust_create_target) thrust_create_target(${namespaces_name}::Thrust FROM_OPTIONS) set_target_properties(${namespaces_name}::Thrust PROPERTIES IMPORTED_NO_SYSTEM ON) if(TARGET _Thrust_Thrust) diff --git a/testing/utils/fill_cache/CMakeLists.txt b/testing/utils/fill_cache/CMakeLists.txt index 80cb11313..0dc8bcc6f 100644 --- a/testing/utils/fill_cache/CMakeLists.txt +++ b/testing/utils/fill_cache/CMakeLists.txt @@ -44,7 +44,7 @@ rapids_cpm_nvbench(DOWNLOAD_ONLY ON) rapids_cpm_rmm(DOWNLOAD_ONLY ON) rapids_cpm_spdlog(DOWNLOAD_ONLY ON) rapids_cpm_fmt(DOWNLOAD_ONLY ON) -rapids_cpm_thrust(temp DOWNLOAD_ONLY ON) +rapids_cpm_thrust(NAMESPACE temp DOWNLOAD_ONLY ON) rapids_cpm_find(skbuild 0.14.1 GIT_REPOSITORY https://github.com/scikit-build/scikit-build.git GIT_TAG 0.14.1 From 6f59951e5e49863b82db563fe8caf69750e13e30 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 29 Jun 2023 14:35:31 -0400 Subject: [PATCH 16/24] Add rapids_cuda_set_runtime (#429) Add `rapids_cuda_set_runtime` which is the per target version of `rapids_cuda_init_runtime`. Fixes https://github.com/rapidsai/rapids-cmake/issues/427 Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rapids-cmake/pull/429 --- cmake-format-rapids-cmake.json | 5 ++ docs/api.rst | 1 + docs/command/rapids_cuda_set_runtime.rst | 1 + rapids-cmake/cuda/set_runtime.cmake | 72 +++++++++++++++++++ testing/cuda/CMakeLists.txt | 4 ++ .../set_runtime-on-interface-target.cmake | 24 +++++++ testing/cuda/set_runtime-shared.cmake | 31 ++++++++ testing/cuda/set_runtime-static.cmake | 30 ++++++++ 8 files changed, 168 insertions(+) create mode 100644 docs/command/rapids_cuda_set_runtime.rst create mode 100644 rapids-cmake/cuda/set_runtime.cmake create mode 100644 testing/cuda/set_runtime-on-interface-target.cmake create mode 100644 testing/cuda/set_runtime-shared.cmake create mode 100644 testing/cuda/set_runtime-static.cmake diff --git a/cmake-format-rapids-cmake.json b/cmake-format-rapids-cmake.json index b09ce5e53..d57f9fa23 100644 --- a/cmake-format-rapids-cmake.json +++ b/cmake-format-rapids-cmake.json @@ -195,6 +195,11 @@ "nargs": 1 } }, + "rapids_cuda_set_runtime": { + "pargs": { + "nargs": 3 + } + }, "rapids_export_cpm": { "pargs": { diff --git a/docs/api.rst b/docs/api.rst index f91c58f54..6612f6095 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -107,6 +107,7 @@ require. rapids_cuda_init_architectures rapids_cuda_init_runtime rapids_cuda_patch_toolkit + rapids_cuda_set_runtime rapids_cuda_set_architectures [Advanced] diff --git a/docs/command/rapids_cuda_set_runtime.rst b/docs/command/rapids_cuda_set_runtime.rst new file mode 100644 index 000000000..16f04f577 --- /dev/null +++ b/docs/command/rapids_cuda_set_runtime.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../rapids-cmake/cuda/set_runtime.cmake diff --git a/rapids-cmake/cuda/set_runtime.cmake b/rapids-cmake/cuda/set_runtime.cmake new file mode 100644 index 000000000..1b110f2a9 --- /dev/null +++ b/rapids-cmake/cuda/set_runtime.cmake @@ -0,0 +1,72 @@ +#============================================================================= +# 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_guard(GLOBAL) + +#[=======================================================================[.rst: +rapids_cuda_set_runtime +------------------------------- + +.. versionadded:: v23.08.00 + +Establish what CUDA runtime library should be used by a single target + + .. code-block:: cmake + + rapids_cuda_set_runtime( target USE_STATIC (TRUE|FALSE) ) + + Establishes what CUDA runtime will be used for a target, via + the :cmake:prop_tgt:`CUDA_RUNTIME_LIBRARY ` + and by linking to `CUDA::cudart` or `CUDA::cudart_static` if the :cmake:module:`find_package(CUDAToolkit) + ` has been called. + + The linking to the `CUDA::cudart` or `CUDA::cudart_static` will have the following + usage behavior: + + - For `INTERFACE` targets the linking will be `INTERFACE` + - For all other targets the linking will be `PRIVATE` + + .. note:: + If using the deprecated `FindCUDA.cmake` you must use the + :cmake:command:`rapids_cuda_init_runtime` method to properly establish the default + mode. + + When `USE_STATIC TRUE` is provided the target will link to a + statically-linked CUDA runtime library. + + When `USE_STATIC FALSE` is provided the target will link to a + shared-linked CUDA runtime library. + + +#]=======================================================================] +function(rapids_cuda_set_runtime target use_static value) + list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cuda.set_runtime") + + get_target_property(type ${target} TYPE) + if(type STREQUAL "INTERFACE_LIBRARY") + set(mode INTERFACE) + else() + set(mode PRIVATE) + endif() + + if(${value}) + set_target_properties(${target} PROPERTIES CUDA_RUNTIME_LIBRARY STATIC) + target_link_libraries(${target} ${mode} $) + else() + set_target_properties(${target} PROPERTIES CUDA_RUNTIME_LIBRARY SHARED) + target_link_libraries(${target} ${mode} $) + endif() + +endfunction() diff --git a/testing/cuda/CMakeLists.txt b/testing/cuda/CMakeLists.txt index 65859361a..212dd237a 100644 --- a/testing/cuda/CMakeLists.txt +++ b/testing/cuda/CMakeLists.txt @@ -20,6 +20,10 @@ add_cmake_config_test( init_runtime-multiple.cmake ) add_cmake_config_test( init_runtime-shared.cmake ) add_cmake_config_test( init_runtime-static.cmake ) +add_cmake_config_test( set_runtime-shared.cmake ) +add_cmake_config_test( set_runtime-static.cmake ) +add_cmake_config_test( set_runtime-on-interface-target.cmake ) + add_cmake_config_test( init_arch-all-via-undef ) add_cmake_config_test( init_arch-existing-project-flags.cmake ) add_cmake_config_test( init_arch-native.cmake ) diff --git a/testing/cuda/set_runtime-on-interface-target.cmake b/testing/cuda/set_runtime-on-interface-target.cmake new file mode 100644 index 000000000..73b6f859b --- /dev/null +++ b/testing/cuda/set_runtime-on-interface-target.cmake @@ -0,0 +1,24 @@ +#============================================================================= +# 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}/cuda/set_runtime.cmake) + +add_library(uses_cuda INTERFACE) +rapids_cuda_set_runtime(uses_cuda USE_STATIC TRUE) + +get_target_property(linked_libs uses_cuda INTERFACE_LINK_LIBRARIES) +if(NOT "$" IN_LIST linked_libs) + message(FATAL_ERROR "rapids_cuda_set_runtime shouldn't set CUDA::cudart_static in target linked libraries correctly") +endif() diff --git a/testing/cuda/set_runtime-shared.cmake b/testing/cuda/set_runtime-shared.cmake new file mode 100644 index 000000000..f1e77dea1 --- /dev/null +++ b/testing/cuda/set_runtime-shared.cmake @@ -0,0 +1,31 @@ +#============================================================================= +# 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}/cuda/set_runtime.cmake) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/empty.cpp" " ") +add_library(uses_cuda SHARED ${CMAKE_CURRENT_BINARY_DIR}/empty.cpp) +rapids_cuda_set_runtime(uses_cuda USE_STATIC FALSE) + + +get_target_property(runtime_state uses_cuda CUDA_RUNTIME_LIBRARY) +if( NOT runtime_state STREQUAL "SHARED") + message(FATAL_ERROR "rapids_cuda_set_runtime didn't correctly set CUDA_RUNTIME_LIBRARY") +endif() + +get_target_property(linked_libs uses_cuda LINK_LIBRARIES) +if(NOT "$" IN_LIST linked_libs) + message(FATAL_ERROR "rapids_cuda_set_runtime didn't privately link to CUDA::cudart_static") +endif() diff --git a/testing/cuda/set_runtime-static.cmake b/testing/cuda/set_runtime-static.cmake new file mode 100644 index 000000000..c7a1c502b --- /dev/null +++ b/testing/cuda/set_runtime-static.cmake @@ -0,0 +1,30 @@ +#============================================================================= +# 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}/cuda/set_runtime.cmake) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/empty.cpp" " ") +add_library(uses_cuda SHARED ${CMAKE_CURRENT_BINARY_DIR}/empty.cpp) +rapids_cuda_set_runtime(uses_cuda USE_STATIC TRUE) + +get_target_property(runtime_state uses_cuda CUDA_RUNTIME_LIBRARY) +if( NOT runtime_state STREQUAL "STATIC") + message(FATAL_ERROR "rapids_cuda_set_runtime didn't correctly set CUDA_RUNTIME_LIBRARY") +endif() + +get_target_property(linked_libs uses_cuda LINK_LIBRARIES) +if(NOT "$" IN_LIST linked_libs) + message(FATAL_ERROR "rapids_cuda_set_runtime didn't privately link to CUDA::cudart_static") +endif() From 052d184eaf178d3ad09dd131841e4e360c363475 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 29 Jun 2023 14:44:53 -0400 Subject: [PATCH 17/24] Correct re-root controls from conda-forge with thrust/cub/etc (#431) Upstream fix: https://github.com/NVIDIA/thrust/issues/1966 Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rapids-cmake/pull/431 --- .../cpm/patches/Thrust/reroot_support.diff | 47 +++++++++++++++++++ .../patches/libcudacxx/reroot_support.diff | 12 +++++ rapids-cmake/cpm/versions.json | 12 ++++- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 rapids-cmake/cpm/patches/Thrust/reroot_support.diff create mode 100644 rapids-cmake/cpm/patches/libcudacxx/reroot_support.diff diff --git a/rapids-cmake/cpm/patches/Thrust/reroot_support.diff b/rapids-cmake/cpm/patches/Thrust/reroot_support.diff new file mode 100644 index 000000000..92ae560cf --- /dev/null +++ b/rapids-cmake/cpm/patches/Thrust/reroot_support.diff @@ -0,0 +1,47 @@ +diff --git a/dependencies/cub/cub/cmake/cub-header-search.cmake b/dependencies/cub/cub/cmake/cub-header-search.cmake +index 2ff1a8acd8..5e731f2be8 100644 +--- a/dependencies/cub/cub/cmake/cub-header-search.cmake ++++ b/dependencies/cub/cub/cmake/cub-header-search.cmake +@@ -1,5 +1,6 @@ + unset(_CUB_VERSION_INCLUDE_DIR CACHE) # Clear old result to force search + find_path(_CUB_VERSION_INCLUDE_DIR cub/version.cuh ++ NO_CMAKE_FIND_ROOT_PATH + NO_DEFAULT_PATH # Only search explicit paths below: + PATHS + "${CMAKE_CURRENT_LIST_DIR}/../.." # Source tree +diff --git a/dependencies/cub/cub/cmake/cub-header-search.cmake.in b/dependencies/cub/cub/cmake/cub-header-search.cmake.in +index 271b1b27bd..3bd10e4b70 100644 +--- a/dependencies/cub/cub/cmake/cub-header-search.cmake.in ++++ b/dependencies/cub/cub/cmake/cub-header-search.cmake.in +@@ -11,6 +11,7 @@ list(TRANSFORM from_install_prefix REPLACE ".+" "../") + list(JOIN from_install_prefix "" from_install_prefix) + + find_path(_CUB_VERSION_INCLUDE_DIR cub/version.cuh ++ NO_CMAKE_FIND_ROOT_PATH + NO_DEFAULT_PATH # Only search explicit paths below: + PATHS + "${CMAKE_CURRENT_LIST_DIR}/${from_install_prefix}/@CMAKE_INSTALL_INCLUDEDIR@" +diff --git a/thrust/cmake/thrust-header-search.cmake b/thrust/cmake/thrust-header-search.cmake +index 643ec90b7..7d27c68f4 100644 +--- a/thrust/cmake/thrust-header-search.cmake ++++ b/thrust/cmake/thrust-header-search.cmake +@@ -1,6 +1,7 @@ + # Parse version information from version.h: + unset(_THRUST_VERSION_INCLUDE_DIR CACHE) # Clear old result to force search + find_path(_THRUST_VERSION_INCLUDE_DIR thrust/version.h ++ NO_CMAKE_FIND_ROOT_PATH + NO_DEFAULT_PATH # Only search explicit paths below: + PATHS + "${CMAKE_CURRENT_LIST_DIR}/../.." # Source tree +diff --git a/thrust/cmake/thrust-header-search.cmake.in b/thrust/cmake/thrust-header-search.cmake.in +index c014c469b..adea07e2d 100644 +--- a/thrust/cmake/thrust-header-search.cmake.in ++++ b/thrust/cmake/thrust-header-search.cmake.in +@@ -11,6 +11,7 @@ list(TRANSFORM from_install_prefix REPLACE ".+" "../") + list(JOIN from_install_prefix "" from_install_prefix) + + find_path(_THRUST_VERSION_INCLUDE_DIR thrust/version.h ++ NO_CMAKE_FIND_ROOT_PATH + NO_DEFAULT_PATH # Only search explicit paths below: + PATHS + "${CMAKE_CURRENT_LIST_DIR}/${from_install_prefix}/@CMAKE_INSTALL_INCLUDEDIR@" diff --git a/rapids-cmake/cpm/patches/libcudacxx/reroot_support.diff b/rapids-cmake/cpm/patches/libcudacxx/reroot_support.diff new file mode 100644 index 000000000..2b623988b --- /dev/null +++ b/rapids-cmake/cpm/patches/libcudacxx/reroot_support.diff @@ -0,0 +1,12 @@ +diff --git a/lib/cmake/libcudacxx/libcudacxx-header-search.cmake.in b/lib/cmake/libcudacxx/libcudacxx-header-search.cmake.in +index 8c44d990..365b9de0 100644 +--- a/lib/cmake/libcudacxx/libcudacxx-header-search.cmake.in ++++ b/lib/cmake/libcudacxx/libcudacxx-header-search.cmake.in +@@ -11,6 +11,7 @@ list(TRANSFORM from_install_prefix REPLACE ".+" "../") + list(JOIN from_install_prefix "" from_install_prefix) + + find_path(_libcudacxx_VERSION_INCLUDE_DIR cuda/std/detail/__config ++ NO_CMAKE_FIND_ROOT_PATH # Don't allow CMake to re-root the search + NO_DEFAULT_PATH # Only search explicit paths below: + PATHS + "${CMAKE_CURRENT_LIST_DIR}/${from_install_prefix}/@CMAKE_INSTALL_INCLUDEDIR@" # Install tree diff --git a/rapids-cmake/cpm/versions.json b/rapids-cmake/cpm/versions.json index 465ef7907..16b179302 100644 --- a/rapids-cmake/cpm/versions.json +++ b/rapids-cmake/cpm/versions.json @@ -31,7 +31,12 @@ "file" : "libcudacxx/install_rules.diff", "issue" : "libcudacxx 1.X installs incorrect files [https://github.com/NVIDIA/libcudacxx/pull/428]", "fixed_in" : "2.2" - } + }, + { + "file" : "libcudacxx/reroot_support.diff", + "issue" : "Support conda-forge usage of CMake rerooting [https://github.com/NVIDIA/libcudacxx/pull/490]", + "fixed_in" : "2.2" + }, ] }, "nvbench" : { @@ -71,6 +76,11 @@ "git_url" : "https://github.com/NVIDIA/thrust.git", "git_tag" : "${version}", "patches" : [ + { + "file" : "Thrust/reroot_support.diff", + "issue" : "Support conda-forge usage of CMake rerooting [https://github.com/NVIDIA/thrust/pull/1969]", + "fixed_in" : "2.2" + }, { "file" : "Thrust/transform_iter_with_reduce_by_key.diff", "issue" : "Support transform iterator with reduce by key [https://github.com/NVIDIA/thrust/pull/1805]", From 965321ee8323f77ffaa1bd6ff825d12245d55cd3 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 5 Jul 2023 08:43:30 -0400 Subject: [PATCH 18/24] When nvcomp is found locally print where it is on disk (#434) This way users always get some console output for where nvcomp is located. We don't remove the `QUIET` request since that would print out the following: ``` CMake Warning at ..../rapids-cmake/find/package.cmake:125 (find_package): By not providing "Findnvcomp.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "nvcomp", but CMake did not find one. Could not find a package configuration file provided by "nvcomp" (requested version 2.6.1) with any of the following names: nvcompConfig.cmake nvcomp-config.cmake Add the installation prefix of "nvcomp" to CMAKE_PREFIX_PATH or set "nvcomp_DIR" to a directory containing one of the above files. If "nvcomp" provides a separate development package or SDK, be sure it has been installed. ``` Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: None URL: https://github.com/rapidsai/rapids-cmake/pull/434 --- rapids-cmake/cpm/nvcomp.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rapids-cmake/cpm/nvcomp.cmake b/rapids-cmake/cpm/nvcomp.cmake index 2021aec35..eea96038d 100644 --- a/rapids-cmake/cpm/nvcomp.cmake +++ b/rapids-cmake/cpm/nvcomp.cmake @@ -93,6 +93,10 @@ function(rapids_cpm_nvcomp) include("${rapids-cmake-dir}/find/package.cmake") rapids_find_package(nvcomp ${version} GLOBAL_TARGETS nvcomp::nvcomp ${_RAPIDS_EXPORT_ARGUMENTS} FIND_ARGS QUIET) + if(nvcomp_FOUND) + # report where nvcomp was found + message(STATUS "Found nvcomp: ${nvcomp_DIR} (found version ${nvcomp_VERSION})") + endif() endif() # second see if we have a proprietary pre-built binary listed in versions.json and it if From 41a83482624a5a4a88859dfcd17b646919519385 Mon Sep 17 00:00:00 2001 From: Yunsong Wang Date: Tue, 11 Jul 2023 19:00:01 -0700 Subject: [PATCH 19/24] Bump cuco version (#435) This PR bump the cuco version to the latest. Opened https://github.com/rapidsai/cudf/pull/13665 to verify it won't break cudf. Opened https://github.com/rapidsai/raft/pull/1641 to verify it won't break raft. https://github.com/rapidsai/cugraph/issues/3692 to be addressed once this PR is merged. Authors: - Yunsong Wang (https://github.com/PointKernel) Approvers: - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/rapids-cmake/pull/435 --- rapids-cmake/cpm/versions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rapids-cmake/cpm/versions.json b/rapids-cmake/cpm/versions.json index 16b179302..5b2cb573c 100644 --- a/rapids-cmake/cpm/versions.json +++ b/rapids-cmake/cpm/versions.json @@ -10,7 +10,7 @@ "version" : "0.0.1", "git_shallow" : false, "git_url" : "https://github.com/NVIDIA/cuCollections.git", - "git_tag" : "546ca606a17f480fa9d58d1752cce2aad6575bc4" + "git_tag" : "303f134573afa315cf14fca3f7a0b730438497c3" }, "fmt" : { "version" : "9.1.0", From 05be912dc8614b48f5af1aa07b086dd8143c9b5d Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 13 Jul 2023 09:38:04 -0400 Subject: [PATCH 20/24] Update rapids-cmake ci to support conda-forge CUDA 12 (#437) Needed due to the changes coming to the rapids shared-action-workflow: https://github.com/rapidsai/shared-action-workflows/issues/112 Authors: - Robert Maynard (https://github.com/robertmaynard) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rapids-cmake/pull/437 --- .github/workflows/build.yaml | 6 +- .github/workflows/pr.yaml | 10 +-- .github/workflows/test.yaml | 2 +- ci/check_style.sh | 2 +- .../conda_build_config.yaml | 6 ++ .../rapids_core_dependencies/meta.yaml | 17 +++-- dependencies.yaml | 63 +++++++++++++++++-- 7 files changed, 87 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b2de1180a..2185560fa 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-120 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: upload-conda: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@cuda-120 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: docs-build: if: github.ref_type == 'branch' secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-120 with: arch: "amd64" branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 2977ce28b..450b04990 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -17,26 +17,26 @@ jobs: - conda-cpp-tests - docs-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@cuda-120 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@cuda-120 conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-120 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-120 with: build_type: pull-request docs-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-120 with: build_type: pull-request node_type: "cpu4" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fba047b13..e433745a0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-120 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/ci/check_style.sh b/ci/check_style.sh index 82dc1b68a..db39e7389 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -9,7 +9,7 @@ rapids-logger "Create checks conda environment" rapids-dependency-file-generator \ --output conda \ --file_key checks \ - --matrix "" | tee env.yaml + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml rapids-mamba-retry env create --force -f env.yaml -n checks diff --git a/conda/recipes/rapids_core_dependencies/conda_build_config.yaml b/conda/recipes/rapids_core_dependencies/conda_build_config.yaml index 9f90f6f0c..c65bc4f3d 100644 --- a/conda/recipes/rapids_core_dependencies/conda_build_config.yaml +++ b/conda/recipes/rapids_core_dependencies/conda_build_config.yaml @@ -2,7 +2,13 @@ cxx_compiler_version: - 11 cuda_compiler: + - cuda-nvcc + +cuda11_compiler: - nvcc +cmake_version: + - ">=3.26.4" + sysroot_version: - "2.17" diff --git a/conda/recipes/rapids_core_dependencies/meta.yaml b/conda/recipes/rapids_core_dependencies/meta.yaml index 6362829bc..efa54215a 100644 --- a/conda/recipes/rapids_core_dependencies/meta.yaml +++ b/conda/recipes/rapids_core_dependencies/meta.yaml @@ -16,18 +16,27 @@ build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} ignore_run_exports_from: - - {{ compiler('cuda') }} + {% if cuda_major == "11" %} + - {{ compiler('cuda11') }} + {% endif %} requirements: build: - - cmake>=3.23.1,!=3.25.0 + - cmake {{ cmake_version }} - {{ compiler('cxx') }} - - {{ compiler('cuda') }} {{ cuda_version }} + {% if cuda_major == "11" %} + - {{ compiler('cuda11') }} ={{ cuda_version }} + {% else %} + - {{ compiler('cuda') }} + {% endif %} + - cuda-version ={{ cuda_version }} - make - ninja - sysroot_{{ target_platform }} {{ sysroot_version }} host: - - cudatoolkit ={{ cuda_version }} + - cuda-version ={{ cuda_version }} + run: + - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} about: home: https://rapids.ai/ diff --git a/dependencies.yaml b/dependencies.yaml index 4421ff28a..4625261fa 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -32,6 +32,44 @@ dependencies: - c-compiler - cxx-compiler - make + specific: + - output_types: conda + matrices: + - matrix: + arch: x86_64 + cuda: "11.2" + packages: + - nvcc_linux-64=11.2 + - matrix: + arch: aarch64 + cuda: "11.2" + packages: + - nvcc_linux-aarch64=11.2 + - matrix: + arch: x86_64 + cuda: "11.4" + packages: + - nvcc_linux-64=11.4 + - matrix: + arch: aarch64 + cuda: "11.4" + packages: + - nvcc_linux-aarch64=11.4 + - matrix: + arch: x86_64 + cuda: "11.8" + packages: + - nvcc_linux-64=11.8 + - matrix: + arch: aarch64 + cuda: "11.8" + packages: + - nvcc_linux-aarch64=11.8 + - matrix: + cuda: "12.0" + packages: + - cuda-version=12.0 + - cuda-nvcc cudatoolkit: specific: - output_types: conda @@ -39,29 +77,44 @@ dependencies: - matrix: cuda: "11.2" packages: - - cudatoolkit=11.2 + - cuda-version=11.2 + - cudatoolkit - gcc<11.0.0 - sysroot_linux-64==2.17 - matrix: cuda: "11.4" packages: - - cudatoolkit=11.4 + - cuda-version=11.4 + - cudatoolkit - gcc<11.0.0 - sysroot_linux-64==2.17 - matrix: cuda: "11.5" packages: - - cudatoolkit=11.5 + - cuda-version=11.5 + - cudatoolkit + - gcc<12.0.0 - sysroot_linux-64==2.17 - matrix: cuda: "11.6" packages: - - cudatoolkit=11.6 + - cuda-version=11.6 + - cudatoolkit + - gcc<12.0.0 - sysroot_linux-64==2.17 - matrix: cuda: "11.8" packages: - - cudatoolkit=11.8 + - cuda-version=11.8 + - cudatoolkit + - gcc<12.0.0 + - sysroot_linux-64==2.17 + - matrix: + cuda: "12.0" + packages: + - cuda-version=12.0 + - cuda-cupti-dev + - gcc<13.0.0 - sysroot_linux-64==2.17 docs: common: From 37c650803d997a85cf522384d42c3275a240e47e Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 18 Jul 2023 15:31:58 -0500 Subject: [PATCH 21/24] Migrate to updated shared-action-workflows name for CUDA 12 CI (#438) This PR reverts changes to the branch of `shared-action-workflows` used for CUDA 12 testing. Now that https://github.com/rapidsai/shared-action-workflows/pull/101 is merged, we can revert this. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rapids-cmake/pull/438 --- .github/workflows/build.yaml | 6 +++--- .github/workflows/pr.yaml | 10 +++++----- .github/workflows/test.yaml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2185560fa..7827e2312 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: upload-conda: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: docs-build: if: github.ref_type == 'branch' secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 with: arch: "amd64" branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 450b04990..2977ce28b 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -17,26 +17,26 @@ jobs: - conda-cpp-tests - docs-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.08 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.08 conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 with: build_type: pull-request docs-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 with: build_type: pull-request node_type: "cpu4" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e433745a0..fba047b13 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 with: build_type: nightly branch: ${{ inputs.branch }} From 0862c821f30c5d33c29deb3fdf8cd2f00a0ee8b9 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Thu, 20 Jul 2023 15:34:46 -0400 Subject: [PATCH 22/24] v23.10 --- .github/workflows/build.yaml | 6 +++--- .github/workflows/pr.yaml | 10 +++++----- .github/workflows/test.yaml | 2 +- RAPIDS.cmake | 2 +- ci/build_docs.sh | 2 +- docs/basics.rst | 4 ++-- docs/conf.py | 4 ++-- rapids-cmake/rapids-version.cmake | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7827e2312..5971444bf 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: upload-conda: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: docs-build: if: github.ref_type == 'branch' secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.10 with: arch: "amd64" branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 2977ce28b..d4979eb45 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -17,26 +17,26 @@ jobs: - conda-cpp-tests - docs-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.10 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.10 conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.10 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.10 with: build_type: pull-request docs-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.10 with: build_type: pull-request node_type: "cpu4" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fba047b13..38b565a40 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.10 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/RAPIDS.cmake b/RAPIDS.cmake index 2d8205e21..78bcab755 100644 --- a/RAPIDS.cmake +++ b/RAPIDS.cmake @@ -20,7 +20,7 @@ # Allow users to control which version is used if(NOT rapids-cmake-version) # Define a default version if the user doesn't set one - set(rapids-cmake-version 23.08) + set(rapids-cmake-version 23.10) endif() # Allow users to control which GitHub repo is fetched diff --git a/ci/build_docs.sh b/ci/build_docs.sh index afb8f4db1..892adbfb0 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -16,7 +16,7 @@ conda activate docs rapids-print-env -export RAPIDS_VERSION_NUMBER="23.08" +export RAPIDS_VERSION_NUMBER="23.10" export RAPIDS_DOCS_DIR="$(mktemp -d)" rapids-logger "Build Sphinx docs" diff --git a/docs/basics.rst b/docs/basics.rst index bda2006b7..8cd89afdc 100644 --- a/docs/basics.rst +++ b/docs/basics.rst @@ -13,7 +13,7 @@ Content `_ into yo cmake_minimum_required(...) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.08/RAPIDS.cmake + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.10/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/_RAPIDS.cmake) endif() include(${CMAKE_CURRENT_BINARY_DIR}/_RAPIDS.cmake) @@ -58,7 +58,7 @@ like this: GIT_REPOSITORY https://github.com//rapids-cmake.git GIT_TAG ) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.08/RAPIDS.cmake + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.10/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake) diff --git a/docs/conf.py b/docs/conf.py index 56d801de8..fc0db2d0b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,9 +25,9 @@ # built documents. # # The short X.Y version. -version = "23.08" +version = "23.10" # The full version, including alpha/beta/rc tags. -release = "23.08.00" +release = "23.10.00" # -- General configuration --------------------------------------------------- diff --git a/rapids-cmake/rapids-version.cmake b/rapids-cmake/rapids-version.cmake index 2fe83c160..6d114d834 100644 --- a/rapids-cmake/rapids-version.cmake +++ b/rapids-cmake/rapids-version.cmake @@ -17,5 +17,5 @@ # that breaks its usage by cpm/detail/package_details if(NOT DEFINED rapids-cmake-version) - set(rapids-cmake-version 23.08) + set(rapids-cmake-version 23.10) endif() From 51161dab031988d254429ed4fac4a043ddf7e683 Mon Sep 17 00:00:00 2001 From: Paul Taylor <178183+trxcllnt@users.noreply.github.com> Date: Thu, 20 Jul 2023 14:22:59 -0700 Subject: [PATCH 23/24] Conditionally modify envvar vs. global CMAKE_PREFIX_PATH in `rapids_cmake_support_conda_env` (#439) This PR updates the logic when `rapids_cmake_support_conda_env()` is called with `MODIFY_PREFIX_PATH`. The current logic prepends the `$PREFIX`/`$BUILD_PREFIX`/`$CONDA_PREFIX` paths to the global `CMAKE_PREFIX_PATH` variable. This PR proposes the following changes: 1. Append instead of prepend the `$PREFIX`/`$BUILD_PREFIX`/`$CONDA_PREFIX` paths 2. Prefer modifying the `CMAKE_PREFIX_PATH` _environment variable_ instead of the global `CMAKE_PREFIX_PATH` variable 3. Only modify the global `CMAKE_PREFIX_PATH` variable if it's already populated (preserving paths in `ENV{CMAKE_PREFIX_PATH}`) Authors: - Paul Taylor (https://github.com/trxcllnt) Approvers: - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/rapids-cmake/pull/439 --- rapids-cmake/cmake/support_conda_env.cmake | 56 ++++++++-- testing/cmake/CMakeLists.txt | 4 + testing/cmake/conda_env-build-envvar.cmake | 96 +++++++++++++++++ testing/cmake/conda_env-build.cmake | 11 +- .../conda_env-cross-build-arm-envvar.cmake | 100 +++++++++++++++++ testing/cmake/conda_env-cross-build-arm.cmake | 9 +- .../conda_env-cross-build-x86-envvar.cmake | 101 ++++++++++++++++++ testing/cmake/conda_env-cross-build-x86.cmake | 9 +- testing/cmake/conda_env-prefix-envvar.cmake | 80 ++++++++++++++ testing/cmake/conda_env-prefix.cmake | 11 +- 10 files changed, 453 insertions(+), 24 deletions(-) create mode 100644 testing/cmake/conda_env-build-envvar.cmake create mode 100644 testing/cmake/conda_env-cross-build-arm-envvar.cmake create mode 100644 testing/cmake/conda_env-cross-build-x86-envvar.cmake create mode 100644 testing/cmake/conda_env-prefix-envvar.cmake diff --git a/rapids-cmake/cmake/support_conda_env.cmake b/rapids-cmake/cmake/support_conda_env.cmake index e5e18614e..5b863ba71 100644 --- a/rapids-cmake/cmake/support_conda_env.cmake +++ b/rapids-cmake/cmake/support_conda_env.cmake @@ -59,7 +59,7 @@ Result Targets `target_name` target will be created only if called from a conda environment. #]=======================================================================] -# cmake-lint: disable=R0912,R0915 +# cmake-lint: disable=R0912,R0915,W0106 function(rapids_cmake_support_conda_env target) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cmake.support_conda_env") @@ -76,12 +76,50 @@ function(rapids_cmake_support_conda_env target) if(in_conda_build OR in_conda_prefix) + # comment needed here due to cmake-lint bug + macro(modify_cmake_prefix_path_global) + cmake_parse_arguments(_RAPIDS "" "" "PATHS" ${ARGN}) + + if(DEFINED ENV{CMAKE_PREFIX_PATH}) + # If both CMAKE_PREFIX_PATH cmake and environment variables are populated, ensure the + # environment variable's paths are preserved in the cmake variable + cmake_path(CONVERT "$ENV{CMAKE_PREFIX_PATH}" TO_CMAKE_PATH_LIST _paths NORMALIZE) + list(PREPEND _RAPIDS_PATHS ${_paths}) + endif() + + list(APPEND CMAKE_PREFIX_PATH ${_RAPIDS_PATHS}) + list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH) + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE) + message(VERBOSE "CMAKE_PREFIX_PATH set to: ${CMAKE_PREFIX_PATH}") + endmacro() + + # comment needed here due to cmake-lint bug + macro(modify_cmake_prefix_path_envvar) + cmake_parse_arguments(_RAPIDS "" "" "PATHS" ${ARGN}) + cmake_path(CONVERT "$ENV{CMAKE_PREFIX_PATH}" TO_CMAKE_PATH_LIST _paths NORMALIZE) + list(APPEND _paths ${_RAPIDS_PATHS}) + list(REMOVE_DUPLICATES _paths) + cmake_path(CONVERT "${_paths}" TO_NATIVE_PATH_LIST _paths NORMALIZE) + # cmake-lint: disable=W0106 + set(ENV{CMAKE_PREFIX_PATH} ${_paths}) + # cmake-lint: disable=W0106 + message(VERBOSE "ENV{CMAKE_PREFIX_PATH} set to: $ENV{CMAKE_PREFIX_PATH}") + endmacro() + + # comment needed here due to cmake-lint bug + macro(modify_cmake_prefix_path) + if(DEFINED CMAKE_PREFIX_PATH) + modify_cmake_prefix_path_global(${ARGN}) + else() + modify_cmake_prefix_path_envvar(${ARGN}) + endif() + endmacro() + if(ARGV1 STREQUAL "MODIFY_PREFIX_PATH") set(modify_prefix_path TRUE) endif() add_library(${target} INTERFACE) - set(prefix_paths) if(in_conda_build) # For conda-build we add the host conda environment prefix to the cmake search paths so that @@ -116,12 +154,12 @@ function(rapids_cmake_support_conda_env target) endif() if(modify_prefix_path) - list(PREPEND CMAKE_PREFIX_PATH "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}") + message(VERBOSE "Conda build detected") + set(prefix_paths "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}") if(DEFINED targetsDir) - list(PREPEND CMAKE_PREFIX_PATH "$ENV{PREFIX}/${targetsDir}") + list(PREPEND prefix_paths "$ENV{PREFIX}/${targetsDir}") endif() - set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" PARENT_SCOPE) - message(VERBOSE "Conda build detected, CMAKE_PREFIX_PATH set to: ${CMAKE_PREFIX_PATH}") + modify_cmake_prefix_path(PATHS ${prefix_paths}) endif() elseif(in_conda_prefix) @@ -134,10 +172,8 @@ function(rapids_cmake_support_conda_env target) endif() if(modify_prefix_path) - list(PREPEND CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX}") - set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" PARENT_SCOPE) - message(VERBOSE - "Conda environment detected, CMAKE_PREFIX_PATH set to: ${CMAKE_PREFIX_PATH}") + message(VERBOSE "Conda environment detected") + modify_cmake_prefix_path(PATHS "$ENV{CONDA_PREFIX}") endif() endif() endif() diff --git a/testing/cmake/CMakeLists.txt b/testing/cmake/CMakeLists.txt index a75944e6f..22f68be7b 100644 --- a/testing/cmake/CMakeLists.txt +++ b/testing/cmake/CMakeLists.txt @@ -21,10 +21,14 @@ add_cmake_config_test( build_type-multiple.cmake ) add_cmake_config_test( build_type-user-specified.cmake) add_cmake_config_test( conda_env-build.cmake ) +add_cmake_config_test( conda_env-build-envvar.cmake ) add_cmake_config_test( conda_env-cross-build-arm.cmake ) +add_cmake_config_test( conda_env-cross-build-arm-envvar.cmake ) add_cmake_config_test( conda_env-cross-build-x86.cmake ) +add_cmake_config_test( conda_env-cross-build-x86-envvar.cmake ) add_cmake_config_test( conda_env-invalid.cmake ) add_cmake_config_test( conda_env-prefix.cmake ) +add_cmake_config_test( conda_env-prefix-envvar.cmake ) add_cmake_config_test( install_lib_dir-after-gnuinstalldir-include.cmake ) add_cmake_config_test( install_lib_dir-build.cmake ) diff --git a/testing/cmake/conda_env-build-envvar.cmake b/testing/cmake/conda_env-build-envvar.cmake new file mode 100644 index 000000000..3f7bd7f89 --- /dev/null +++ b/testing/cmake/conda_env-build-envvar.cmake @@ -0,0 +1,96 @@ +#============================================================================= +# 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}/cmake/support_conda_env.cmake) + + +set(ENV{CONDA_BUILD} "1") +set(ENV{BUILD_PREFIX} "/usr/local/build_prefix") +set(ENV{PREFIX} "/opt/local/prefix") +set(ENV{CONDA_PREFIX} "/opt/conda/prefix") + +rapids_cmake_support_conda_env(conda_env) +if(NOT TARGET conda_env) + message(FATAL_ERROR "Expected target conda_env to exist") +endif() + +get_target_property(include_dirs conda_env INTERFACE_INCLUDE_DIRECTORIES) +if( NOT "$ENV{BUILD_PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Expected env{BUILD_PREFIX} to be in the include dirs of `conda_env`") +endif() +if( NOT "$ENV{PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Expected env{PREFIX} to be in the include dirs of `conda_env`") +endif() +if("$ENV{CONDA_PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Not expected for env{CONDA_PREFIX} to be in the include dirs of `conda_env`") +endif() + +get_target_property(link_dirs conda_env INTERFACE_LINK_DIRECTORIES) +if( NOT "$ENV{BUILD_PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Expected env{BUILD_PREFIX} to be in the link dirs of `conda_env`") +endif() +if( NOT "$ENV{PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Expected env{PREFIX} to be in the link dirs of `conda_env`") +endif() +if("$ENV{CONDA_PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Not expected for env{CONDA_PREFIX} to be in the link dirs of `conda_env`") +endif() + +get_target_property(link_options conda_env INTERFACE_LINK_OPTIONS) +message(STATUS "link_options: ${link_options}") +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{BUILD_PREFIX} to be in the link options of `conda_env`") +endif() +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{PREFIX} to be in the link options of `conda_env`") +endif() +if("$" IN_LIST link_options) + message(FATAL_ERROR "Not expected for rpath-link=env{CONDA_PREFIX} to be in the link options of `conda_env`") +endif() + +# No effect as the target already exists +set(before_call_value "$ENV{CMAKE_PREFIX_PATH}" ) +rapids_cmake_support_conda_env(conda_env MODIFY_PREFIX_PATH) +if(NOT ("${before_call_value}" STREQUAL "$ENV{CMAKE_PREFIX_PATH}") ) + message(FATAL_ERROR "Expected rapids_cmake_support_conda_env not to change ENV{CMAKE_PREFIX_PATH}") +endif() + +# New target being used, so this should modify ENV{CMAKE_PREFIX_PATH} +set(ENV{CMAKE_PREFIX_PATH} "placeholder" ) +rapids_cmake_support_conda_env(conda_env_modify MODIFY_PREFIX_PATH) +if(NOT TARGET conda_env_modify) + message(FATAL_ERROR "Expected target conda_env_modify to exist") +endif() + +cmake_path(CONVERT "$ENV{CMAKE_PREFIX_PATH}" TO_CMAKE_PATH_LIST env_cmake_prefix_path NORMALIZE) + +list(LENGTH env_cmake_prefix_path len) +if( len GREATER 3) + message(FATAL_ERROR "ENV{CMAKE_PREFIX_PATH} length is wrong after MODIFY_PREFIX_PATH") +endif() + +list(GET env_cmake_prefix_path 0 first_value) +list(GET env_cmake_prefix_path 1 second_value) +list(GET env_cmake_prefix_path 2 third_value) +set(correct_list "placeholder" "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}") +set(actual_list "${first_value}" "${second_value}" "${third_value}") + +foreach(correct actual IN ZIP_LISTS correct_list actual_list) + if(NOT correct STREQUAL actual) + message(STATUS "correct: ${correct}") + message(STATUS "actual: ${actual}") + message(FATAL_ERROR "MODIFY_PREFIX_PATH failed") + endif() +endforeach() diff --git a/testing/cmake/conda_env-build.cmake b/testing/cmake/conda_env-build.cmake index 81435fb8e..22a14045f 100644 --- a/testing/cmake/conda_env-build.cmake +++ b/testing/cmake/conda_env-build.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-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. @@ -69,21 +69,24 @@ endif() # New target being used, so this should modify CMAKE_PREFIX_PATH set(CMAKE_PREFIX_PATH "placeholder" ) +set(ENV{CMAKE_PREFIX_PATH} "env_1:env_2" ) rapids_cmake_support_conda_env(conda_env_modify MODIFY_PREFIX_PATH) if(NOT TARGET conda_env_modify) message(FATAL_ERROR "Expected target conda_env_modify to exist") endif() list(LENGTH CMAKE_PREFIX_PATH len) -if( len GREATER 3) +if( len GREATER 5) message(FATAL_ERROR "CMAKE_PREFIX_PATH length is wrong after MODIFY_PREFIX_PATH") endif() list(GET CMAKE_PREFIX_PATH 0 first_value) list(GET CMAKE_PREFIX_PATH 1 second_value) list(GET CMAKE_PREFIX_PATH 2 third_value) -set(correct_list "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}" "placeholder") -set(actual_list "${first_value}" "${second_value}" "${third_value}") +list(GET CMAKE_PREFIX_PATH 3 fourth_value) +list(GET CMAKE_PREFIX_PATH 4 fifth_value) +set(correct_list "placeholder" "env_1" "env_2" "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}") +set(actual_list "${first_value}" "${second_value}" "${third_value}" "${fourth_value}" "${fifth_value}") foreach(correct actual IN ZIP_LISTS correct_list actual_list) if(NOT correct STREQUAL actual) diff --git a/testing/cmake/conda_env-cross-build-arm-envvar.cmake b/testing/cmake/conda_env-cross-build-arm-envvar.cmake new file mode 100644 index 000000000..64c20af34 --- /dev/null +++ b/testing/cmake/conda_env-cross-build-arm-envvar.cmake @@ -0,0 +1,100 @@ +#============================================================================= +# 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}/cmake/support_conda_env.cmake) + + +set(ENV{CONDA_BUILD} "1") +set(ENV{BUILD_PREFIX} "/usr/local/build_prefix") +set(ENV{cross_target_platform} "linux-aarch64") +set(ENV{PREFIX} "/opt/local/prefix") +set(ENV{CONDA_PREFIX} "/opt/conda/prefix") + +rapids_cmake_support_conda_env(conda_env) +if(NOT TARGET conda_env) + message(FATAL_ERROR "Expected target conda_env to exist") +endif() + +get_target_property(include_dirs conda_env INTERFACE_INCLUDE_DIRECTORIES) +if( NOT "$ENV{BUILD_PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Expected env{BUILD_PREFIX} to be in the include dirs of `conda_env`") +endif() +if( NOT "$ENV{PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Expected env{PREFIX} to be in the include dirs of `conda_env`") +endif() +if("$ENV{CONDA_PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Not expected for env{CONDA_PREFIX} to be in the include dirs of `conda_env`") +endif() + +get_target_property(link_dirs conda_env INTERFACE_LINK_DIRECTORIES) +if( NOT "$ENV{BUILD_PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Expected env{BUILD_PREFIX} to be in the link dirs of `conda_env`") +endif() +if( NOT "$ENV{PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Expected env{PREFIX} to be in the link dirs of `conda_env`") +endif() +if("$ENV{CONDA_PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Not expected for env{CONDA_PREFIX} to be in the link dirs of `conda_env`") +endif() + +get_target_property(link_options conda_env INTERFACE_LINK_OPTIONS) +message(STATUS "link_options: ${link_options}") +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{BUILD_PREFIX} to be in the link options of `conda_env`") +endif() +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{PREFIX} to be in the link options of `conda_env`") +endif() +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{PREFIX}/targets/sbsa-linux/ to be in the link options of `conda_env`") +endif() +if("$" IN_LIST link_options) + message(FATAL_ERROR "Not expected for rpath-link=env{CONDA_PREFIX} to be in the link options of `conda_env`") +endif() + +# No effect as the target already exists +set(before_call_value "$ENV{CMAKE_PREFIX_PATH}" ) +rapids_cmake_support_conda_env(conda_env MODIFY_PREFIX_PATH) +if(NOT ("${before_call_value}" STREQUAL "$ENV{CMAKE_PREFIX_PATH}") ) + message(FATAL_ERROR "Expected rapids_cmake_support_conda_env not to change ENV{CMAKE_PREFIX_PATH}") +endif() + +# New target being used, so this should modify ENV{CMAKE_PREFIX_PATH} +set(ENV{CMAKE_PREFIX_PATH} "placeholder" ) +rapids_cmake_support_conda_env(conda_env_modify MODIFY_PREFIX_PATH) +if(NOT TARGET conda_env_modify) + message(FATAL_ERROR "Expected target conda_env_modify to exist") +endif() + +cmake_path(CONVERT "$ENV{CMAKE_PREFIX_PATH}" TO_CMAKE_PATH_LIST env_cmake_prefix_path NORMALIZE) + +list(LENGTH env_cmake_prefix_path len) +if( len GREATER 4) + message(FATAL_ERROR "ENV{CMAKE_PREFIX_PATH} length is wrong after MODIFY_PREFIX_PATH") +endif() + +list(GET env_cmake_prefix_path 0 first_value) +list(GET env_cmake_prefix_path 1 second_value) +list(GET env_cmake_prefix_path 2 third_value) +list(GET env_cmake_prefix_path 3 fourth_value) +set(correct_list "placeholder" "$ENV{PREFIX}/targets/sbsa-linux" "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}") +set(actual_list "${first_value}" "${second_value}" "${third_value}" "${fourth_value}") +foreach(correct actual IN ZIP_LISTS correct_list actual_list) + if(NOT correct STREQUAL actual) + message(STATUS "correct: ${correct}") + message(STATUS "actual: ${actual}") + message(FATAL_ERROR "MODIFY_PREFIX_PATH failed") + endif() +endforeach() diff --git a/testing/cmake/conda_env-cross-build-arm.cmake b/testing/cmake/conda_env-cross-build-arm.cmake index 86a8ffc8d..7838123ff 100644 --- a/testing/cmake/conda_env-cross-build-arm.cmake +++ b/testing/cmake/conda_env-cross-build-arm.cmake @@ -73,13 +73,14 @@ endif() # New target being used, so this should modify CMAKE_PREFIX_PATH set(CMAKE_PREFIX_PATH "placeholder" ) +set(ENV{CMAKE_PREFIX_PATH} "env_1:env_2" ) rapids_cmake_support_conda_env(conda_env_modify MODIFY_PREFIX_PATH) if(NOT TARGET conda_env_modify) message(FATAL_ERROR "Expected target conda_env_modify to exist") endif() list(LENGTH CMAKE_PREFIX_PATH len) -if( len GREATER 4) +if( len GREATER 6) message(FATAL_ERROR "CMAKE_PREFIX_PATH length is wrong after MODIFY_PREFIX_PATH") endif() @@ -87,8 +88,10 @@ list(GET CMAKE_PREFIX_PATH 0 first_value) list(GET CMAKE_PREFIX_PATH 1 second_value) list(GET CMAKE_PREFIX_PATH 2 third_value) list(GET CMAKE_PREFIX_PATH 3 fourth_value) -set(correct_list "$ENV{PREFIX}/targets/sbsa-linux" "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}" "placeholder") -set(actual_list "${first_value}" "${second_value}" "${third_value}" "${fourth_value}") +list(GET CMAKE_PREFIX_PATH 4 fifth_value) +list(GET CMAKE_PREFIX_PATH 5 sixth_value) +set(correct_list "placeholder" "env_1" "env_2" "$ENV{PREFIX}/targets/sbsa-linux" "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}") +set(actual_list "${first_value}" "${second_value}" "${third_value}" "${fourth_value}" "${fifth_value}" "${sixth_value}") foreach(correct actual IN ZIP_LISTS correct_list actual_list) if(NOT correct STREQUAL actual) message(STATUS "correct: ${correct}") diff --git a/testing/cmake/conda_env-cross-build-x86-envvar.cmake b/testing/cmake/conda_env-cross-build-x86-envvar.cmake new file mode 100644 index 000000000..ce10f2ebe --- /dev/null +++ b/testing/cmake/conda_env-cross-build-x86-envvar.cmake @@ -0,0 +1,101 @@ +#============================================================================= +# 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}/cmake/support_conda_env.cmake) + + +set(ENV{CONDA_BUILD} "1") +set(ENV{BUILD_PREFIX} "/usr/local/build_prefix") +set(ENV{target_platform} "linux-64") +set(ENV{PREFIX} "/opt/local/prefix") +set(ENV{CONDA_PREFIX} "/opt/conda/prefix") + +rapids_cmake_support_conda_env(conda_env) +if(NOT TARGET conda_env) + message(FATAL_ERROR "Expected target conda_env to exist") +endif() + +get_target_property(include_dirs conda_env INTERFACE_INCLUDE_DIRECTORIES) +if( NOT "$ENV{BUILD_PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Expected env{BUILD_PREFIX} to be in the include dirs of `conda_env`") +endif() +if( NOT "$ENV{PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Expected env{PREFIX} to be in the include dirs of `conda_env`") +endif() +if("$ENV{CONDA_PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Not expected for env{CONDA_PREFIX} to be in the include dirs of `conda_env`") +endif() + +get_target_property(link_dirs conda_env INTERFACE_LINK_DIRECTORIES) +if( NOT "$ENV{BUILD_PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Expected env{BUILD_PREFIX} to be in the link dirs of `conda_env`") +endif() +if( NOT "$ENV{PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Expected env{PREFIX} to be in the link dirs of `conda_env`") +endif() +if("$ENV{CONDA_PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Not expected for env{CONDA_PREFIX} to be in the link dirs of `conda_env`") +endif() + +get_target_property(link_options conda_env INTERFACE_LINK_OPTIONS) +message(STATUS "link_options: ${link_options}") +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{BUILD_PREFIX} to be in the link options of `conda_env`") +endif() +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{PREFIX} to be in the link options of `conda_env`") +endif() +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected rpath-link=env{PREFIX}/targets/x86_64-linux/ to be in the link options of `conda_env`") +endif() +if("$" IN_LIST link_options) + message(FATAL_ERROR "Not expected for rpath-link=env{CONDA_PREFIX} to be in the link options of `conda_env`") +endif() + +# No effect as the target already exists +set(before_call_value "$ENV{CMAKE_PREFIX_PATH}" ) +rapids_cmake_support_conda_env(conda_env MODIFY_PREFIX_PATH) +if(NOT ("${before_call_value}" STREQUAL "$ENV{CMAKE_PREFIX_PATH}") ) + message(FATAL_ERROR "Expected rapids_cmake_support_conda_env not to change ENV{CMAKE_PREFIX_PATH}") +endif() + +# New target being used, so this should modify ENV{CMAKE_PREFIX_PATH} +set(ENV{CMAKE_PREFIX_PATH} "placeholder" ) +rapids_cmake_support_conda_env(conda_env_modify MODIFY_PREFIX_PATH) +if(NOT TARGET conda_env_modify) + message(FATAL_ERROR "Expected target conda_env_modify to exist") +endif() + +cmake_path(CONVERT "$ENV{CMAKE_PREFIX_PATH}" TO_CMAKE_PATH_LIST env_cmake_prefix_path NORMALIZE) + +list(LENGTH env_cmake_prefix_path len) +if( len GREATER 4) + message(FATAL_ERROR "ENV{CMAKE_PREFIX_PATH} length is wrong after MODIFY_PREFIX_PATH") +endif() + +list(GET env_cmake_prefix_path 0 first_value) +list(GET env_cmake_prefix_path 1 second_value) +list(GET env_cmake_prefix_path 2 third_value) +list(GET env_cmake_prefix_path 3 fourth_value) +set(correct_list "placeholder" "$ENV{PREFIX}/targets/x86_64-linux" "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}") +set(actual_list "${first_value}" "${second_value}" "${third_value}" "${fourth_value}") + +foreach(correct actual IN ZIP_LISTS correct_list actual_list) + if(NOT correct STREQUAL actual) + message(STATUS "correct: ${correct}") + message(STATUS "actual: ${actual}") + message(FATAL_ERROR "MODIFY_PREFIX_PATH failed") + endif() +endforeach() diff --git a/testing/cmake/conda_env-cross-build-x86.cmake b/testing/cmake/conda_env-cross-build-x86.cmake index a8501f3c2..789d29a06 100644 --- a/testing/cmake/conda_env-cross-build-x86.cmake +++ b/testing/cmake/conda_env-cross-build-x86.cmake @@ -73,13 +73,14 @@ endif() # New target being used, so this should modify CMAKE_PREFIX_PATH set(CMAKE_PREFIX_PATH "placeholder" ) +set(ENV{CMAKE_PREFIX_PATH} "env_1:env_2" ) rapids_cmake_support_conda_env(conda_env_modify MODIFY_PREFIX_PATH) if(NOT TARGET conda_env_modify) message(FATAL_ERROR "Expected target conda_env_modify to exist") endif() list(LENGTH CMAKE_PREFIX_PATH len) -if( len GREATER 4) +if( len GREATER 6) message(FATAL_ERROR "CMAKE_PREFIX_PATH length is wrong after MODIFY_PREFIX_PATH") endif() @@ -87,8 +88,10 @@ list(GET CMAKE_PREFIX_PATH 0 first_value) list(GET CMAKE_PREFIX_PATH 1 second_value) list(GET CMAKE_PREFIX_PATH 2 third_value) list(GET CMAKE_PREFIX_PATH 3 fourth_value) -set(correct_list "$ENV{PREFIX}/targets/x86_64-linux" "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}" "placeholder") -set(actual_list "${first_value}" "${second_value}" "${third_value}" "${fourth_value}") +list(GET CMAKE_PREFIX_PATH 4 fifth_value) +list(GET CMAKE_PREFIX_PATH 5 sixth_value) +set(correct_list "placeholder" "env_1" "env_2" "$ENV{PREFIX}/targets/x86_64-linux" "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}") +set(actual_list "${first_value}" "${second_value}" "${third_value}" "${fourth_value}" "${fifth_value}" "${sixth_value}") foreach(correct actual IN ZIP_LISTS correct_list actual_list) if(NOT correct STREQUAL actual) diff --git a/testing/cmake/conda_env-prefix-envvar.cmake b/testing/cmake/conda_env-prefix-envvar.cmake new file mode 100644 index 000000000..e9cdf727d --- /dev/null +++ b/testing/cmake/conda_env-prefix-envvar.cmake @@ -0,0 +1,80 @@ +#============================================================================= +# 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}/cmake/support_conda_env.cmake) + +set(ENV{CONDA_BUILD} "2") +set(ENV{BUILD_PREFIX} "/usr/local/build_prefix") +set(ENV{PREFIX} "/opt/local/prefix") +set(ENV{CONDA_PREFIX} "/opt/conda/prefix") + +rapids_cmake_support_conda_env(conda_env) + +get_target_property(include_dirs conda_env INTERFACE_INCLUDE_DIRECTORIES) +if( "$ENV{BUILD_PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Not expected env{BUILD_PREFIX} to be in the include dirs of `conda_env`") +endif() +if( "$ENV{PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Not expected env{PREFIX} to be in the include dirs of `conda_env`") +endif() +if( NOT "$ENV{CONDA_PREFIX}/include" IN_LIST include_dirs) + message(FATAL_ERROR "Expected for env{CONDA_PREFIX} to be in the include dirs of `conda_env`") +endif() + +get_target_property(link_dirs conda_env INTERFACE_LINK_DIRECTORIES) +if( "$ENV{BUILD_PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Not expected env{BUILD_PREFIX} to be in the link dirs of `conda_env`") +endif() +if( "$ENV{PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Not expected env{PREFIX} to be in the link dirs of `conda_env`") +endif() +if( NOT "$ENV{CONDA_PREFIX}/lib" IN_LIST link_dirs) + message(FATAL_ERROR "Expected for env{CONDA_PREFIX} to be in the link dirs of `conda_env`") +endif() + +get_target_property(link_options conda_env INTERFACE_LINK_OPTIONS) +if( "$" IN_LIST link_options) + message(FATAL_ERROR "Not expected rpath-link=env{BUILD_PREFIX} to be in the link options of `conda_env`") +endif() +if( "$" IN_LIST link_options) + message(FATAL_ERROR "Not expected rpath-link=env{PREFIX} to be in the link options of `conda_env`") +endif() +if( NOT "$" IN_LIST link_options) + message(FATAL_ERROR "Expected for rpath-link=env{CONDA_PREFIX} to be in the link options of `conda_env`") +endif() + +set(ENV{CMAKE_PREFIX_PATH} "placeholder" ) +rapids_cmake_support_conda_env(conda_env_modify MODIFY_PREFIX_PATH) +if(NOT TARGET conda_env_modify) + message(FATAL_ERROR "Expected target conda_env_modify to exist") +endif() + +cmake_path(CONVERT "$ENV{CMAKE_PREFIX_PATH}" TO_CMAKE_PATH_LIST env_cmake_prefix_path NORMALIZE) + +list(LENGTH env_cmake_prefix_path len) +if( len GREATER 2) + message(FATAL_ERROR "ENV{CMAKE_PREFIX_PATH} length is wrong after MODIFY_PREFIX_PATH") +endif() + +list(GET env_cmake_prefix_path 0 first_value) +list(GET env_cmake_prefix_path 1 second_value) +set(correct_list "placeholder" "$ENV{CONDA_PREFIX}") +set(actual_list "${first_value}" "${second_value}") + +foreach(correct actual IN ZIP_LISTS correct_list actual_list) + if(NOT correct STREQUAL actual) + message(FATAL_ERROR "MODIFY_PREFIX_PATH failed") + endif() +endforeach() diff --git a/testing/cmake/conda_env-prefix.cmake b/testing/cmake/conda_env-prefix.cmake index de9fd914e..4c7a87951 100644 --- a/testing/cmake/conda_env-prefix.cmake +++ b/testing/cmake/conda_env-prefix.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-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. @@ -56,20 +56,23 @@ if( NOT "$" IN_LIST l endif() set(CMAKE_PREFIX_PATH "placeholder" ) +set(ENV{CMAKE_PREFIX_PATH} "env_1:env_2" ) rapids_cmake_support_conda_env(conda_env_modify MODIFY_PREFIX_PATH) if(NOT TARGET conda_env_modify) message(FATAL_ERROR "Expected target conda_env_modify to exist") endif() list(LENGTH CMAKE_PREFIX_PATH len) -if( len GREATER 2) +if( len GREATER 4) message(FATAL_ERROR "CMAKE_PREFIX_PATH length is wrong after MODIFY_PREFIX_PATH") endif() list(GET CMAKE_PREFIX_PATH 0 first_value) list(GET CMAKE_PREFIX_PATH 1 second_value) -set(correct_list "$ENV{CONDA_PREFIX}" "placeholder") -set(actual_list "${first_value}" "${second_value}") +list(GET CMAKE_PREFIX_PATH 2 third_value) +list(GET CMAKE_PREFIX_PATH 3 fourth_value) +set(correct_list "placeholder" "env_1" "env_2" "$ENV{CONDA_PREFIX}") +set(actual_list "${first_value}" "${second_value}" "${third_value}" "${fourth_value}") foreach(correct actual IN ZIP_LISTS correct_list actual_list) if(NOT correct STREQUAL actual) From c0f87827c7cb6d869664cbd0596c4a08bd7e5f53 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 21 Jul 2023 08:54:32 -0500 Subject: [PATCH 24/24] Remove trailing comma and add pre-commit hook for JSON validation. (#440) This PR fixes a trailing comma (invalid in JSON) that makes `versions.json` have invalid syntax, and adds a lightweight pre-commit hook to prevent this problem from happening again. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/rapids-cmake/pull/440 --- .pre-commit-config.yaml | 1 + rapids-cmake/cpm/versions.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 878a28114..96462e887 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,6 +14,7 @@ repos: (?x)^( ^rapids-cmake/cpm/patches/.* ) + - id: check-json - repo: https://github.com/pre-commit/mirrors-clang-format rev: v16.0.1 hooks: diff --git a/rapids-cmake/cpm/versions.json b/rapids-cmake/cpm/versions.json index 5b2cb573c..4d14321cd 100644 --- a/rapids-cmake/cpm/versions.json +++ b/rapids-cmake/cpm/versions.json @@ -36,7 +36,7 @@ "file" : "libcudacxx/reroot_support.diff", "issue" : "Support conda-forge usage of CMake rerooting [https://github.com/NVIDIA/libcudacxx/pull/490]", "fixed_in" : "2.2" - }, + } ] }, "nvbench" : {