repo_id
stringlengths
21
96
file_path
stringlengths
31
155
content
stringlengths
1
92.9M
__index_level_0__
int64
0
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm/patches
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm/patches/libcudacxx/install_rules.diff
diff --git a/cmake/libcudacxxInstallRules.cmake b/cmake/libcudacxxInstallRules.cmake index bd92a3be..f99a5606 100644 --- a/cmake/libcudacxxInstallRules.cmake +++ b/cmake/libcudacxxInstallRules.cmake @@ -28,10 +28,17 @@ install(DIRECTORY "${libcudacxx_SOURCE_DIR}/lib/cmake/libcudacxx" # Need to configure a file to store CMAKE_INSTALL_INCLUDEDIR # since it can be defined by the user. This is common to work around collisions # with the CTK installed headers. +set(install_location "${CMAKE_INSTALL_LIBDIR}/cmake/libcudacxx") +# Transform to a list of directories, replace each directory with "../" +# and convert back to a string +string(REGEX REPLACE "/" ";" from_install_prefix "${install_location}") +list(TRANSFORM from_install_prefix REPLACE ".+" "../") +list(JOIN from_install_prefix "" from_install_prefix) + configure_file("${libcudacxx_SOURCE_DIR}/lib/cmake/libcudacxx/libcudacxx-header-search.cmake.in" "${libcudacxx_BINARY_DIR}/lib/cmake/libcudacxx/libcudacxx-header-search.cmake" @ONLY ) install(FILES "${libcudacxx_BINARY_DIR}/lib/cmake/libcudacxx/libcudacxx-header-search.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/libcudacxx" + DESTINATION "${install_location}" ) diff --git a/lib/cmake/libcudacxx/libcudacxx-header-search.cmake.in b/lib/cmake/libcudacxx/libcudacxx-header-search.cmake.in index 9e7e187c..6130197f 100644 --- a/lib/cmake/libcudacxx/libcudacxx-header-search.cmake.in +++ b/lib/cmake/libcudacxx/libcudacxx-header-search.cmake.in @@ -1,8 +1,12 @@ # Parse version information from version header: unset(_libcudacxx_VERSION_INCLUDE_DIR CACHE) # Clear old result to force search + +# Find CMAKE_INSTALL_INCLUDEDIR=@CMAKE_INSTALL_INCLUDEDIR@ directory" +set(from_install_prefix "@from_install_prefix@") + find_path(_libcudacxx_VERSION_INCLUDE_DIR cuda/std/detail/__config NO_DEFAULT_PATH # Only search explicit paths below: PATHS - "${CMAKE_CURRENT_LIST_DIR}/../../../@CMAKE_INSTALL_INCLUDEDIR@" # Install tree + "${CMAKE_CURRENT_LIST_DIR}/${from_install_prefix}/@CMAKE_INSTALL_INCLUDEDIR@" # Install tree ) set_property(CACHE _libcudacxx_VERSION_INCLUDE_DIR PROPERTY TYPE INTERNAL)
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm/patches
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm/patches/fmt/no_debug_warnings.diff
diff --git a/include/fmt/core.h b/include/fmt/core.h index f6a37af..ffabe63 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -286,7 +286,7 @@ // Enable minimal optimizations for more compact code in debug mode. FMT_GCC_PRAGMA("GCC push_options") -#if !defined(__OPTIMIZE__) && !defined(__NVCOMPILER) +#if !defined(__OPTIMIZE__) && !defined(__NVCOMPILER) && !defined(__LCC__) && !defined(__CUDACC__) FMT_GCC_PRAGMA("GCC optimize(\"Og\")") #endif
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm/detail/generate_patch_command.cmake
#============================================================================= # Copyright (c) 2022, 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_cpm_generate_patch_command --------------------------------- .. versionadded:: v22.10.00 Applies any relevant patches to the provided CPM package .. code-block:: cmake rapids_cpm_generate_patch_command(<pkg> <version> patch_command) #]=======================================================================] # cmake-lint: disable=R0915,E1120 function(rapids_cpm_generate_patch_command package_name version patch_command) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.generate_patch_command") include("${rapids-cmake-dir}/cpm/detail/load_preset_versions.cmake") rapids_cpm_load_preset_versions() include("${rapids-cmake-dir}/cpm/detail/get_default_json.cmake") include("${rapids-cmake-dir}/cpm/detail/get_override_json.cmake") get_default_json(${package_name} json_data) get_override_json(${package_name} override_json_data) get_property(json_path GLOBAL PROPERTY rapids_cpm_${package_name}_json_file) get_property(override_json_path GLOBAL PROPERTY rapids_cpm_${package_name}_override_json_file) string(JSON json_data ERROR_VARIABLE no_default_patch GET "${json_data}" patches) string(JSON override_json_data ERROR_VARIABLE no_override_patch GET "${override_json_data}" patches) if(no_default_patch AND no_override_patch) return() # no patches endif() if(NOT no_override_patch) set(json_data "${override_json_data}") set(json_path "${override_json_path}") endif() # Need the current_json_dir variable populated before we parse any json entries so that we # properly evaluate this placeholder cmake_path(GET json_path PARENT_PATH current_json_dir) # Parse required fields function(rapids_cpm_json_get_value json_data_ name) string(JSON value ERROR_VARIABLE have_error GET "${json_data_}" ${name}) if(NOT have_error) set(${name} ${value} PARENT_SCOPE) endif() endfunction() # Need Git to apply the patches find_package(Git REQUIRED) if(NOT GIT_EXECUTABLE) message(WARNING "Unable to apply git patches to ${package_name}, git not found") return() endif() # Gather number of patches string(JSON patch_count LENGTH "${json_data}") math(EXPR patch_count "${patch_count} - 1") # For each project cache the subset of the json set(patch_files_to_run) set(patch_issues_to_ref) foreach(index RANGE ${patch_count}) string(JSON patch_data GET "${json_data}" ${index}) rapids_cpm_json_get_value(${patch_data} fixed_in) if(NOT fixed_in OR version VERSION_LESS fixed_in) rapids_cpm_json_get_value(${patch_data} file) rapids_cpm_json_get_value(${patch_data} issue) cmake_language(EVAL CODE "set(file ${file})") cmake_path(IS_RELATIVE file is_relative) if(is_relative) set(file "${rapids-cmake-dir}/cpm/patches/${file}") endif() list(APPEND patch_files_to_run "${file}") list(APPEND patch_issues_to_ref "${issue}") endif() endforeach() set(patch_script "${CMAKE_BINARY_DIR}/rapids-cmake/patches/${package_name}/patch.cmake") set(log_file "${CMAKE_BINARY_DIR}/rapids-cmake/patches/${package_name}/log") if(patch_files_to_run) configure_file(${rapids-cmake-dir}/cpm/patches/command_template.cmake.in "${patch_script}" @ONLY) set(${patch_command} ${CMAKE_COMMAND} -P ${patch_script} PARENT_SCOPE) else() # remove any old patch / log files that exist and are no longer needed due to a change in the # package version / version.json file(REMOVE "${patch_script}" "${log_file}") endif() endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm/detail/load_preset_versions.cmake
#============================================================================= # Copyright (c) 2021, 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_cpm_load_preset_versions ------------------------------- .. versionadded:: v21.10.00 Establish the `CPM` preset package information for the project. .. code-block:: cmake rapids_cpm_load_preset_versions() .. note:: Will be called by the first invocation of :cmake:command:`rapids_cpm_init` or :cmake:command:`rapids_cpm_<pkg>`. #]=======================================================================] function(rapids_cpm_load_preset_versions) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.load_preset_versions") # Check if we have been loaded before, if so early terminate get_property(already_loaded GLOBAL PROPERTY rapids_cpm_load_presets SET) if(already_loaded) return() endif() set_property(GLOBAL PROPERTY rapids_cpm_load_presets "ON") # Load our json files file(READ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../versions.json" json_data) # Determine all the projects that exist in the json file string(JSON package_count LENGTH "${json_data}" packages) math(EXPR package_count "${package_count} - 1") # For each project cache the subset of the json for that project in a global property # cmake-lint: disable=E1120 foreach(index RANGE ${package_count}) string(JSON package_name MEMBER "${json_data}" packages ${index}) string(JSON data GET "${json_data}" packages "${package_name}") set_property(GLOBAL PROPERTY rapids_cpm_${package_name}_json "${data}") set_property(GLOBAL PROPERTY rapids_cpm_${package_name}_json_file "${filepath}") endforeach() endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm/detail/download.cmake
#============================================================================= # 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. # 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_cpm_download ------------------- .. versionadded:: v21.10.00 Does the downloading of the `CPM` module .. code-block:: cmake rapids_cpm_download() The CPM module will be downloaded based on the state of :cmake:variable:`CPM_SOURCE_CACHE` and :cmake:variable:`ENV{CPM_SOURCE_CACHE}`. .. note:: Use `rapids_cpm_init` instead of this function, as this is an implementation detail required for proper cpm project exporting in build directories This function can't call other rapids-cmake functions, due to the restrictions of `write_dependencies.cmake` #]=======================================================================] function(rapids_cpm_download) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.download") # When changing version verify no new variables needs to be propagated set(CPM_DOWNLOAD_VERSION 0.38.5) set(CPM_DOWNLOAD_MD5_HASH c98d14a13dfd1952e115979c095f6794) if(CPM_SOURCE_CACHE) # Expand relative path. This is important if the provided path contains a tilde (~) cmake_path(ABSOLUTE_PATH CPM_SOURCE_CACHE) # default to the same location that cpm computes set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") if(EXISTS "${CPM_SOURCE_CACHE}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") # Also support the rapids-cmake download location ( cmake/ vs cpm/ ) set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") endif() elseif(DEFINED ENV{CPM_SOURCE_CACHE}) # default to the same location that cpm computes set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") if(EXISTS "$ENV{CPM_SOURCE_CACHE}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") # Also support the rapids-cmake download location ( cmake/ vs cpm/ ) set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") endif() else() set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") endif() if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) message(VERBOSE "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ${CPM_DOWNLOAD_LOCATION} LOG download_log) file(MD5 ${CPM_DOWNLOAD_LOCATION} cpm_hash) if(NOT cpm_hash STREQUAL CPM_DOWNLOAD_MD5_HASH) message(FATAL_ERROR "CPM.cmake hash mismatch [got=${cpm_hash} expected=${CPM_DOWNLOAD_MD5_HASH}] to download details below\n ${download_log}" ) endif() endif() include(${CPM_DOWNLOAD_LOCATION}) # Propagate up any modified local variables that CPM has changed. # # Push up the modified CMAKE_MODULE_PATh to allow `find_package` calls to find packages that CPM # already added. set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE) endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm/detail/get_proprietary_binary_url.cmake
#============================================================================= # 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_cpm_get_proprietary_binary_url ------------------- .. versionadded:: v23.04.00 Generated the url for the associated proprietary binary for the given project based on the current CPU target architecture ( x86_64, aarch64, etc ) .. note:: if override => the proprietary entry only in the override will be evaluated if no override => the proprietary entry only in the default will be evaluated #]=======================================================================] function(rapids_cpm_get_proprietary_binary_url package_name version url_var) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.rapids_cpm_get_proprietary_binary_url") include("${rapids-cmake-dir}/cpm/detail/get_default_json.cmake") include("${rapids-cmake-dir}/cpm/detail/get_override_json.cmake") get_default_json(${package_name} json_data) get_override_json(${package_name} override_json_data) # need to search the `proprietary_binary` dictionary for a key with the same name as # lower_case(`CMAKE_SYSTEM_PROCESSOR-CMAKE_SYSTEM_NAME`). set(key "${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM_NAME}") string(TOLOWER ${key} key) if(override_json_data) string(JSON proprietary_binary ERROR_VARIABLE have_error GET "${override_json_data}" "proprietary_binary" "${key}") else() string(JSON proprietary_binary ERROR_VARIABLE have_error GET "${json_data}" "proprietary_binary" "${key}") endif() if(have_error) message(VERBOSE "${package_name} requested usage of a proprietary_binary but none exist for ${CMAKE_SYSTEM_PROCESSOR}" ) return() endif() if(NOT DEFINED rapids-cmake-version) include("${rapids-cmake-dir}/rapids-version.cmake") endif() # Determine the CUDA Toolkit version so that we properly evaluate the placeholders in # `proprietary_binary` if(proprietary_binary MATCHES "{cuda-toolkit-version") find_package(CUDAToolkit REQUIRED) set(cuda-toolkit-version ${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}) set(cuda-toolkit-version-major ${CUDAToolkit_VERSION_MAJOR}) endif() # Evaluate any magic placeholders in the proprietary_binary value including the # `rapids-cmake-version` value cmake_language(EVAL CODE "set(proprietary_binary ${proprietary_binary})") # Tell the caller what the URL will be for this binary set(${url_var} "${proprietary_binary}" PARENT_SCOPE) endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm/detail/get_default_json.cmake
#============================================================================= # Copyright (c) 2021, 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: get_default_json -------------------------- . code-block:: cmake get_default_json(package_name output_variable) #]=======================================================================] function(get_default_json package_name output_variable) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.get_default_json") get_property(json_data GLOBAL PROPERTY rapids_cpm_${package_name}_json) set(${output_variable} "${json_data}" PARENT_SCOPE) endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm/detail/download_proprietary_binary.cmake
#============================================================================= # 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: download_proprietary_binary ------------------- .. versionadded:: v23.04.00 Download the associated proprietary binary from the providied URL and make it part of the project with `FetchContent_MakeAvailable` #]=======================================================================] function(rapids_cpm_download_proprietary_binary package_name url) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.rapids_cpm_download_proprietary_binary") # download and extract the binaries since they don't exist on the machine include(FetchContent) set(pkg_name "${package_name}_proprietary_binary") if(POLICY CMP0135) cmake_policy(SET CMP0135 NEW) set(CMAKE_POLICY_DEFAULT_CMP0135 NEW) endif() FetchContent_Declare(${pkg_name} URL ${url}) FetchContent_MakeAvailable(${pkg_name}) # Tell the subsequent rapids_cpm_find where to search so that it uses this binary set(${package_name}_ROOT "${${pkg_name}_SOURCE_DIR}" PARENT_SCOPE) set(${package_name}_proprietary_binary ON PARENT_SCOPE) endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm/detail/get_override_json.cmake
#============================================================================= # Copyright (c) 2021, 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: get_override_json -------------------------- . code-block:: cmake get_override_json(package_name output_variable) #]=======================================================================] function(get_override_json package_name output_variable) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.get_override_json") get_property(json_data GLOBAL PROPERTY rapids_cpm_${package_name}_override_json) set(${output_variable} "${json_data}" PARENT_SCOPE) endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm/detail/package_details.cmake
#============================================================================= # 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. # 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_cpm_package_details -------------------------- . code-block:: cmake rapids_cpm_package_details(<package_name> <version_variable> <git_url_variable> <git_tag_variable> <shallow_variable> <exclude_from_all_variable> ) 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,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") include("${rapids-cmake-dir}/cpm/detail/load_preset_versions.cmake") rapids_cpm_load_preset_versions() include("${rapids-cmake-dir}/cpm/detail/get_default_json.cmake") include("${rapids-cmake-dir}/cpm/detail/get_override_json.cmake") get_default_json(${package_name} json_data) get_override_json(${package_name} override_json_data) # Parse required fields function(rapids_cpm_json_get_value name) string(JSON value ERROR_VARIABLE have_error GET "${override_json_data}" ${name}) if(have_error) string(JSON value ERROR_VARIABLE have_error GET "${json_data}" ${name}) endif() if(NOT have_error) set(${name} ${value} PARENT_SCOPE) endif() endfunction() rapids_cpm_json_get_value(version) rapids_cpm_json_get_value(git_url) rapids_cpm_json_get_value(git_tag) if(override_json_data) string(JSON value ERROR_VARIABLE no_url_override GET "${override_json_data}" git_url) string(JSON value ERROR_VARIABLE no_tag_override GET "${override_json_data}" git_tag) string(JSON value ERROR_VARIABLE no_patches_override GET "${override_json_data}" patches) set(git_details_overridden TRUE) if(no_url_override AND no_tag_override AND no_patches_override) set(git_details_overridden FALSE) endif() endif() # Parse optional fields, set the variable to the 'default' value first set(git_shallow ON) rapids_cpm_json_get_value(git_shallow) set(exclude_from_all OFF) rapids_cpm_json_get_value(exclude_from_all) set(always_download OFF) if(override_json_data AND json_data AND git_details_overridden) # `always_download` default value requires the package to exist in both the default and override # and that the git url / git tag have been modified. set(always_download ON) endif() rapids_cpm_json_get_value(always_download) # Evaluate any magic placeholders in the version or tag components including the # `rapids-cmake-version` value if(NOT DEFINED rapids-cmake-version) include("${rapids-cmake-dir}/rapids-version.cmake") endif() cmake_language(EVAL CODE "set(version ${version})") cmake_language(EVAL CODE "set(git_tag ${git_tag})") set(${version_var} ${version} PARENT_SCOPE) set(${url_var} ${git_url} PARENT_SCOPE) set(${tag_var} ${git_tag} PARENT_SCOPE) 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() endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm
rapidsai_public_repos/rapids-cmake/rapids-cmake/cpm/detail/display_patch_status.cmake
#============================================================================= # Copyright (c) 2022, 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_cpm_display_patch_status ------------------------------- .. versionadded:: v22.10.00 Displays the result of any patches applied to the requested package .. code-block:: cmake rapids_cpm_display_patch_status(<pkg>) #]=======================================================================] function(rapids_cpm_display_patch_status package_name) # Only display the status information on the first execution of the call if(${package_name}_ADDED) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.display_patch_status") set(log_file "${CMAKE_BINARY_DIR}/rapids-cmake/patches/${package_name}/log") if(EXISTS "${log_file}") file(STRINGS "${log_file}" contents) foreach(line IN LISTS contents) message(STATUS "${line}") endforeach() endif() endif() endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/cpm.cmake
#============================================================================= # 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. # 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_export_cpm ----------------- .. versionadded:: v21.06.00 Record a given <PackageName> found by `CPMFindPackage` is required for a given export set .. code-block:: cmake rapids_export_cpm( (BUILD|INSTALL) <PackageName> <ExportSet> CPM_ARGS <standard cpm args> [GLOBAL_TARGETS <targets...>] ) Records a given <PackageName> found by `CPMFindPackage` is required for a given export set. When the associated :cmake:command:`rapids_export(BUILD|INSTALL)` or :cmake:command:`rapids_export_write_dependencies(BUILD|INSTALL)` command is invoked the generated information will include a :cmake:command:`CPMFindPackage` call for <PackageName>. ``BUILD`` Will record <PackageName> is part of the build directory export set ``INSTALL`` Will record <PackageName> is part of the build directory export set .. note:: It is an anti-pattern to use this command with `INSTALL` as most CMake based projects should be installed, and :cmake:command:`rapids_export_package(INSTALL` used to find it. Only use :cmake:command:`rapids_export_cpm(INSTALL` when the above pattern doesn't work for some reason. #]=======================================================================] function(rapids_export_cpm type name export_set) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.export.cpm") string(TOLOWER ${type} type) set(options "") set(one_value EXPORT_SET) set(multi_value GLOBAL_TARGETS CPM_ARGS) cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) if(type STREQUAL build) if(DEFINED ${name}_DIR AND ${name}_DIR) # Export out where we found the existing local config module set(possible_dir "${${name}_DIR}") else() # Export out the build-dir in case it has build directory find-package support set(possible_dir "${${name}_BINARY_DIR}") endif() endif() configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/cpm.cmake.in" "${CMAKE_BINARY_DIR}/rapids-cmake/${export_set}/${type}/cpm_${name}.cmake" @ONLY) if(NOT TARGET rapids_export_${type}_${export_set}) add_library(rapids_export_${type}_${export_set} INTERFACE) endif() # Record that we need CPM injected into the export set set_property(TARGET rapids_export_${type}_${export_set} PROPERTY "REQUIRES_CPM" TRUE) # Need to record the <PackageName> to `rapids_export_${type}_${export_set}` set_property(TARGET rapids_export_${type}_${export_set} APPEND PROPERTY "PACKAGE_NAMES" "${name}") if(_RAPIDS_GLOBAL_TARGETS) # record our targets that need to be marked as global when imported set_property(TARGET rapids_export_${type}_${export_set} APPEND PROPERTY "GLOBAL_TARGETS" "${_RAPIDS_GLOBAL_TARGETS}") endif() endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/find_package_root.cmake
#============================================================================= # 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. # 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_export_find_package_root ------------------------------- .. versionadded:: v21.10.00 Record that for <PackageName> to be found correctly, the :cmake:variable:`<PackageName>_ROOT_DIR` needs to be set to the provided path. .. code-block:: cmake rapids_export_find_package_root( (BUILD|INSTALL) <PackageName> <directory_path> (<ExportSetName> | EXPORT_SET [ExportSetName]) [CONDITION <variableName>] ) When constructing complicated export sets, espically ones that install complicated dependencies it can be necessary to specify :cmake:variable:`PackageName_ROOT` so that we are sure we will find the packaged dependency. ``BUILD`` Record that the `PackageName_ROOT` will be set to <directory_path> before any find_dependency calls for `PackageName` for our build directory export set. ``INSTALL`` Record that the `PackageName_ROOT` will be set to <directory_path> before any find_dependency calls for `PackageName` for our install directory export set. ``EXPORT_SET`` List the export set name that the `directory_path` should be attached too. If no name is given the associated call will be ignored. ``CONDITION`` A boolean variable name, that when evaluates to undefined or a false value will cause the associated call to be ignored. #]=======================================================================] function(rapids_export_find_package_root type name dir_path) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.export.find_package_root_dir") include("${rapids-cmake-dir}/cmake/detail/policy.cmake") set(options "") set(one_value EXPORT_SET CONDITION) set(multi_value "") cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) # handle when we are given just an export set name and not `EXPORT_SET <name>` if(_RAPIDS_UNPARSED_ARGUMENTS AND NOT _RAPIDS_COMPONENTS_EXPORT_SET) rapids_cmake_policy(DEPRECATED_IN 23.12 REMOVED_IN 24.02 MESSAGE [=[Usage of `rapids_export_find_package_root` without an explicit `EXPORT_SET` key has been deprecated.]=] ) set(_RAPIDS_EXPORT_SET ${_RAPIDS_UNPARSED_ARGUMENTS}) endif() # Early terminate conditions if(NOT _RAPIDS_EXPORT_SET OR NOT ${_RAPIDS_CONDITION}) return() endif() string(TOLOWER ${type} type) set(export_set ${_RAPIDS_EXPORT_SET}) if(NOT TARGET rapids_export_${type}_${export_set}) add_library(rapids_export_${type}_${export_set} INTERFACE) endif() # Don't remove duplicates here as that cost should only be paid Once per export set. So that # should occur in `write_dependencies` set_property(TARGET rapids_export_${type}_${export_set} APPEND PROPERTY "FIND_ROOT_PACKAGES" ${name}) set_property(TARGET rapids_export_${type}_${export_set} APPEND PROPERTY "FIND_ROOT_FOR_${name}" ${dir_path}) endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/write_language.cmake
#============================================================================= # 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. # 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_export_write_language ---------------------------- .. versionadded:: v21.06.00 Creates a self-contained file that makes sure the requested language is enabled globally. .. code-block:: cmake rapids_export_write_language( (BUILD|INSTALL) (CXX|CUDA|...) <file_path> ) The contents of `<file_path>` will be a self-contained file that when called via :cmake:command:`include <cmake:command:include>` will make sure the requested language is enabled globally. This is required as CMake's :cmake:command:`enable_language <cmake:command:enable_language>` only supports enabling languages for the current directory scope, and doesn't support being called from within functions. These limitations make it impossible for packages included via `CPM` to enable extra languages. .. note:: This uses some serious CMake black magic to make sure that :cmake:command:`enable_language <cmake:command:enable_language>` occurs both at the call site, and up the entire :cmake:command:`enable_language <cmake:command:add_subdirectory>` stack so the language is enabled globally. #]=======================================================================] function(rapids_export_write_language type lang file_path) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.export.write_language") set(code_to_inject [=[ # Enable the requested language, which is only supported # in the highest directory that 'uses' a language. # We have to presume all directories use a language # since linking to a target with language standards # means `using` if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) if(NOT DEFINED CMAKE_CURRENT_FUNCTION) #Can't be called inside a function enable_language(@lang@) return() endif() endif() # If we aren't in the highest directory we need to hoist up # all the language information to trick CMake into thinking # the correct things happened. # `cmake_langauge(DEFER )` doesn't support calling `enable_language` # so we have to emulate what it does. # # So what we need to do is the following: # # 1. Transform each `set` in CMake@lang@Compiler to be a `PARENT_SCOPE` # This allows us to propagate up immediate information that is # used by commands such target_compile_features. # # 2. Make sure that every directory including root also re-executes # `CMake@lang@Information` This can't be deferred as the contents # are required if any target is constructed # # Expose the language at the current scope enable_language(@lang@) if(NOT EXISTS "${CMAKE_BINARY_DIR}/cmake/PropagateCMake@[email protected]") # 1. # Take everything that `enable_language` generated and transform all sets to PARENT_SCOPE () # This will allow our parent directory to be able to call CMake@lang@Information file(STRINGS "${CMAKE_BINARY_DIR}/CMakeFiles/${CMAKE_VERSION}/CMake@[email protected]" rapids_code_to_transform) set(rapids_code_to_execute ) foreach( line IN LISTS rapids_code_to_transform) if(line MATCHES "[ ]*set") string(REPLACE ")" " PARENT_SCOPE)" line "${line}") endif() string(APPEND rapids_code_to_execute "${line}\n") endforeach() # 2. # Make sure we call "CMake@lang@Information" for the current directory string(APPEND rapids_code_to_execute "include(CMake@lang@Information)\n") file(WRITE "${CMAKE_BINARY_DIR}/cmake/PropagateCMake@[email protected]" "${rapids_code_to_execute}") unset(rapids_code_to_execute) unset(rapids_code_to_transform) endif() # propagate up one parent_scope include("${CMAKE_BINARY_DIR}/cmake/PropagateCMake@[email protected]") # Compute all directories between here and the root of the project # - Each directory but the root needs to include `PropagateCMake@[email protected]` # - Since the root directory doesn't have a parent it only needs to include # `CMake@lang@Information` set(rapids_directory "${CMAKE_CURRENT_SOURCE_DIR}") if(DEFINED CMAKE_CURRENT_FUNCTION) string(APPEND rapids_directory "/fake_dir") endif() set(rapids_root_directory "${CMAKE_SOURCE_DIR}") cmake_path(GET rapids_directory PARENT_PATH rapids_directory) while(NOT rapids_directory STREQUAL rapids_root_directory) # Make sure we haven't already installed a language hook for this directory # Once we found a directory with an existing hook we can safely stop # as that means hooks exist from that point up in the graph cmake_language(DEFER DIRECTORY "${rapids_directory}" GET_CALL_IDS rapids_existing_calls) if(NOT rapids_@lang@_hook IN_LIST rapids_existing_calls) cmake_language(DEFER DIRECTORY "${rapids_directory}" ID rapids_@lang@_hook CALL include "${CMAKE_BINARY_DIR}/cmake/PropagateCMake@[email protected]") else() break() endif() cmake_path(GET rapids_directory PARENT_PATH rapids_directory) endwhile() # Make sure we haven't already installed a language hook for this directory cmake_language(DEFER DIRECTORY "${CMAKE_SOURCE_DIR}" GET_CALL_IDS rapids_existing_calls) if(NOT rapids_@lang@_hook IN_LIST rapids_existing_calls) cmake_language(DEFER DIRECTORY "${CMAKE_SOURCE_DIR}" ID rapids_@lang@_hook CALL include "CMake@lang@Information") endif() unset(rapids_existing_calls) unset(rapids_directory) unset(rapids_root_directory) ]=]) string(CONFIGURE "${code_to_inject}" code_to_inject @ONLY) file(WRITE "${file_path}" "${code_to_inject}") endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/export.cmake
#============================================================================= # 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. # 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_export --------------------- .. versionadded:: v21.06.00 Generate a projects -Config.cmake module and all related information .. code-block:: cmake rapids_export( (BUILD|INSTALL) <project_name> EXPORT_SET <export_set> [ GLOBAL_TARGETS <targets...> ] [ COMPONENTS <components...> ] [ COMPONENTS_EXPORT_SET <component 1 export set, component 2 export set...> ] [ VERSION <X.Y.Z> ] [ NAMESPACE <name_space> ] [ DOCUMENTATION <doc_variable> ] [ FINAL_CODE_BLOCK <code_block_variable> ] [ LANGUAGES <langs...> ] ) The :cmake:command:`rapids_export` function allow projects to easily generate a fully correct build and install tree `Project-Config.cmake` module including any necessary calls to :cmake:command:`find_dependency`, or :cmake:command:`CPMFindPackage`. .. note:: The files generated by :cmake:command:`rapids_export` are completely standalone and don't require the consuming package to use `rapids-cmake` ``project_name`` Name of the project, to be used by consumers when using `find_package` ``GLOBAL_TARGETS`` Explicitly list what targets should be made globally visible to the consuming project. ``COMPONENTS`` .. versionadded:: v23.04.00 A list of the optional `COMPONENTS` that are offered by this exported package. The names listed here will be what consumers calling :cmake:command:`find_package` will use to enable these components. For each entry in `COMPONENTS` it is required to have an entry in `COMPONENTS_EXPORT_SET` at the same positional location. .. code-block:: cmake rapids_export(BUILD example EXPORT_SET example-targets COMPONENTS A B COMPONENTS A-export B-export ) This is needed so that :cmake:command:`rapids_export` can correctly establish the dependency and import target information for each component. ``COMPONENTS_EXPORT_SET`` .. versionadded:: v23.04.00 A list of the associated export set for each optional `COMPONENT`. Each entry in `COMPONENTS_EXPORT_SET` is associated to the component as the same position in the `COMPONENTS` list. ``VERSION`` Explicitly list the version of the package being exported. By default :cmake:command:`rapids_export` uses the version specified by the root level :cmake:command:`project <cmake:command:project>` call. If no version has been specified either way or `OFF` is provided as the `VERSION` value, no version compatibility checks will be generated. Depending on the version string different compatibility modes will be used. +------------------+---------------------+ | Version String | Compatibility Type | +==================+=====================+ | None | No checks performed | +------------------+---------------------+ | X | SameMajorVersion | +------------------+---------------------+ | X.Y | SameMinorVersion | +------------------+---------------------+ | X.Y.Z | SameMinorVersion | +------------------+---------------------+ .. note:: It can be useful to explicitly specify a version string when generating export rules for a sub-component of alarger project, or an external project that doesn't have export rules. ``NAMESPACE`` Optional value to specify what namespace all targets from the EXPORT_SET will be placed into. When provided must match the pattern of `<name>::`. A recommended namespace could be `<project_name>::`. If not provided, no namespace is used. 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 <cmake:prop_tgt:EXPORT_NAME>` property. ``DOCUMENTATION`` Optional value of the variable that holds the documentation for this config file. Note: This requires the documentation variable instead of the contents so we can handle having CMake code inside the documentation ``FINAL_CODE_BLOCK`` Optional value of the variable that holds a string of code that will be executed at 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 ``LANGUAGES`` Non default languages, such as CUDA that are required by consumers of your package. This makes sure all consumers properly setup these languages correctly. This is required as CMake's :cmake:command:`enable_language <cmake:command:enable_language>` only supports enabling languages for the current directory scope, and doesn't support being called from within functions. Marking languages here overcomes these limitations and makes it possible for packages included via `CPM` to enable languages. Example on how to properly use :cmake:command:`rapids_export`: .. code-block:: cmake ... add_library(example STATIC source.cu) target_compile_features(example PUBLIC $<BUILD_INTERFACE:cuda_std_17>) rapids_cmake_install_lib_dir(lib_dir) install(TARGETS example DESTINATION ${lib_dir} EXPORT example-targets ) set(doc_string [=[Provide targets for the example library.]=]) set(code_string [=[ message(STATUS "hi from example-config")]=]) rapids_export(INSTALL example EXPORT_SET example-targets GLOBAL_TARGETS example # Need to list all targets from `install(TARGETS` NAMESPACE example:: DOCUMENTATION doc_string FINAL_CODE_BLOCK code_string ) rapids_export(BUILD example EXPORT_SET example-targets GLOBAL_TARGETS example # Need to list all targets from `install(TARGETS` # CUDA language support is a build detail only, as target_compile_features # guards the language behind `BUILD_INTERFACE` generator expression LANGUAGES CUDA NAMESPACE example:: DOCUMENTATION doc_string FINAL_CODE_BLOCK code_string ) #]=======================================================================] # cmake-lint: disable=R0912,R0915,W0105 function(rapids_export type project_name) include(CMakePackageConfigHelpers) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.export.export") string(TOLOWER ${type} type) set(project_name_orig ${project_name}) string(TOLOWER ${project_name} project_name) string(TOUPPER ${project_name} project_name_uppercase) set(options "") set(one_value EXPORT_SET VERSION NAMESPACE DOCUMENTATION FINAL_CODE_BLOCK) set(multi_value GLOBAL_TARGETS COMPONENTS COMPONENTS_EXPORT_SET LANGUAGES) cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) set(rapids_version_set ON) if(DEFINED _RAPIDS_VERSION AND NOT _RAPIDS_VERSION) # We need to capture `VERSION OFF` so we need to make sure it has an off value, and not just # undefined set(rapids_version_set OFF) unset(_RAPIDS_VERSION) # unset this so we don't export a version value of `OFF` elseif(NOT DEFINED _RAPIDS_VERSION AND NOT DEFINED PROJECT_VERSION) set(rapids_version_set OFF) elseif(DEFINED PROJECT_VERSION AND NOT DEFINED _RAPIDS_VERSION) # Choose the project version when an explicit version isn't provided set(_RAPIDS_VERSION "${PROJECT_VERSION}") endif() if(rapids_version_set) include("${rapids-cmake-dir}/export/detail/parse_version.cmake") rapids_export_parse_version(${_RAPIDS_VERSION} rapids_orig rapids_project_version) endif() 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) message(FATAL_ERROR "rapids_export(${type} ${project_name} is missing COMPONENTS_EXPORT_SET as COMPONENTS was provided." ) endif() if(_RAPIDS_COMPONENTS_EXPORT_SET AND NOT _RAPIDS_COMPONENTS) message(FATAL_ERROR "rapids_export(${type} ${project_name} is missing COMPONENTS as COMPONENTS_EXPORT_SET was provided." ) endif() if(_RAPIDS_COMPONENTS AND _RAPIDS_COMPONENTS_EXPORT_SET) include("${rapids-cmake-dir}/export/detail/component.cmake") set(_RAPIDS_HAS_COMPONENTS TRUE) foreach(comp comp_export_set IN ZIP_LISTS _RAPIDS_COMPONENTS _RAPIDS_COMPONENTS_EXPORT_SET) string(REGEX REPLACE "(${project_name}[-_])|([-_]?${comp}[-_]?)|([-_]?export[s]?)" "" nice_export_name "${comp_export_set}") if(nice_export_name STREQUAL "") string(PREPEND nice_export_name "${comp}") 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_COMPONENT_NAMESPACE}") endforeach() endif() set(_RAPIDS_PROJECT_DOCUMENTATION "Generated ${project_name}-config module") if(DEFINED _RAPIDS_DOCUMENTATION) if(NOT DEFINED ${_RAPIDS_DOCUMENTATION}) message(FATAL_ERROR "DOCUMENTATION variable `${_RAPIDS_DOCUMENTATION}` doesn't exist") endif() set(_RAPIDS_PROJECT_DOCUMENTATION "${${_RAPIDS_DOCUMENTATION}}") 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_PROJECT_FINAL_CODE_BLOCK "${${_RAPIDS_FINAL_CODE_BLOCK}}") endif() # Write configuration and version files if(type STREQUAL "install") include("${rapids-cmake-dir}/cmake/install_lib_dir.cmake") rapids_cmake_install_lib_dir(install_location) set(install_location "${install_location}/cmake/${project_name}") set(scratch_dir "${PROJECT_BINARY_DIR}/rapids-cmake/${project_name}/export/${project_name}") configure_package_config_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/config.cmake.in" "${scratch_dir}/${project_name}-config.cmake" INSTALL_DESTINATION "${install_location}") if(rapids_version_set) write_basic_package_version_file( "${scratch_dir}/${project_name}-config-version.cmake" VERSION ${rapids_project_version} COMPATIBILITY ${rapids_project_version_compat}) endif() 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") set(destination "${scratch_dir}/${project_name}-dependencies.cmake") rapids_export_write_dependencies(INSTALL ${_RAPIDS_EXPORT_SET} "${destination}") endif() if(DEFINED _RAPIDS_LANGUAGES) include("${rapids-cmake-dir}/export/write_language.cmake") foreach(lang IN LISTS _RAPIDS_LANGUAGES) set(destination "${scratch_dir}/${project_name}-${lang}-language.cmake") rapids_export_write_language(INSTALL ${lang} "${destination}") endforeach() endif() # Install everything we have generated install(DIRECTORY "${scratch_dir}/" DESTINATION "${install_location}" COMPONENT ${project_name}) else() set(install_location "${PROJECT_BINARY_DIR}") configure_package_config_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/config.cmake.in" "${install_location}/${project_name}-config.cmake" INSTALL_DESTINATION "${install_location}") if(rapids_version_set) write_basic_package_version_file( "${install_location}/${project_name}-config-version.cmake" VERSION ${rapids_project_version} COMPATIBILITY ${rapids_project_version_compat}) endif() 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") rapids_export_write_dependencies(BUILD ${_RAPIDS_EXPORT_SET} "${install_location}/${project_name}-dependencies.cmake") endif() if(DEFINED _RAPIDS_LANGUAGES) include("${rapids-cmake-dir}/export/write_language.cmake") foreach(lang IN LISTS _RAPIDS_LANGUAGES) rapids_export_write_language(BUILD ${lang} "${install_location}/${project_name}-${lang}-language.cmake") endforeach() endif() endif() endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/write_dependencies.cmake
#============================================================================= # 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. # 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_export_write_dependencies -------------------------------- .. versionadded:: v21.06.00 .. code-block:: cmake Creates a self-contained file that searches for all dependencies for a given export set. rapids_export_write_dependencies( (BUILD|INSTALL) <export_set> <file_path> ) Generates a self-contained file that will search for all dependencies of a given export_set for the requested mode. ``BUILD`` Will generate calls for all build directory export set ``INSTALL`` Will generate calls for all install directory export set .. note:: It is better to use :cmake:command:`rapids_export` as it generates a complete CMake config module. #]=======================================================================] # cmake-lint: disable=R0915 function(rapids_export_write_dependencies type export_set file_path) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.export.write_dependencies") string(TOLOWER ${type} type) if(NOT TARGET rapids_export_${type}_${export_set}) return() endif() # Determine if we need have any `ROOT_DIR` variables we need to set. get_property(find_root_dirs TARGET rapids_export_${type}_${export_set} PROPERTY "FIND_ROOT_PACKAGES") list(REMOVE_DUPLICATES find_root_dirs) # Determine if we need have any `FindModules` that we need to package. get_property(find_modules TARGET rapids_export_${type}_${export_set} PROPERTY "FIND_PACKAGES_TO_INSTALL") list(REMOVE_DUPLICATES find_modules) # Determine if we need to inject CPM hooks get_property(uses_cpm TARGET rapids_export_${type}_${export_set} PROPERTY "REQUIRES_CPM") list(REMOVE_DUPLICATES uses_cpm) # Collect all `find_dependency` calls. Order is important here As this is the order they are # recorded which is the implied valid search order get_property(deps TARGET rapids_export_${type}_${export_set} PROPERTY "PACKAGE_NAMES") list(REMOVE_DUPLICATES deps) # Do we need a Template header? set(_RAPIDS_EXPORT_CONTENTS) if(uses_cpm) file(READ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../cpm/detail/download.cmake" cpm_logic) string(APPEND _RAPIDS_EXPORT_CONTENTS ${cpm_logic}) string(APPEND _RAPIDS_EXPORT_CONTENTS "rapids_cpm_download()\n\n") if(type STREQUAL build) string(APPEND _RAPIDS_EXPORT_CONTENTS "# re-use our CPM source cache if not set if(NOT DEFINED CPM_SOURCE_CACHE) set(CPM_SOURCE_CACHE \"@CPM_SOURCE_CACHE@\") set(rapids_clear_cpm_cache true) endif()\n") endif() endif() foreach(package IN LISTS find_root_dirs) get_property(root_dir_path TARGET rapids_export_${type}_${export_set} PROPERTY "FIND_ROOT_FOR_${package}") set(dep_content "set(${package}_ROOT \"${root_dir_path}\")") string(APPEND _RAPIDS_EXPORT_CONTENTS "${dep_content}\n") endforeach() if(find_modules) cmake_path(GET file_path PARENT_PATH find_module_dest) file(COPY ${find_modules} DESTINATION "${find_module_dest}") string(APPEND _RAPIDS_EXPORT_CONTENTS [=[list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")]=] "\n") endif() set(dep_dir "${CMAKE_BINARY_DIR}/rapids-cmake/${export_set}/${type}") foreach(dep IN LISTS deps) # We need inject the contents of this generated file into the file we are writing out. That way # users can re-locate/install the file and it will still work if(EXISTS "${dep_dir}/cpm_${dep}.cmake") # CPM recording takes priority over a find_package() recording file(READ "${dep_dir}/cpm_${dep}.cmake" dep_content) elseif(EXISTS "${dep_dir}/package_${dep}.cmake") file(READ "${dep_dir}/package_${dep}.cmake" dep_content) endif() string(APPEND _RAPIDS_EXPORT_CONTENTS "${dep_content}\n") get_property(post_find_code TARGET rapids_export_${type}_${export_set} PROPERTY "${dep}_POST_FIND_CODE") if(post_find_code) string(APPEND _RAPIDS_EXPORT_CONTENTS "if(${dep}_FOUND)\n${post_find_code}\nendif()\n") endif() endforeach() string(APPEND _RAPIDS_EXPORT_CONTENTS "\n") # Handle promotion to global targets get_property(global_targets TARGET rapids_export_${type}_${export_set} PROPERTY "GLOBAL_TARGETS") list(REMOVE_DUPLICATES global_targets) string(APPEND _RAPIDS_EXPORT_CONTENTS "set(rapids_global_targets ${global_targets})\n") configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/dependencies.cmake.in" "${file_path}" @ONLY) endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/package.cmake
#============================================================================= # Copyright (c) 2021, 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_export_package --------------------- .. versionadded:: v21.06.00 Record a given <PackageName> found by :cmake:command:`find_package <cmake:command:find_package>` is required for a given export set .. code-block:: cmake rapids_export_package( (BUILD|INSTALL) <PackageName> <ExportSet> [VERSION] major.minor [GLOBAL_TARGETS <targets...>] ) Records a given <PackageName> found by :cmake:command:`find_package <cmake:command:find_package>` is required for a given export set. When the associated :cmake:command:`rapids_export(BUILD|INSTALL)` or :cmake:command:`rapids_export_write_dependencies(BUILD|INSTALL)` command is invoked the generated information will include a :cmake:command:`find_dependency` call for <PackageName>. ``BUILD`` Will record <PackageName> is part of the build directory export set ``INSTALL`` Will record <PackageName> is part of the build directory export set ``VERSION`` .. versionadded:: v22.04.00 Record which `major.minor` version of the package is required for consumers. ``COMPONENTS`` .. versionadded:: v22.10.00 Record which components of the package are required for consumers. ``GLOBAL_TARGETS`` Which targets from this package should be made global when the package is imported in. #]=======================================================================] function(rapids_export_package type name export_set) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.export.package") string(TOLOWER ${type} type) set(options "") set(one_value EXPORT_SET VERSION) set(multi_value GLOBAL_TARGETS COMPONENTS) cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) if(type STREQUAL build) if(DEFINED ${name}_DIR AND ${name}_DIR) # Export out where we found the existing local config module set(possible_dir "${${name}_DIR}") endif() endif() if(_RAPIDS_COMPONENTS AND _RAPIDS_VERSION) set(version ${_RAPIDS_VERSION}) set(components ${_RAPIDS_COMPONENTS}) configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/${type}_package_components_versioned.cmake.in" "${CMAKE_BINARY_DIR}/rapids-cmake/${export_set}/${type}/package_${name}.cmake" @ONLY) elseif(_RAPIDS_COMPONENTS) set(components ${_RAPIDS_COMPONENTS}) configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/${type}_package_components.cmake.in" "${CMAKE_BINARY_DIR}/rapids-cmake/${export_set}/${type}/package_${name}.cmake" @ONLY) elseif(_RAPIDS_VERSION) set(version ${_RAPIDS_VERSION}) configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/${type}_package_versioned.cmake.in" "${CMAKE_BINARY_DIR}/rapids-cmake/${export_set}/${type}/package_${name}.cmake" @ONLY) else() configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/${type}_package.cmake.in" "${CMAKE_BINARY_DIR}/rapids-cmake/${export_set}/${type}/package_${name}.cmake" @ONLY) endif() if(NOT TARGET rapids_export_${type}_${export_set}) add_library(rapids_export_${type}_${export_set} INTERFACE) endif() # Don't remove duplicates here as that cost should only be paid Once per export set. So that # should occur in `write_dependencies` # Need to record the <PackageName> to `rapids_export_${type}_${export_set}` set_property(TARGET rapids_export_${type}_${export_set} APPEND PROPERTY "PACKAGE_NAMES" "${name}") if(_RAPIDS_GLOBAL_TARGETS) # record our targets that need to be marked as global when imported set_property(TARGET rapids_export_${type}_${export_set} APPEND PROPERTY "GLOBAL_TARGETS" "${_RAPIDS_GLOBAL_TARGETS}") endif() endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/find_package_file.cmake
#============================================================================= # 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. # 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_export_find_package_file ------------------------------- .. versionadded:: v21.06.00 Record that the file found at <file_path> needs to be usable as part of the associated export set. .. code-block:: cmake rapids_export_find_package_file( (BUILD|INSTALL) <file_path> (<ExportSetName> | EXPORT_SET [ExportSetName]) [CONDITION <variableName>] ) When constructing export sets, espically installed ones it is necessary to install any custom FindModules that your project has written. The :cmake:command:`rapids_export_find_package_file(BUILD|INSTALL)` allows projects to easily specify that a FindModule is either used by our export set or used by a consumer, allowing rapids-cmake to ensure it is installed correct and added to :cmake:variable:`CMAKE_MODULE_PATH` when needed. ``BUILD`` Record that the FindPackage at <file_path> needs to be part of our build directory export set. This means that it will be usable by the calling package if it needs to search for <PackageName> again. ``INSTALL`` Record that the FindPackage at <file_path> needs to be part of our install export set. This means that it will be installed as part of our packages CMake export set infrastructure ``EXPORT_SET`` List the export set name that this code should be attached too. If no name is given the associated call will be ignored. ``CONDITION`` A boolean variable name, that when evaluates to undefined or a false value will cause the associated call to be ignored. #]=======================================================================] function(rapids_export_find_package_file type file_path) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.export.find_package_file") include("${rapids-cmake-dir}/cmake/detail/policy.cmake") set(options "") set(one_value EXPORT_SET CONDITION) set(multi_value "") cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) # handle when we are given just an export set name and not `EXPORT_SET <name>` if(_RAPIDS_UNPARSED_ARGUMENTS AND NOT _RAPIDS_COMPONENTS_EXPORT_SET) rapids_cmake_policy(DEPRECATED_IN 23.12 REMOVED_IN 24.02 MESSAGE [=[Usage of `rapids_export_find_package_file` without an explicit `EXPORT_SET` key has been deprecated.]=] ) set(_RAPIDS_EXPORT_SET ${_RAPIDS_UNPARSED_ARGUMENTS}) endif() # Early terminate conditions if(NOT _RAPIDS_EXPORT_SET OR NOT ${_RAPIDS_CONDITION}) return() endif() string(TOLOWER ${type} type) set(export_set ${_RAPIDS_EXPORT_SET}) if(NOT TARGET rapids_export_${type}_${export_set}) add_library(rapids_export_${type}_${export_set} INTERFACE) endif() # Don't remove duplicates here as that cost should only be paid Once per export set. So that # should occur in `write_dependencies` set_property(TARGET rapids_export_${type}_${export_set} APPEND PROPERTY "FIND_PACKAGES_TO_INSTALL" "${file_path}") endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/detail/component.cmake
#============================================================================= # 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_export_component ----------------------- .. versionadded:: v23.04.00 .. code-block:: cmake Generate the necessary -Config.cmake modules needed for an optional component of a rapids export package. rapids_export_component( (BUILD|INSTALL) <project_name> <component_name> <export_set> <unique_name> <namespace>) The :cmake:command:`rapids_export_component` function generates the `<proj>-<unique_name>-targets.cmake` and `<proj>-<unique_name>-dependencies.cmake` files necessary for :cmake:command:`rapids_export` to support optional components. #]=======================================================================] # cmake-lint: disable=W0105,R0913 function(rapids_export_component type project_name component_name export_set unique_name namespace) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.export.rapids_export_component") string(TOLOWER ${type} type) set(deps_destination) if(type STREQUAL "install") include("${rapids-cmake-dir}/cmake/install_lib_dir.cmake") rapids_cmake_install_lib_dir(install_location) set(install_location "${install_location}/cmake/${project_name}") set(deps_destination "${PROJECT_BINARY_DIR}/rapids-cmake/${project_name}/export/${component_name}/") file(MAKE_DIRECTORY "${deps_destination}") install(DIRECTORY "${deps_destination}" 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}/") 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() if(TARGET rapids_export_${type}_${export_set}) include("${rapids-cmake-dir}/export/write_dependencies.cmake") rapids_export_write_dependencies( ${type} ${export_set} "${deps_destination}/${project_name}-${unique_name}-dependencies.cmake") endif() endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/detail/post_find_package_code.cmake
#============================================================================= # 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_export_post_find_package_code ------------------------------------ .. versionadded:: v23.12.00 Record for <PackageName> a set of CMake instructions to be executed after the package has been found successfully. .. code-block:: cmake rapids_export_post_find_package_code((BUILD|INSTALL) <PackageName> <code> EXPORT_SET [ExportSetName] [CONDITION <variableName>] ) When using complicated find modules like `Thrust` you might need to run some code after execution. Multiple calls to :cmake:command:`rapids_export_post_find_package_code` will append the instructions to execute in call order. .. note: The code will only be run if the package was found ``BUILD`` Record code to be executed immediately after `PackageName` has been found for our our build directory export set. ``INSTALL`` Record code to be executed immediately after `PackageName` has been found for our our install directory export set. ``EXPORT_SET`` List the export set name that this code should be attached too. If no name is given the associated call will be ignored. ``CONDITION`` A boolean variable name, that when evaluates to undefined or a false value will cause the associated call to be ignored. #]=======================================================================] function(rapids_export_post_find_package_code type name code) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.export.post_find_package_code") set(options "") set(one_value EXPORT_SET CONDITION) set(multi_value "") cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) # Early terminate conditions if(NOT _RAPIDS_EXPORT_SET OR NOT ${_RAPIDS_CONDITION}) return() endif() string(TOLOWER ${type} type) set(export_set ${_RAPIDS_EXPORT_SET}) if(NOT TARGET rapids_export_${type}_${export_set}) add_library(rapids_export_${type}_${export_set} INTERFACE) endif() # if the code coming in is a list of string we will have `;`, so transform those to "\n" so we # have a single string string(REPLACE ";" "\n" code "${code}") set_property(TARGET rapids_export_${type}_${export_set} APPEND_STRING PROPERTY "${name}_POST_FIND_CODE" "${code}\n") endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/detail/parse_version.cmake
#============================================================================= # Copyright (c) 2021, 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) # Function function(rapids_export_parse_version rapids_version orig_prefix ver_value) include("${rapids-cmake-dir}/cmake/parse_version.cmake") set(orig_version ${rapids_version}) rapids_cmake_parse_version(MAJOR "${rapids_version}" orig_major_version) rapids_cmake_parse_version(MINOR "${rapids_version}" orig_minor_version) rapids_cmake_parse_version(PATCH "${rapids_version}" orig_patch_version) set(version_compat SameMajorVersion) if(DEFINED orig_major_version) set(rapids_major_version "${orig_major_version}") if(rapids_major_version MATCHES "^0+$") set(rapids_major_version "0") endif() string(APPEND rapids_project_version "${rapids_major_version}") endif() if(DEFINED orig_minor_version) set(rapids_minor_version "${orig_minor_version}") if(rapids_minor_version MATCHES "^0+$") set(rapids_minor_version "0") endif() string(APPEND rapids_project_version ".${rapids_minor_version}") set(version_compat SameMinorVersion) endif() if(DEFINED orig_patch_version) set(rapids_patch_version "${orig_patch_version}") if(rapids_patch_version MATCHES "^0+$") set(rapids_patch_version "0") endif() string(APPEND rapids_project_version ".${rapids_patch_version}") set(version_compat SameMinorVersion) endif() set(${ver_value} ${rapids_project_version} PARENT_SCOPE) set(${ver_value}_compat ${version_compat} PARENT_SCOPE) set(${orig_prefix}_version ${rapids_version} PARENT_SCOPE) set(${orig_prefix}_major_version ${orig_major_version} PARENT_SCOPE) set(${orig_prefix}_minor_version ${orig_minor_version} PARENT_SCOPE) set(${orig_prefix}_patch_version ${orig_patch_version} PARENT_SCOPE) endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/template/install_package_components.cmake.in
find_dependency(@name@ COMPONENTS @components@)
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/template/cpm.cmake.in
#============================================================================= # Copyright (c) 2021, 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. #============================================================================= # CPM Search for @name@ # # Make sure we search for a build-dir config module for the CPM project set(possible_package_dir "@possible_dir@") if(possible_package_dir AND NOT DEFINED @name@_DIR) set(@name@_DIR "${possible_package_dir}") endif() CPMFindPackage( "@_RAPIDS_CPM_ARGS@" ) if(possible_package_dir) unset(possible_package_dir) endif() #=============================================================================
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/template/install_package.cmake.in
find_dependency(@name@)
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/template/install_package_versioned.cmake.in
find_package(@name@ @version@ QUIET) find_dependency(@name@)
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/template/dependencies.cmake.in
#============================================================================= # Copyright (c) 2021, 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(CMakeFindDependencyMacro) @_RAPIDS_EXPORT_CONTENTS@ foreach(target IN LISTS rapids_global_targets) if(TARGET ${target}) get_target_property(_is_imported ${target} IMPORTED) get_target_property(_already_global ${target} IMPORTED_GLOBAL) if(_is_imported AND NOT _already_global) set_target_properties(${target} PROPERTIES IMPORTED_GLOBAL TRUE) endif() endif() endforeach() unset(rapids_global_targets) unset(rapids_clear_cpm_cache)
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/template/build_package.cmake.in
#============================================================================= # find_dependency Search for @name@ # # Make sure we search for a build-dir config module for the project set(possible_package_dir "@possible_dir@") if(possible_package_dir AND NOT DEFINED @name@_DIR) set(@name@_DIR "${possible_package_dir}") endif() find_dependency(@name@) if(possible_package_dir) unset(possible_package_dir) endif() #=============================================================================
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/template/install_package_components_versioned.cmake.in
find_package(@name@ @version@ QUIET COMPONENTS @components@) find_dependency(@name@ COMPONENTS @components@)
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/template/build_package_components.cmake.in
#============================================================================= # find_dependency Search for @name@ # # Make sure we search for a build-dir config module for the project set(possible_package_dir "@possible_dir@") if(possible_package_dir AND NOT DEFINED @name@_DIR) set(@name@_DIR "${possible_package_dir}") endif() find_dependency(@name@ COMPONENTS @components@) if(possible_package_dir) unset(possible_package_dir) endif() #=============================================================================
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/template/config.cmake.in
#============================================================================= # Copyright (c) 2021, 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. #============================================================================= #[=======================================================================[ @_RAPIDS_PROJECT_DOCUMENTATION@ Result Variables ^^^^^^^^^^^^^^^^ This module will set the following variables:: @project_name_uppercase@_FOUND @project_name_uppercase@_VERSION @project_name_uppercase@_VERSION_MAJOR @project_name_uppercase@_VERSION_MINOR #]=======================================================================] @PACKAGE_INIT@ cmake_minimum_required(VERSION @CMAKE_MINIMUM_REQUIRED_VERSION@) set(rapids_global_languages @_RAPIDS_LANGUAGES@) foreach(lang IN LISTS rapids_global_languages) include("${CMAKE_CURRENT_LIST_DIR}/@project_name@-${lang}-language.cmake") endforeach() unset(rapids_global_languages) include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]" OPTIONAL) include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]" OPTIONAL) if(@_RAPIDS_HAS_COMPONENTS@) set(@project_name@_comp_names @_RAPIDS_COMPONENTS@) # find dependencies before creating targets that use them # this way if a dependency can't be found we fail foreach(comp IN LISTS @project_name@_FIND_COMPONENTS) if(${comp} IN_LIST @project_name@_comp_names) file(GLOB @project_name@_component_dep_files LIST_DIRECTORIES FALSE "${CMAKE_CURRENT_LIST_DIR}/@project_name@-${comp}*-dependencies.cmake") foreach(f IN LISTS @project_name@_component_dep_files) include("${f}") endforeach() endif() endforeach() foreach(comp IN LISTS @project_name@_FIND_COMPONENTS) if(${comp} IN_LIST @project_name@_comp_names) file(GLOB @project_name@_component_target_files LIST_DIRECTORIES FALSE "${CMAKE_CURRENT_LIST_DIR}/@project_name@-${comp}*-targets.cmake") foreach(f IN LISTS @project_name@_component_target_files) include("${f}") endforeach() set(@project_name@_${comp}_FOUND TRUE) endif() endforeach() endif() include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]" OPTIONAL) # Set our version variables set(@project_name_uppercase@_VERSION_MAJOR @rapids_orig_major_version@) set(@project_name_uppercase@_VERSION_MINOR @rapids_orig_minor_version@) set(@project_name_uppercase@_VERSION_PATCH @rapids_orig_patch_version@) set(@project_name_uppercase@_VERSION @rapids_orig_version@) set(rapids_global_targets @_RAPIDS_GLOBAL_TARGETS@) set(rapids_namespaced_global_targets @_RAPIDS_GLOBAL_TARGETS@) 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) if(TARGET ${target}) get_target_property(_is_imported ${target} IMPORTED) get_target_property(_already_global ${target} IMPORTED_GLOBAL) if(_is_imported AND NOT _already_global) set_target_properties(${target} PROPERTIES IMPORTED_GLOBAL TRUE) endif() endif() endforeach() # For backwards compat if("rapids_config_@type@" STREQUAL "rapids_config_build") foreach(target IN LISTS rapids_global_targets) if(TARGET ${target}) get_target_property(_is_imported ${target} IMPORTED) get_target_property(_already_global ${target} IMPORTED_GLOBAL) if(_is_imported AND NOT _already_global) set_target_properties(${target} PROPERTIES IMPORTED_GLOBAL TRUE) endif() if(NOT TARGET @_RAPIDS_NAMESPACE@${target}) add_library(@_RAPIDS_NAMESPACE@${target} ALIAS ${target}) endif() endif() endforeach() endif() unset(rapids_comp_names) unset(rapids_comp_unique_ids) unset(rapids_global_targets) unset(rapids_namespaced_global_targets) check_required_components(@project_name@) set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG "${CMAKE_CURRENT_LIST_FILE}") include(FindPackageHandleStandardArgs) find_package_handle_standard_args(${CMAKE_FIND_PACKAGE_NAME} CONFIG_MODE) @_RAPIDS_PROJECT_FINAL_CODE_BLOCK@
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/template/build_package_versioned.cmake.in
#============================================================================= # find_dependency Search for @name@ # # Make sure we search for a build-dir config module for the project set(possible_package_dir "@possible_dir@") if(possible_package_dir AND NOT DEFINED @name@_DIR) set(@name@_DIR "${possible_package_dir}") endif() find_package(@name@ @version@ QUIET) find_dependency(@name@) if(possible_package_dir) unset(possible_package_dir) endif() #=============================================================================
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/export
rapidsai_public_repos/rapids-cmake/rapids-cmake/export/template/build_package_components_versioned.cmake.in
#============================================================================= # find_dependency Search for @name@ # # Make sure we search for a build-dir config module for the project set(possible_package_dir "@possible_dir@") if(possible_package_dir AND NOT DEFINED @name@_DIR) set(@name@_DIR "${possible_package_dir}") endif() find_package(@name@ @version@ QUIET COMPONENTS @components@) find_dependency(@name@ COMPONENTS @components@) if(possible_package_dir) unset(possible_package_dir) endif() #=============================================================================
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/find/package.cmake
#============================================================================= # 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. # 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_find_package ------------------- .. versionadded:: v21.06.00 Allow projects to find dependencies via `find_package` with built-in tracking of these dependencies for correct export support. .. code-block:: cmake rapids_find_package(<PackageName> [ all normal find_package options ] [COMPONENTS <components...>] [GLOBAL_TARGETS <targets...>] [BUILD_EXPORT_SET <name>] [INSTALL_EXPORT_SET <name>] [ <FIND_ARGS> all normal find_package options ] ) Invokes :cmake:command:`find_package <cmake:command:find_package>` call and associate this with the listed build and install export set for correct export generation. Will propagate all variables set by :cmake:command:`find_package <cmake:command:find_package>` to the caller's scope. Since the visibility of CMake's targets differ between targets built locally and those imported, :cmake:command:`rapids_find_package` promotes imported targets to be global so users have consistency. List all targets used by your project in `GLOBAL_TARGETS`. ``PackageName`` Name of the package to find. ``COMPONENTS`` .. versionadded:: v22.10.00 A list of required components that are required to be found for this package to be considered valid. ``GLOBAL_TARGETS`` Which targets from this package should be made global. This information will be propagated to any associated export set. ``BUILD_EXPORT_SET`` Record that a :cmake:command:`find_dependency(<PackageName>)` call needs to occur as part of our build directory export set. ``INSTALL_EXPORT_SET`` Record that a :cmake:command:`find_dependency(<PackageName>)` call needs to occur as part of our build directory export set. ``FIND_ARGS`` Required placeholder to be provided before any extra arguments that need to be passed down to :cmake:command:`find_package <cmake:command:find_package>` .. note:: If the project/package you are looking for doesn't have an existing CMake Find module, please look at using :cmake:command:`rapids_find_generate_module`. The :cmake:command:`rapids_find_package` function supports two call modes. 1. When all the parameters for :cmake:command:`find_package <cmake:command:find_package>` are first followed by rapids parameters such as `BUILD_EXPORT_SET` and `INSTALL_EXPORT_SET` last. Here is an example of what this call would look like: .. code-block:: cmake rapids_find_package(ZLIB 1.2 REQUIRED GLOBAL_TARGETS ZLIB::ZLIB INSTALL_EXPORT_SET my-export-set BUILD_EXPORT_SET my-export-set ) 2. When the rapids parameters come first, and in that case they must be followed by the `FIND_ARGS` keyword. This ensures proper argument propagation to the underlying :cmake:command:`find_package <cmake:command:find_package>`. Here is an example of what this call would look like: .. code-block:: cmake rapids_find_package(ZLIB GLOBAL_TARGETS ZLIB::ZLIB INSTALL_EXPORT_SET my-export-set BUILD_EXPORT_SET my-export-set FIND_ARGS 1.2 REQUIRED ) #]=======================================================================] macro(rapids_find_package name) # # rapids_find_package breaks convention and is a macro on purpose. Since `find_package` allows # arbitrary variable creation ( `<PROJECT_???>` ) we need to have `rapids_find_package` do the # same. If it doesn't it would make drop in replacements impossible # list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.find.package") 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_FIND "${_rapids_options}" "${_rapids_one_value}" "${_rapids_multi_value}" ${ARGN}) if(_RAPIDS_FIND_COMPONENTS) list(APPEND _RAPIDS_FIND_UNPARSED_ARGUMENTS COMPONENTS ${_RAPIDS_FIND_COMPONENTS}) endif() find_package(${name} ${_RAPIDS_FIND_UNPARSED_ARGUMENTS}) if(_RAPIDS_FIND_GLOBAL_TARGETS) include("${rapids-cmake-dir}/cmake/make_global.cmake") 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 # OPTIONAL find packages if(${${name}_FOUND}) if(${name} STREQUAL "CUDAToolkit") include("${rapids-cmake-dir}/cuda/patch_toolkit.cmake") rapids_cuda_patch_toolkit() endif() set(_rapids_extra_info) if(_RAPIDS_FIND_GLOBAL_TARGETS) list(APPEND _rapids_extra_info "GLOBAL_TARGETS" ${_RAPIDS_FIND_GLOBAL_TARGETS}) endif() 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 set(possible_version ${ARGV1}) if(possible_version MATCHES "^[0-9]+") list(APPEND _rapids_extra_info "VERSION" ${possible_version}) endif() if(_RAPIDS_FIND_BUILD_EXPORT_SET) include("${rapids-cmake-dir}/export/package.cmake") rapids_export_package(BUILD ${name} ${_RAPIDS_FIND_BUILD_EXPORT_SET} ${_rapids_extra_info}) endif() if(_RAPIDS_FIND_INSTALL_EXPORT_SET) include("${rapids-cmake-dir}/export/package.cmake") rapids_export_package(INSTALL ${name} ${_RAPIDS_FIND_INSTALL_EXPORT_SET} ${_rapids_extra_info}) endif() unset(_rapids_extra_info) endif() # Cleanup all our local variables foreach(_rapids_local_var IN LISTS _rapids_options _rapids_one_value _rapids_multi_value) if(DEFINED _RAPIDS_FIND_${_rapids_local_var}) unset(_RAPIDS_FIND_${_rapids_local_var}) endif() endforeach() unset(_rapids_local_var) unset(_rapids_options) unset(_rapids_one_value) unset(_rapids_multi_value) list(POP_BACK CMAKE_MESSAGE_CONTEXT) endmacro()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/find/generate_module.cmake
#============================================================================= # 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. # 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(PUSH) cmake_policy(VERSION 3.23) #[=======================================================================[.rst: rapids_find_generate_module --------------------------- .. versionadded:: v21.06.00 Generate a Find*.cmake module for the requested package .. code-block:: cmake rapids_find_generate_module( <PackageName> HEADER_NAMES <paths...> [LIBRARY_NAMES <names...>] [INCLUDE_SUFFIXES <suffixes...>] [VERSION <version>] [NO_CONFIG] [INITIAL_CODE_BLOCK <code_block_variable>] [FINAL_CODE_BLOCK <code_block_variable>] [BUILD_EXPORT_SET <name>] [INSTALL_EXPORT_SET <name>] ) Generates a custom Find module for the requested package. Makes it easier for projects to look for packages that don't have an existing FindModule or don't provide a CONFIG module when installed. .. note:: If you are using this for a module that is part of your BUILD or INSTALL export set, it is highly likely that this needs to be part of the same export sets. ``HEADER_NAMES`` Header names that should be provided to :cmake:command:`find_path` to determine the include directory of the package. If provided a list of names only one needs to be found for a directory to be considered a match ``LIBRARY_NAMES`` library names that should be provided to :cmake:command:`find_library` to determine the include directory of the package. If provided a list of names only one needs to be found for a directory to be considered a match .. note:: Every entry that doesn't start with `lib` will also be searched for as `lib<name>` ``INCLUDE_SUFFIXES`` Extra relative sub-directories to use while searching for `HEADER_NAMES`. ``VERSION`` Will append extra entries of the library to search for based on the content of `LIBRARY_NAMES`: - <name><version> - <name>.<version> - lib<name><version> - lib<name>.<version> This ordering is done explicitly to follow CMake recommendations for searching for versioned libraries: "We recommend specifying the unversioned name first so that locally-built packages can be found before those provided by distributions." ``NO_CONFIG`` 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 usable by the calling package if it needs to search for <PackageName> again. ``INSTALL_EXPORT_SET`` Record that this custom FindPackage module needs to be part of our install export set. This means that it will be installed as part of our packages CMake export set infrastructure Result Variables ^^^^^^^^^^^^^^^^ :cmake:variable:`CMAKE_MODULE_PATH` will be modified to include the folder where `Find<PackageName>.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 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}) if(NOT DEFINED _RAPIDS_HEADER_NAMES) message(FATAL_ERROR "rapids_find_generate_module requires HEADER_NAMES to be provided") endif() set(_RAPIDS_PKG_NAME ${name}) # Construct any extra suffix search paths set(_RAPIDS_PATH_SEARCH_ARGS) if(_RAPIDS_INCLUDE_SUFFIXES) string(APPEND _RAPIDS_PATH_SEARCH_ARGS "PATH_SUFFIXES ${_RAPIDS_INCLUDE_SUFFIXES}") endif() set(_RAPIDS_HEADER_ONLY TRUE) if(DEFINED _RAPIDS_LIBRARY_NAMES) set(_RAPIDS_HEADER_ONLY FALSE) # Construct the release and debug library names handling version number suffixes set(_RAPIDS_PKG_LIB_NAMES ${_RAPIDS_LIBRARY_NAMES}) set(_RAPIDS_PKG_LIB_DEBUG_NAMES ${_RAPIDS_LIBRARY_NAMES}) list(TRANSFORM _RAPIDS_PKG_LIB_DEBUG_NAMES APPEND "d") if(DEFINED _RAPIDS_VERSION) list(TRANSFORM _RAPIDS_PKG_LIB_NAMES APPEND "${_RAPIDS_VERSION}" OUTPUT_VARIABLE lib_version1) list(TRANSFORM _RAPIDS_PKG_LIB_NAMES APPEND ".${_RAPIDS_VERSION}" OUTPUT_VARIABLE lib_version2) list(PREPEND _RAPIDS_PKG_LIB_NAMES ${lib_version1} ${lib_version2}) list(TRANSFORM _RAPIDS_PKG_LIB_DEBUG_NAMES APPEND "${_RAPIDS_VERSION}" OUTPUT_VARIABLE lib_version1) list(TRANSFORM _RAPIDS_PKG_LIB_DEBUG_NAMES APPEND ".${_RAPIDS_VERSION}" OUTPUT_VARIABLE lib_version2) list(PREPEND _RAPIDS_PKG_LIB_DEBUG_NAMES ${lib_version1} ${lib_version2}) 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) # Need to add our generated modules to CMAKE_MODULE_PATH! if(NOT "${CMAKE_BINARY_DIR}/rapids-cmake/find_modules/" IN_LIST CMAKE_MODULE_PATH) list(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}/cmake/find_modules/") set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE) endif() # Record what export sets this module is part of include("${rapids-cmake-dir}/export/find_package_file.cmake") rapids_export_find_package_file(BUILD "${CMAKE_BINARY_DIR}/cmake/find_modules/Find${name}.cmake" EXPORT_SET ${_RAPIDS_BUILD_EXPORT_SET}) rapids_export_find_package_file(INSTALL "${CMAKE_BINARY_DIR}/cmake/find_modules/Find${name}.cmake" EXPORT_SET ${_RAPIDS_INSTALL_EXPORT_SET}) endfunction() cmake_policy(POP)
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/find
rapidsai_public_repos/rapids-cmake/rapids-cmake/find/template/find_module.cmake.in
#============================================================================= # Copyright (c) 2021, 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. #============================================================================= #[=======================================================================[.rst: Find@_RAPIDS_PKG_NAME@ -------- Find @_RAPIDS_PKG_NAME@ Imported targets ^^^^^^^^^^^^^^^^ This module defines the following :prop_tgt:`IMPORTED` target(s): ``@_RAPIDS_PKG_NAME@::@_RAPIDS_PKG_NAME@`` The @_RAPIDS_PKG_NAME@ library, if found. Result variables ^^^^^^^^^^^^^^^^ This module will set the following variables in your project: ``@_RAPIDS_PKG_NAME@_FOUND`` True if @_RAPIDS_PKG_NAME@ is found. ``@_RAPIDS_PKG_NAME@_INCLUDE_DIRS`` The include directories needed to use @_RAPIDS_PKG_NAME@. ``@_RAPIDS_PKG_NAME@_LIBRARIES`` The libraries needed to use@_RAPIDS_PKG_NAME@. ``@_RAPIDS_PKG_NAME@_VERSION_STRING`` The version of the @_RAPIDS_PKG_NAME@ library found. [OPTIONAL] #]=======================================================================] # 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) if(@_RAPIDS_PKG_NAME@_FOUND) find_package_handle_standard_args(@_RAPIDS_PKG_NAME@ DEFAULT_MSG @_RAPIDS_PKG_NAME@_CONFIG) return() endif() endif() find_path(@_RAPIDS_PKG_NAME@_INCLUDE_DIR NAMES @_RAPIDS_HEADER_NAMES@ @_RAPIDS_PATH_SEARCH_ARGS@) set(@_RAPIDS_PKG_NAME@_IS_HEADER_ONLY @_RAPIDS_HEADER_ONLY@) if(NOT @_RAPIDS_PKG_NAME@_LIBRARY AND NOT @_RAPIDS_PKG_NAME@_IS_HEADER_ONLY) find_library(@_RAPIDS_PKG_NAME@_LIBRARY_RELEASE NAMES @_RAPIDS_PKG_LIB_NAMES@ NAMES_PER_DIR @_RAPIDS_LIB_SEARCH_ARGS@) find_library(@_RAPIDS_PKG_NAME@_LIBRARY_DEBUG NAMES @_RAPIDS_PKG_LIB_DEBUG_NAMES@ NAMES_PER_DIR @_RAPIDS_LIB_SEARCH_ARGS@) include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake) select_library_configurations(@_RAPIDS_PKG_NAME@) unset(@_RAPIDS_PKG_NAME@_FOUND) #incorrectly set by select_library_configurations endif() include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) if(@_RAPIDS_PKG_NAME@_IS_HEADER_ONLY) find_package_handle_standard_args(@_RAPIDS_PKG_NAME@ FOUND_VAR @_RAPIDS_PKG_NAME@_FOUND REQUIRED_VARS @_RAPIDS_PKG_NAME@_INCLUDE_DIR VERSION_VAR @_RAPIDS_VERSION@) else() find_package_handle_standard_args(@_RAPIDS_PKG_NAME@ FOUND_VAR @_RAPIDS_PKG_NAME@_FOUND REQUIRED_VARS @_RAPIDS_PKG_NAME@_LIBRARY @_RAPIDS_PKG_NAME@_INCLUDE_DIR VERSION_VAR @_RAPIDS_VERSION@) endif() if(@_RAPIDS_PKG_NAME@_FOUND) set(@_RAPIDS_PKG_NAME@_INCLUDE_DIRS ${@_RAPIDS_PKG_NAME@_INCLUDE_DIR}) if(NOT @_RAPIDS_PKG_NAME@_LIBRARIES) set(@_RAPIDS_PKG_NAME@_LIBRARIES ${@_RAPIDS_PKG_NAME@_LIBRARY}) endif() if(NOT TARGET @_RAPIDS_PKG_NAME@::@_RAPIDS_PKG_NAME@) add_library(@_RAPIDS_PKG_NAME@::@_RAPIDS_PKG_NAME@ UNKNOWN IMPORTED GLOBAL) set_target_properties(@_RAPIDS_PKG_NAME@::@_RAPIDS_PKG_NAME@ PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${@_RAPIDS_PKG_NAME@_INCLUDE_DIRS}") if(@_RAPIDS_PKG_NAME@_LIBRARY_RELEASE) set_property(TARGET @_RAPIDS_PKG_NAME@::@_RAPIDS_PKG_NAME@ APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) set_target_properties(@_RAPIDS_PKG_NAME@::@_RAPIDS_PKG_NAME@ PROPERTIES IMPORTED_LOCATION_RELEASE "${@_RAPIDS_PKG_NAME@_LIBRARY_RELEASE}") endif() if(@_RAPIDS_PKG_NAME@_LIBRARY_DEBUG) set_property(TARGET @_RAPIDS_PKG_NAME@::@_RAPIDS_PKG_NAME@ APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) set_target_properties(@_RAPIDS_PKG_NAME@::@_RAPIDS_PKG_NAME@ PROPERTIES IMPORTED_LOCATION_DEBUG "${@_RAPIDS_PKG_NAME@_LIBRARY_DEBUG}") endif() if(NOT @_RAPIDS_PKG_NAME@_LIBRARY_RELEASE AND NOT @_RAPIDS_PKG_NAME@_LIBRARY_DEBUG) set_property(TARGET @_RAPIDS_PKG_NAME@::@_RAPIDS_PKG_NAME@ APPEND PROPERTY IMPORTED_LOCATION "${@_RAPIDS_PKG_NAME@_LIBRARY}") endif() endif() endif() @_RAPIDS_FIND_FINAL_CODE_BLOCK@ unset(@_RAPIDS_PKG_NAME@_NO_CONFIG) unset(@_RAPIDS_PKG_NAME@_IS_HEADER_ONLY)
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/test/add.cmake
#============================================================================= # 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_add --------------- .. versionadded:: v23.04.00 States how many GPUs and what percent of each a test requires. .. code-block:: cmake rapids_test_add(NAME <name> COMMAND <target|command> [<args>...] [GPUS <N> [PERCENT <value>]] [INSTALL_COMPONENT_SET <set>] [WORKING_DIRECTORY <dir>]) Add a test called `<name>` which will be executed with a given GPU resource allocation. When combined with :cmake:command:`rapids_test_init` informs CTest what resources should be allocated to a test so that when testing in parallel oversubscription doesn't occur. Without this information user execution of CTest with high parallel levels will cause multiple tests to run on the same GPU and quickly exhaust all memory. ``COMMAND`` Specify the test command-line including any arguments. If the first argument provided is an executable target (created by add_executable()) it will automatically be replaced by the location of the executable created at build time. ``GPUS`` State how many GPUs this test requires. Allows CTest to not over-subscribe a machine's hardware. If no value is provided, the test is considered to not use any GPUs ``PERCENT`` By default if no percent is provided, 100 is used. State how much of each GPU this test requires. ``INSTALL_COMPONENT_SET`` Record which component that the underlying executable for the test will be installed by. This is used by :cmake:command:`rapids_test_install_relocatable` to allow for execution of the installed tests by ctest ``WORKING_DIRECTORY`` Specify the working directory in which to execute the test. If not specified the test will be run with the current working directory set to the value of :cmake:variable:`CMAKE_CURRENT_BINARY_DIR <cmake:variable:CMAKE_CURRENT_BINARY_DIR>`. #]=======================================================================] # cmake-lint: disable=R0915 function(rapids_test_add) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.add") set(options) set(one_value NAME WORKING_DIRECTORY GPUS PERCENT INSTALL_COMPONENT_SET) set(multi_value COMMAND) cmake_parse_arguments(_RAPIDS_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) if(NOT DEFINED _RAPIDS_TEST_NAME) message(FATAL_ERROR "rapids_add_test called without a name") endif() if(NOT DEFINED _RAPIDS_TEST_COMMAND) message(FATAL_ERROR "rapids_add_test called without a command") endif() list(POP_FRONT _RAPIDS_TEST_COMMAND command_or_target) set(args "${_RAPIDS_TEST_COMMAND}") set(command ${command_or_target}) if(TARGET ${command_or_target}) set(command "$<TARGET_FILE:${command}>") endif() if(NOT DEFINED _RAPIDS_TEST_WORKING_DIRECTORY) set(_RAPIDS_TEST_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") endif() # Provide a copy of the test runner in the binary directory so that tests still can be executed if # for some reason rapids-cmake src has been removed. set(_rapids_run_gpu_test_script_dir "${PROJECT_BINARY_DIR}/rapids-cmake/") set(_rapids_run_gpu_test_script "./run_gpu_test.cmake") if(NOT EXISTS "${_rapids_run_gpu_test_script_dir}${_rapids_run_gpu_test_script}") file(COPY "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/run_gpu_test.cmake" DESTINATION "${_rapids_run_gpu_test_script_dir}") 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}" WORKING_DIRECTORY "${_RAPIDS_TEST_WORKING_DIRECTORY}") include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/gpu_requirements.cmake) if(DEFINED _RAPIDS_TEST_GPUS) rapids_test_gpu_requirements(${_RAPIDS_TEST_NAME} GPUS ${_RAPIDS_TEST_GPUS} PERCENT ${_RAPIDS_TEST_PERCENT}) endif() 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_install.cmake) rapids_test_record_test_component(NAME ${_RAPIDS_TEST_NAME} COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET}) if(TARGET ${command_or_target}) rapids_test_record_install(TARGET ${command_or_target} COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET}) endif() endif() endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/test/init.cmake
#============================================================================= # 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_init ---------------- .. versionadded:: v23.04.00 Establish necessary components for CTest GPU resource allocation to allow for parallel tests. .. code-block:: cmake rapids_test_init( ) Generates a JSON resource specification file representing the machine's GPUs using system introspection. This will allow CTest to schedule multiple single-GPU or multi-GPU tests in parallel on multi-GPU machines. For tests to execute correctly they will need to use the :cmake:command:`rapids_test_add` to register GPU requirements: .. code-block:: cmake enable_testing() include(rapids-test) rapids_test_init() add_executable( test_example test.cu ) rapids_test_add(NAME single_gpu_alloc COMMAND test_example GPUS 1) rapids_test_add(NAME two_gpu_alloc COMMAND test_example GPUS 2) Result Variables ^^^^^^^^^^^^^^^^ :cmake:variable:`CTEST_RESOURCE_SPEC_FILE` will be set to the generated JSON file if not already set #]=======================================================================] function(rapids_test_init) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.init") include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/default_names.cmake) include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/generate_resource_spec.cmake) set(rapids_test_spec_file "${PROJECT_BINARY_DIR}/${rapids_test_json_file_name}") rapids_test_generate_resource_spec(DESTINATION "${rapids_test_spec_file}") if(NOT CTEST_RESOURCE_SPEC_FILE) set(CTEST_RESOURCE_SPEC_FILE "${rapids_test_spec_file}" PARENT_SCOPE) endif() endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/test/gpu_requirements.cmake
#============================================================================= # 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_gpu_requirements ---------------------------- .. versionadded:: v23.04.00 States how many GPUs and what percent of each a test requires. .. code-block:: cmake rapids_test_gpu_requirements( test_name GPUS <N> [PERCENT <value>]) This function should only be used when :cmake:command:`rapids_test_add` is insufficient due to the rapids-cmake test wrappers not working for your project. When combined with :cmake:command:`rapids_test_init` informs CTest what resources should be allocated to a test so that when testing in parallel oversubscription doesn't occur. Without this information user execution of CTest with high parallel levels will cause multiple tests to run on the same GPU and quickly exhaust all memory. ``GPUS`` State how many GPUs this test requires. Allows CTest to not over-subscribe a machine's hardware. Any integer value >= 0 is supported ``PERCENT`` State how much of each GPU this test requires. In general 100, 50, and 20 are commonly used values. By default if no percent is provided, 100 is used. Any integer value >= 0 and <= 100 is supported Default value of 100 #]=======================================================================] function(rapids_test_gpu_requirements test_name) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.gpu_requirements") set(options) set(one_value GPUS PERCENT) set(multi_value) cmake_parse_arguments(_RAPIDS_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) if(DEFINED _RAPIDS_TEST_PERCENT AND NOT DEFINED _RAPIDS_TEST_GPUS) message(FATAL_ERROR "rapids_test_gpu_requirements requires the GPUS option to be provided when PERCENT is" ) endif() set(gpus 0) if(DEFINED _RAPIDS_TEST_GPUS) set(gpus ${_RAPIDS_TEST_GPUS}) endif() set(percent 100) if(DEFINED _RAPIDS_TEST_PERCENT) set(percent ${_RAPIDS_TEST_PERCENT}) endif() # verify that gpu and percent are withing the allowed bounds if(NOT gpus GREATER_EQUAL 0) message(FATAL_ERROR "rapids_test_gpu_requirements requires a numeric GPUS value [0-N].") endif() if(NOT (percent GREATER_EQUAL 1 AND percent LESS_EQUAL 100)) message(FATAL_ERROR "rapids_test_gpu_requirements requires a numeric PERCENT value [1-100].") endif() if(gpus AND percent) set_property(TEST ${test_name} PROPERTY RESOURCE_GROUPS "${gpus},gpus:${percent}") endif() endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/test/generate_resource_spec.cmake
#============================================================================= # 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_generate_resource_spec ---------------------------------- .. versionadded:: v23.04.00 Generates a JSON resource specification file representing the machine's GPUs using system introspection. .. code-block:: cmake rapids_test_generate_resource_spec( DESTINATION filepath ) Generates a JSON resource specification file representing the machine's GPUs using system introspection. This will allow CTest to schedule multiple single-GPU tests in parallel on multi-GPU machines. For the majority of projects :cmake:command:`rapids_test_init` should be used. This command should be used directly projects that require multiple spec files to be generated. ``DESTINATION`` Location that the JSON output from the detection should be written to .. note:: Unlike rapids_test_init this doesn't set CTEST_RESOURCE_SPEC_FILE #]=======================================================================] function(rapids_test_generate_resource_spec DESTINATION filepath) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.generate_resource_spec") if(NOT DEFINED CMAKE_CUDA_COMPILER AND NOT DEFINED CMAKE_CXX_COMPILER) message(FATAL_ERROR "rapids_test_generate_resource_spec Requires the CUDA or C++ language to be enabled." ) endif() set(gpu_json_contents [=[ { "version": {"major": 1, "minor": 0}, "local": [{ "gpus": [{"id":"0", "slots": 0}] }] } ]=]) include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/default_names.cmake) set(eval_file ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/generate_resource_spec.cpp) set(eval_exe ${PROJECT_BINARY_DIR}/rapids-cmake/${rapids_test_generate_exe_name}) set(error_file ${PROJECT_BINARY_DIR}/rapids-cmake/detect_gpus.stderr.log) if(NOT EXISTS "${eval_exe}") find_package(CUDAToolkit QUIET) file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/rapids-cmake/") if(CUDAToolkit_FOUND) set(compile_options "-I${CUDAToolkit_INCLUDE_DIRS}" "-DHAVE_CUDA") endif() set(link_options ${CUDA_cudart_LIBRARY}) set(compiler "${CMAKE_CXX_COMPILER}") if(NOT DEFINED CMAKE_CXX_COMPILER) set(compiler "${CMAKE_CUDA_COMPILER}") endif() execute_process(COMMAND "${compiler}" "${eval_file}" ${compile_options} ${link_options} -o "${eval_exe}" OUTPUT_VARIABLE compile_output ERROR_VARIABLE compile_output) endif() if(NOT EXISTS "${eval_exe}") message(STATUS "rapids_test_generate_resource_spec failed to build detection executable, presuming no GPUs." ) message(STATUS "rapids_test_generate_resource_spec compile[${compiler} ${compile_options} ${link_options}] failure details are ${compile_output}" ) file(WRITE "${filepath}" "${gpu_json_contents}") else() execute_process(COMMAND ${eval_exe} OUTPUT_FILE "${filepath}") endif() endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake
rapidsai_public_repos/rapids-cmake/rapids-cmake/test/install_relocatable.cmake
#============================================================================= # 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_install_relocatable ------------------------------- .. versionadded:: v23.04.00 Install the needed `ctest` infrastructure to allow installed tests to be run by `ctest` in parallel with GPU awareness. .. code-block:: cmake rapids_test_install_relocatable(INSTALL_COMPONENT_SET <component> DESTINATION <relative_path> [INCLUDE_IN_ALL]) 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` 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 ``DESTINATION`` Relative path from the `CMAKE_INSTALL_PREFIX` to install the infrastructure. This needs to be the same directory as the test executables ``INCLUDE_IN_ALL`` 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") set(options INCLUDE_IN_ALL) set(one_value INSTALL_COMPONENT_SET DESTINATION) set(multi_value) cmake_parse_arguments(_RAPIDS_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) set(to_exclude EXCLUDE_FROM_ALL) if(_RAPIDS_TEST_INCLUDE_IN_ALL) set(to_exclude) endif() set(component ${_RAPIDS_TEST_INSTALL_COMPONENT_SET}) if(NOT TARGET rapids_test_install_${component}) message(FATAL_ERROR "No install component set [${component}] can be found") endif() 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) 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_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}\") 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} ${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} ${to_exclude}) endif() if(EXISTS "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/run_gpu_test.cmake") install(FILES "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/run_gpu_test.cmake" COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET} DESTINATION ${_RAPIDS_TEST_DESTINATION} ${to_exclude}) endif() if(targets_to_install) install(TARGETS ${targets_to_install} COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET} DESTINATION ${_RAPIDS_TEST_DESTINATION} ${to_exclude}) endif() endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/test
rapidsai_public_repos/rapids-cmake/rapids-cmake/test/detail/default_names.cmake
#============================================================================= # 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. #============================================================================= # can't have an include guard on this file # that breaks its usage by test/init and test/install_relocatable set(rapids_test_generate_exe_name generate_ctest_json) set(rapids_test_json_file_name resource_spec.json)
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/test
rapidsai_public_repos/rapids-cmake/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake
#============================================================================= # 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 `<NAME>=<VALUE>` 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_PROJECT_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_PROJECT_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}")
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/test
rapidsai_public_repos/rapids-cmake/rapids-cmake/test/detail/record_test_component.cmake
#============================================================================= # 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_component --------------------------------- .. versionadded:: v23.04.00 Record what component a test is part of .. code-block:: cmake rapids_test_record_test_component(NAME <name> COMPONENT <set>) #]=======================================================================] function(rapids_test_record_test_component) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.record_test_component") set(options) set(one_value NAME COMPONENT) set(multi_value) 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()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/test
rapidsai_public_repos/rapids-cmake/rapids-cmake/test/detail/record_install.cmake
#============================================================================= # 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_install -------------------------- .. versionadded:: v23.04.00 Record that the provided target should have install rules specified when :cmake:command:`rapids_test_install_relocatable` is called with the given component. .. code-block:: cmake rapids_test_record_install(TARGET <name> COMPONENT <set>) #]=======================================================================] function(rapids_test_record_install) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.record_install") set(options) set(one_value TARGET COMPONENT) set(multi_value) cmake_parse_arguments(_RAPIDS_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) set(component ${_RAPIDS_TEST_COMPONENT}) set_property(TARGET rapids_test_install_${component} APPEND PROPERTY TARGETS_TO_INSTALL "${_RAPIDS_TEST_TARGET}") endfunction()
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/test
rapidsai_public_repos/rapids-cmake/rapids-cmake/test/detail/run_gpu_test.cmake
#============================================================================= # 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. #============================================================================= cmake_minimum_required(VERSION 3.23.1) if(DEFINED ENV{CTEST_RESOURCE_GROUP_COUNT}) # cmake-lint: disable=E1120 foreach(index RANGE 0 ${CTEST_RESOURCE_GROUP_COUNT}) set(allocation $ENV{CTEST_RESOURCE_GROUP_${index}_GPUS}) if(DEFINED allocation) # strings look like "id:value,slots:value" so let's make a super lazy parser by deleting `id:` # and replacing `,slots:` with `;` so we have a list with two items. string(REPLACE "id:" "" allocation "${allocation}") string(REPLACE ",slots:" ";" allocation "${allocation}") list(GET allocation 0 device_ids) # slots are the cmake test requirements term for what we call percent. So we can ignore the # second item in the list set(ENV{CUDA_VISIBLE_DEVICES} ${device_ids}) endif() endforeach() endif() execute_process(COMMAND ${command_to_run} ${command_args} COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL ANY)
0
rapidsai_public_repos/rapids-cmake/rapids-cmake/test
rapidsai_public_repos/rapids-cmake/rapids-cmake/test/detail/generate_resource_spec.cpp
/* * 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. */ #ifdef HAVE_CUDA #include <cuda_runtime_api.h> #endif #include <iostream> #include <string> #include <vector> struct version { version() : json_major(1), json_minor(0) {} int json_major; int json_minor; }; struct gpu { gpu(int i) : id(i), memory(0), slots(0){}; gpu(int i, size_t mem) : id(i), memory(mem), slots(100) {} int id; size_t memory; int slots; }; // A hard-coded JSON printer that generates a ctest resource-specification file: // https://cmake.org/cmake/help/latest/manual/ctest.1.html#resource-specification-file void to_json(std::ostream& buffer, version const& v) { buffer << "\"version\": {\"major\": " << v.json_major << ", \"minor\": " << v.json_minor << "}"; } void to_json(std::ostream& buffer, gpu const& g) { buffer << "\t\t{\"id\": \"" << g.id << "\", \"slots\": " << g.slots << "}"; } int main() { std::vector<gpu> gpus; int nDevices = 0; #ifdef HAVE_CUDA cudaGetDeviceCount(&nDevices); if (nDevices == 0) { gpus.push_back(gpu(0)); } else { for (int i = 0; i < nDevices; ++i) { cudaDeviceProp prop; cudaGetDeviceProperties(&prop, i); gpus.push_back(gpu(i, prop.totalGlobalMem)); } } #else gpus.push_back(gpu(0)); #endif version v; std::cout << "{\n"; to_json(std::cout, v); std::cout << ",\n"; std::cout << "\"local\": [{\n"; std::cout << "\t\"gpus\": [\n"; for (int i = 0; i < gpus.size(); ++i) { to_json(std::cout, gpus[i]); if (i != (gpus.size() - 1)) { std::cout << ","; } std::cout << "\n"; } std::cout << "\t]\n"; std::cout << "}]\n"; std::cout << "}" << std::endl; return 0; }
0
rapidsai_public_repos/rapids-cmake
rapidsai_public_repos/rapids-cmake/testing/CMakeLists.txt
#============================================================================= # 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. # 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.23.1 FATAL_ERROR) project(rapids-cmake-testing LANGUAGES NONE) enable_testing() include(utils/cmake_config_test.cmake) include(utils/cmake_ctest_test.cmake) include(utils/cmake_build_test.cmake) add_subdirectory(cmake) add_subdirectory(cuda) add_subdirectory(export) add_subdirectory(find) include("${CMAKE_CURRENT_SOURCE_DIR}/utils/determine_gpu_count.cmake") determine_gpu_count() add_subdirectory(test) option(RAPIDS_CMAKE_ENABLE_DOWNLOAD_TESTS "Enable tests that require downloads" ON) if(RAPIDS_CMAKE_ENABLE_DOWNLOAD_TESTS) # Setup and fill the cpm cache, and specify CPM_SOURCE_CACHE # so that all subsequent tests in this directory use the # shared CPM_SOURCE_CACHE include("${CMAKE_CURRENT_SOURCE_DIR}/utils/setup_cpm_cache.cmake") setup_cpm_cache() add_subdirectory(cpm) add_subdirectory(cython) add_subdirectory(other) endif()
0
rapidsai_public_repos/rapids-cmake
rapidsai_public_repos/rapids-cmake/testing/README.md
# RAPIDS CMake Testing ## Synopsis This is a collection of CMake tests to verify that rapids-cmake works as expected. ## Requirements - CUDA compiler - PNG Library ( for find_package tests ) - ZLIB Library ( for find_package tests )
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/other/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, 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. #============================================================================= add_cmake_config_test( rapids_cmake-multiple-cpm ) add_cmake_config_test( rapids_cmake-multiple-simple ) add_cmake_config_test( FetchContent-legacy ) add_cmake_config_test( FetchContent-hostile-legacy )
0
rapidsai_public_repos/rapids-cmake/testing/other
rapidsai_public_repos/rapids-cmake/testing/other/rapids_cmake-multiple-cpm/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, 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.23.1) project(rapids-test-project LANGUAGES CXX) cmake_path(GET rapids-cmake-dir PARENT_PATH rapids.cmake-location) cmake_path(APPEND rapids.cmake-location "RAPIDS.cmake") # Remove this cache variable so we can properly test # fetching rapids-cmake work as intended unset(rapids-cmake-dir CACHE) set(CMAKE_MODULE_PATH "/not/a/directory") function(add_A ) add_subdirectory(A) endfunction() function(add_B ) add_subdirectory(B) endfunction() add_A() add_B()
0
rapidsai_public_repos/rapids-cmake/testing/other/rapids_cmake-multiple-cpm
rapidsai_public_repos/rapids-cmake/testing/other/rapids_cmake-multiple-cpm/B/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, 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. #============================================================================= # verify no rapids-cmake variables have been specified if(DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "") endif() include("${rapids.cmake-location}") if(NOT DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "expected variable rapids-cmake_SOURCE_DIR to exist") endif() if(NOT DEFINED rapids-cmake-dir) message(FATAL_ERROR "expected variable rapids-cmake-dir to exist") endif() if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH) message(FATAL_ERROR "expected variable rapids-cmake-dir to be inside CMAKE_MODULE_PATH") endif() if(NOT DEFINED rapids-cmake-version) message(FATAL_ERROR "expected variable rapids-cmake-version to exist") endif()
0
rapidsai_public_repos/rapids-cmake/testing/other/rapids_cmake-multiple-cpm
rapidsai_public_repos/rapids-cmake/testing/other/rapids_cmake-multiple-cpm/A/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, 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. #============================================================================= # verify no rapids-cmake variables have been specified if(DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "") endif() include("${rapids.cmake-location}") if(NOT DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "expected variable rapids-cmake_SOURCE_DIR to exist") endif() if(NOT DEFINED rapids-cmake-dir) message(FATAL_ERROR "expected variable rapids-cmake-dir to exist") endif() if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH) message(FATAL_ERROR "expected variable rapids-cmake-dir to be inside CMAKE_MODULE_PATH") endif() if(NOT DEFINED rapids-cmake-version) message(FATAL_ERROR "expected variable rapids-cmake-version to exist") endif() # Be hostile against rapids-cmake set(CMAKE_MODULE_PATH "/not/a/directory")
0
rapidsai_public_repos/rapids-cmake/testing/other
rapidsai_public_repos/rapids-cmake/testing/other/FetchContent-hostile-legacy/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, 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.23.1) project(rapids-test-project LANGUAGES CXX) cmake_path(GET rapids-cmake-dir PARENT_PATH rapids-git-dir) cmake_path(APPEND rapids-git-dir ".git") # Remove this cache variable so we can properly test # fetching rapids-cmake work as intended unset(rapids-cmake-dir CACHE) set(CMAKE_MODULE_PATH "/not/a/directory") add_subdirectory(A) add_subdirectory(B)
0
rapidsai_public_repos/rapids-cmake/testing/other/FetchContent-hostile-legacy
rapidsai_public_repos/rapids-cmake/testing/other/FetchContent-hostile-legacy/B/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, 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. #============================================================================= # verify no rapids-cmake variables have been specified if(DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "") endif() include(FetchContent) FetchContent_Declare( rapids-cmake GIT_REPOSITORY ${rapids-git-dir} GIT_TAG HEAD ) FetchContent_MakeAvailable(rapids-cmake) if(NOT DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "expected variable rapids-cmake_SOURCE_DIR to exist") endif() if(NOT DEFINED rapids-cmake-dir) message(FATAL_ERROR "expected variable rapids-cmake-dir to exist") endif() if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH) message(FATAL_ERROR "expected variable rapids-cmake-dir to be inside CMAKE_MODULE_PATH") endif() if(NOT EXISTS "${rapids-cmake_SOURCE_DIR}/init.cmake") message(FATAL_ERROR "expected init.cmake to exist") endif()
0
rapidsai_public_repos/rapids-cmake/testing/other/FetchContent-hostile-legacy
rapidsai_public_repos/rapids-cmake/testing/other/FetchContent-hostile-legacy/A/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, 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. #============================================================================= # verify no rapids-cmake variables have been specified if(DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "") endif() include(FetchContent) FetchContent_Declare( rapids-cmake GIT_REPOSITORY ${rapids-git-dir} GIT_TAG HEAD ) FetchContent_MakeAvailable(rapids-cmake) if(NOT DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "expected variable rapids-cmake_SOURCE_DIR to exist") endif() if(NOT DEFINED rapids-cmake-dir) message(FATAL_ERROR "expected variable rapids-cmake-dir to exist") endif() if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH) message(FATAL_ERROR "expected variable rapids-cmake-dir to be inside CMAKE_MODULE_PATH") endif() if(NOT EXISTS "${rapids-cmake_SOURCE_DIR}/init.cmake") message(FATAL_ERROR "expected init.cmake to exist") endif() # Be hostile against rapids-cmake set(CMAKE_MODULE_PATH "/not/a/directory")
0
rapidsai_public_repos/rapids-cmake/testing/other
rapidsai_public_repos/rapids-cmake/testing/other/FetchContent-legacy/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, 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.23.1) project(rapids-test-project LANGUAGES CXX) cmake_path(GET rapids-cmake-dir PARENT_PATH rapids-root-dir) # Remove this cache variable so we can properly test # fetching rapids-cmake work as intended unset(rapids-cmake-dir CACHE) add_subdirectory(A) add_subdirectory(B)
0
rapidsai_public_repos/rapids-cmake/testing/other/FetchContent-legacy
rapidsai_public_repos/rapids-cmake/testing/other/FetchContent-legacy/B/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, 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. #============================================================================= # verify no rapids-cmake variables have been specified if(DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "") endif() include(FetchContent) FetchContent_Declare( rapids-cmake SOURCE_DIR "${rapids-root-dir}" ) FetchContent_MakeAvailable(rapids-cmake) if(NOT DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "expected variable rapids-cmake_SOURCE_DIR to exist") endif() if(NOT DEFINED rapids-cmake-dir) message(FATAL_ERROR "expected variable rapids-cmake-dir to exist") endif() if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH) message(FATAL_ERROR "expected variable rapids-cmake-dir to be inside CMAKE_MODULE_PATH") endif() if(NOT EXISTS "${rapids-cmake_SOURCE_DIR}/init.cmake") message(FATAL_ERROR "expected init.cmake to exist") endif()
0
rapidsai_public_repos/rapids-cmake/testing/other/FetchContent-legacy
rapidsai_public_repos/rapids-cmake/testing/other/FetchContent-legacy/A/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, 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. #============================================================================= # verify no rapids-cmake variables have been specified if(DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "") endif() include(FetchContent) FetchContent_Declare( rapids-cmake SOURCE_DIR "${rapids-root-dir}" ) FetchContent_MakeAvailable(rapids-cmake) if(NOT DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "expected variable rapids-cmake_SOURCE_DIR to exist") endif() if(NOT DEFINED rapids-cmake-dir) message(FATAL_ERROR "expected variable rapids-cmake-dir to exist") endif() if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH) message(FATAL_ERROR "expected variable rapids-cmake-dir to be inside CMAKE_MODULE_PATH") endif() if(NOT EXISTS "${rapids-cmake_SOURCE_DIR}/init.cmake") message(FATAL_ERROR "expected init.cmake to exist") endif()
0
rapidsai_public_repos/rapids-cmake/testing/other
rapidsai_public_repos/rapids-cmake/testing/other/rapids_cmake-multiple-simple/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, 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.23.1) project(rapids-test-project LANGUAGES CXX) cmake_path(GET rapids-cmake-dir PARENT_PATH rapids.cmake-location) cmake_path(APPEND rapids.cmake-location "RAPIDS.cmake") # Remove this cache variable so we can properly test # fetching rapids-cmake work as intended unset(rapids-cmake-dir CACHE) # Remove this cache variable so we can properly test # fetching rapids-cmake work as intended unset(rapids-cmake-dir CACHE) add_subdirectory(A) add_subdirectory(B)
0
rapidsai_public_repos/rapids-cmake/testing/other/rapids_cmake-multiple-simple
rapidsai_public_repos/rapids-cmake/testing/other/rapids_cmake-multiple-simple/B/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, 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. #============================================================================= # verify no rapids-cmake variables have been specified if(DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "") endif() include("${rapids.cmake-location}") if(NOT DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "expected variable rapids-cmake_SOURCE_DIR to exist") endif() if(NOT DEFINED rapids-cmake-dir) message(FATAL_ERROR "expected variable rapids-cmake-dir to exist") endif() if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH) message(FATAL_ERROR "expected variable rapids-cmake-dir to be inside CMAKE_MODULE_PATH") endif() if(NOT DEFINED rapids-cmake-version) message(FATAL_ERROR "expected variable rapids-cmake-version to exist") endif()
0
rapidsai_public_repos/rapids-cmake/testing/other/rapids_cmake-multiple-simple
rapidsai_public_repos/rapids-cmake/testing/other/rapids_cmake-multiple-simple/A/CMakeLists.txt
#============================================================================= # Copyright (c) 2021, 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. #============================================================================= # verify no rapids-cmake variables have been specified if(DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "") endif() include("${rapids.cmake-location}") if(NOT DEFINED rapids-cmake_SOURCE_DIR) message(FATAL_ERROR "expected variable rapids-cmake_SOURCE_DIR to exist") endif() if(NOT DEFINED rapids-cmake-dir) message(FATAL_ERROR "expected variable rapids-cmake-dir to exist") endif() if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH) message(FATAL_ERROR "expected variable rapids-cmake-dir to be inside CMAKE_MODULE_PATH") endif() if(NOT DEFINED rapids-cmake-version) message(FATAL_ERROR "expected variable rapids-cmake-version to exist") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/utils/cmake_ctest_test.cmake
#============================================================================= # 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. # 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) include(utils/cmake_test.cmake) function(add_cmake_ctest_test source_or_dir) add_cmake_test(TEST "${source_or_dir}" ${ARGN}) endfunction()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/utils/cmake_test.cmake
#============================================================================= # 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. # 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) include(utils/cmake_detect_generators.cmake) #[=======================================================================[.rst: add_cmake_build_test -------------------- .. versionadded:: v21.06.00 Generates a CMake test(s) for the given input CMake file or directory. Determines the set of supported generators from the below list and adds a test for each generator: - `Ninja` - `Ninja Multi-Config` - `Unix Makefiles` .. code-block:: cmake add_cmake_build_test( (config|build|test|install) <SourceOrDir> [SERIAL] [SHOULD_FAIL <expected error message string>] ) ``config`` Generate a CMake project and runs CMake config and generate step. Expects the test to raise an error to mark failures ``build`` Generate and build a CMake project. The CMake configuration step is constructed as a setup fixture. Expects the test to either raise an error during config, or fail to build to mark failures ``test`` Generate, build, and ctest a CMake project. The CMake config, and build steps are constructed as a setup fixture. Expects the underlying ctest execution to fail to mark failures ``install`` - Not implemented #]=======================================================================] function(add_cmake_test mode source_or_dir) set(options SERIAL) set(one_value SHOULD_FAIL) set(multi_value) cmake_parse_arguments(RAPIDS_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) cmake_detect_generators(supported_generators nice_gen_names) string(TOLOWER ${mode} mode) cmake_path(GET source_or_dir STEM test_name_stem) # Determine if we are past a relative source file or a directory set(have_source_dir FALSE) if(IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/${source_or_dir}") set(src_dir "${CMAKE_CURRENT_LIST_DIR}/${source_or_dir}/") elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${source_or_dir}") set(src_dir "${CMAKE_CURRENT_BINARY_DIR}/${test_name_stem}") set(test_cmake_file "${CMAKE_CURRENT_LIST_DIR}/${source_or_dir}") configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/project_template.cmake.in" "${src_dir}/CMakeLists.txt" @ONLY) else() message(FATAL_ERROR "Unable to find a file or directory named: ${source_or_dir}") endif() set(extra_configure_flags) if(DEFINED CPM_SOURCE_CACHE) list(APPEND extra_configure_flags "-DCPM_SOURCE_CACHE=${CPM_SOURCE_CACHE}") endif() foreach(generator gen_name IN ZIP_LISTS supported_generators nice_gen_names) set(test_name "${test_name_stem}-${gen_name}") set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/${test_name}-build") if(mode STREQUAL "config") add_test(NAME ${test_name} COMMAND ${CMAKE_COMMAND} -S ${src_dir} -B ${build_dir} -G "${generator}" ${extra_configure_flags} -Drapids-cmake-testing-dir=${PROJECT_SOURCE_DIR} -Drapids-cmake-dir=${PROJECT_SOURCE_DIR}/../rapids-cmake) elseif(mode STREQUAL "build") add_test(NAME ${test_name}_configure COMMAND ${CMAKE_COMMAND} -S ${src_dir} -B ${build_dir} -G "${generator}" ${extra_configure_flags} -Drapids-cmake-testing-dir=${PROJECT_SOURCE_DIR} -Drapids-cmake-dir=${PROJECT_SOURCE_DIR}/../rapids-cmake) add_test(NAME ${test_name} COMMAND ${CMAKE_COMMAND} --build ${build_dir} -j3000 ) set_tests_properties(${test_name}_configure PROPERTIES FIXTURES_SETUP ${test_name}) set_tests_properties(${test_name} PROPERTIES FIXTURES_REQUIRED ${test_name}) elseif(mode STREQUAL "test") add_test(NAME ${test_name}_configure COMMAND ${CMAKE_COMMAND} -S ${src_dir} -B ${build_dir} -G "${generator}" ${extra_configure_flags} -Drapids-cmake-testing-dir=${PROJECT_SOURCE_DIR} -Drapids-cmake-dir=${PROJECT_SOURCE_DIR}/../rapids-cmake) add_test(NAME ${test_name}_build COMMAND ${CMAKE_COMMAND} --build ${build_dir} -j3 ) set_tests_properties(${test_name}_build PROPERTIES DEPENDS ${test_name}_configure) add_test(NAME ${test_name} COMMAND ${CMAKE_CTEST_COMMAND} -C Debug -j400 -VV WORKING_DIRECTORY ${build_dir}) set_tests_properties(${test_name}_configure PROPERTIES FIXTURES_SETUP ${test_name}) set_tests_properties(${test_name}_build PROPERTIES FIXTURES_SETUP ${test_name}) set_tests_properties(${test_name} PROPERTIES FIXTURES_REQUIRED ${test_name}) elseif(mode STREQUAL "install") message(FATAL_ERROR "install mode not yet implemented by add_cmake_build_test") else() message(FATAL_ERROR "${mode} mode not one of the valid modes (config|build|install) by add_cmake_build_test") endif() if(RAPIDS_TEST_SERIAL) set_tests_properties(${test_name} PROPERTIES RUN_SERIAL ON) if(TEST ${test_name}_configure) message(STATUS "${test_name}_configure is serial") set_tests_properties(${test_name}_configure PROPERTIES RUN_SERIAL ON) endif() if(TEST ${test_name}_build) set_tests_properties(${test_name}_build PROPERTIES RUN_SERIAL ON) endif() endif() if(RAPIDS_TEST_SHOULD_FAIL) # Make sure we have a match set_tests_properties(${test_name} PROPERTIES WILL_FAIL ON) set_tests_properties(${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION "${RAPIDS_TEST_SHOULD_FAIL}") else() # Error out if we detect any CMake syntax warnings set_tests_properties(${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION "Syntax Warning") endif() # Apply a label to the test based on the folder it is in and the generator used get_filename_component(label_name ${CMAKE_CURRENT_LIST_DIR} NAME_WE) string(TOLOWER "${label_name}" lower_case_label ) set_tests_properties(${test_name} PROPERTIES LABELS "${lower_case_label};${gen_name}") endforeach() endfunction()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/utils/cmake_build_test.cmake
#============================================================================= # Copyright (c) 2021, 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) include(utils/cmake_test.cmake) function(add_cmake_build_test source_or_dir) add_cmake_test(BUILD "${source_or_dir}" ${ARGN}) endfunction()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/utils/cmake_config_test.cmake
#============================================================================= # Copyright (c) 2021, 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) include(utils/cmake_test.cmake) function(add_cmake_config_test source_or_dir) add_cmake_test(CONFIG "${source_or_dir}" ${ARGN}) endfunction()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/utils/determine_gpu_count.cmake
#============================================================================= # 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. #============================================================================= function(determine_gpu_count ) #run nvidia-smi and extract gpu details execute_process(COMMAND nvidia-smi --list-gpus OUTPUT_VARIABLE smi_output) string(REPLACE "\n" ";" smi_output "${smi_output}") list(POP_BACK smi_output) #remove the trailing `;` entry list(LENGTH smi_output gpu_count) set(RAPIDS_CMAKE_TESTING_GPU_COUNT ${gpu_count} PARENT_SCOPE) endfunction()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/utils/project_template.cmake.in
#============================================================================= # Copyright (c) 2021, 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.23.1) include(FetchContent) set(local-rapids-cmake-root "${rapids-cmake-dir}/..") cmake_path(NORMAL_PATH local-rapids-cmake-root) set(scratch_dir "${CMAKE_CURRENT_BINARY_DIR}/_deps") # emulate the variables and properties that FetchContent would set so # tests that themselves download rapids-cmake will use the version we have # symlinked. set(rapids-cmake_SOURCE_DIR "${scratch_dir}/rapids-cmake-src") set(rapids-cmake_BINARY_DIR "${scratch_dir}/rapids-cmake-build") set(rapids-cmake_POPULATED TRUE) set(prefix "_FetchContent_rapids-cmake") set_property(GLOBAL PROPERTY ${prefix}_sourceDir "${rapids-cmake_SOURCE_DIR}") set_property(GLOBAL PROPERTY ${prefix}_binaryDir "${rapids-cmake_BINARY_DIR}") define_property(GLOBAL PROPERTY ${prefix}_populated) # construct a symlink from the source to the build dir # so we get the latest local changes without issue execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory "${scratch_dir}") execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink "${local-rapids-cmake-root}" "${rapids-cmake_SOURCE_DIR}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE) unset(scratch_dir) add_subdirectory(${rapids-cmake_SOURCE_DIR} ${rapids-cmake_BINARY_DIR}) # We need to enable at least one language so that we get properly # generated system search paths. project(@test_name_stem@ LANGUAGES CXX) include("@test_cmake_file@")
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/utils/cmake_detect_generators.cmake
#============================================================================= # Copyright (c) 2021, 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: cmake_detect_generators ----------------------- .. versionadded:: v21.06.00 Reports back what generators from the set of below are usable on the current machine - `Ninja` - `Ninja Multi-Config` - `Unix Makefiles` #]=======================================================================] function(cmake_detect_generators generator_name_var fancy_name_var) # See CMakeUnixFindMake and CMakeNinjaFindMake find_program(RAPIDS_TESTING_MAKE_GEN NAMES gmake make smake NAMES_PER_DIR) find_program(RAPIDS_TESTING_NINJA_GEN NAMES ninja-build ninja samu NAMES_PER_DIR) if(RAPIDS_TESTING_MAKE_GEN) list(APPEND supported_gens "Unix Makefiles") list(APPEND nice_names "makefile") endif() if(RAPIDS_TESTING_NINJA_GEN) list(APPEND supported_gens "Ninja") list(APPEND nice_names "ninja") list(APPEND supported_gens "Ninja Multi-Config") list(APPEND nice_names "ninja_multi-config") endif() set(${generator_name_var} "${supported_gens}" PARENT_SCOPE) set(${fancy_name_var} "${nice_names}" PARENT_SCOPE) endfunction()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/utils/setup_cpm_cache.cmake
#============================================================================= # 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. # 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. #============================================================================= function(setup_cpm_cache ) set(CPM_SOURCE_CACHE "${CMAKE_BINARY_DIR}") cmake_path(APPEND_STRING CPM_SOURCE_CACHE "/cache") set(src_dir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/fill_cache/") set(build_dir "${CPM_SOURCE_CACHE}") #download all pre-configured rapids-cmake packages execute_process(COMMAND ${CMAKE_COMMAND} -Drapids-cmake-dir=${PROJECT_SOURCE_DIR}/../rapids-cmake -S ${src_dir} -B ${build_dir} WORKING_DIRECTORY ${src_dir} ) set(CPM_SOURCE_CACHE "${CPM_SOURCE_CACHE}" PARENT_SCOPE) endfunction()
0
rapidsai_public_repos/rapids-cmake/testing/utils
rapidsai_public_repos/rapids-cmake/testing/utils/fill_cache/CMakeLists.txt
#============================================================================= # 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. # 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.23.1) project(fill_cache LANGUAGES CXX) include(${rapids-cmake-dir}/cpm/init.cmake) include(${rapids-cmake-dir}/cpm/cuco.cmake) include(${rapids-cmake-dir}/cpm/gbench.cmake) include(${rapids-cmake-dir}/cpm/gtest.cmake) include(${rapids-cmake-dir}/cpm/libcudacxx.cmake) include(${rapids-cmake-dir}/cpm/nvbench.cmake) include(${rapids-cmake-dir}/cpm/nvcomp.cmake) include(${rapids-cmake-dir}/cpm/rmm.cmake) include(${rapids-cmake-dir}/cpm/spdlog.cmake) include(${rapids-cmake-dir}/cpm/fmt.cmake) include(${rapids-cmake-dir}/cpm/thrust.cmake) rapids_cpm_init() set(CPM_SOURCE_CACHE "${CMAKE_BINARY_DIR}") # Download all source packages set(CPM_DOWNLOAD_ALL "ON") rapids_cpm_cuco(DOWNLOAD_ONLY ON) rapids_cpm_gbench(DOWNLOAD_ONLY ON) rapids_cpm_gtest(DOWNLOAD_ONLY ON) rapids_cpm_libcudacxx(DOWNLOAD_ONLY ON) 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(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 ) # Download all binary packages set(CPM_DOWNLOAD_ALL "OFF") rapids_cpm_nvcomp(USE_PROPRIETARY_BINARY ON DOWNLOAD_ONLY ON)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/rapids-cuda.cmake
#============================================================================= # Copyright (c) 2021, 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-cuda.cmake)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/set_arch-all-deprecated.cmake
#============================================================================= # 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_architectures.cmake) rapids_cuda_set_architectures(ALL)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/set_arch-existing.cmake
#============================================================================= # 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. # 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_architectures.cmake) # Required by `NATIVE` as it does compiler detection enable_language(CUDA) set(user_value "user-value") set(CMAKE_CUDA_ARCHITECTURES ${user_value}) rapids_cuda_set_architectures(RAPIDS) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES should exist after calling rapids_cuda_set_architectures()") endif() if(CMAKE_CUDA_ARCHITECTURES STREQUAL user_value) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES should be modified by calling rapids_cuda_set_architectures()") endif() set(CMAKE_CUDA_ARCHITECTURES ${user_value}) rapids_cuda_set_architectures(NATIVE) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES should exist after calling rapids_cuda_set_architectures()") endif() if(CMAKE_CUDA_ARCHITECTURES STREQUAL user_value) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES should be modified by calling rapids_cuda_set_architectures()") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/CMakeLists.txt
#============================================================================= # 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. # 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. #============================================================================= add_cmake_config_test( rapids-cuda.cmake ) add_cmake_config_test( init_runtime-existing.cmake ) 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 ) add_cmake_config_test( init_arch-native-via-env.cmake ) add_cmake_config_test( init_arch-rapids.cmake ) add_cmake_config_test( init_arch-rapids-via-env.cmake ) add_cmake_config_test( init_arch-user.cmake ) add_cmake_config_test( init_arch-user-via-env.cmake ) add_cmake_config_test( patch_toolkit.cmake ) add_cmake_config_test( patch_toolkit-nested ) add_cmake_config_test( set_arch-existing.cmake ) add_cmake_config_test( set_arch-invalid-mode.cmake ) add_cmake_config_test( set_arch-native.cmake ) add_cmake_config_test( set_arch-rapids.cmake ) set(deprecated_message [=[rapids-cmake policy [deprecated=23.02 removed=23.06]: Usage of `ALL`]=]) add_cmake_config_test( init_arch-all-via-env-deprecated.cmake SHOULD_FAIL "${deprecated_message}") add_cmake_config_test( init_arch-all-deprecated.cmake SHOULD_FAIL "${deprecated_message}") add_cmake_config_test( set_arch-all-deprecated.cmake SHOULD_FAIL "${deprecated_message}") set(deprecated_message [=[rapids-cmake policy [deprecated=23.02 removed=23.06]: Usage of `""`]=]) add_cmake_config_test( init_arch-native-via-empty-str-deprecated SHOULD_FAIL "${deprecated_message}")
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/init_arch-user.cmake
#============================================================================= # 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. # 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/init_architectures.cmake) set(CMAKE_CUDA_ARCHITECTURES "80") rapids_cuda_init_architectures(rapids-project) project(rapids-project LANGUAGES CUDA) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES should exist after calling rapids_cuda_init_architectures()") endif() if(NOT CMAKE_CUDA_ARCHITECTURES STREQUAL "80") message(FATAL_ERROR "rapids_cuda_init_architectures didn't ignore users CUDA_ARCHITECTURES value") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/init_arch-rapids-via-env.cmake
#============================================================================= # 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(${rapids-cmake-dir}/cuda/init_architectures.cmake) set(CMAKE_ERROR_DEPRECATED ON) set(ENV{CUDAARCHS} "RAPIDS") rapids_cuda_init_architectures(rapids-project) project(rapids-project LANGUAGES CUDA) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES should exist after calling rapids_cuda_init_architectures()") endif() if(CMAKE_CUDA_ARCHITECTURES STREQUAL "RAPIDS") message(FATAL_ERROR "rapids_cuda_init_architectures didn't init CUDA_ARCHITECTURES") endif() include("${rapids-cmake-testing-dir}/cuda/validate-cuda-rapids.cmake")
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/init_runtime-shared.cmake
#============================================================================= # Copyright (c) 2021, 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/init_runtime.cmake) rapids_cuda_init_runtime(USE_STATIC FALSE) if( NOT CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL "SHARED") message(FATAL_ERROR "rapids_cuda_init_runtime didn't correctly set CMAKE_CUDA_RUNTIME_LIBRARY") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/init_arch-native.cmake
#============================================================================= # 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. # 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/init_architectures.cmake) set(CMAKE_ERROR_DEPRECATED ON) set(CMAKE_CUDA_ARCHITECTURES "NATIVE") rapids_cuda_init_architectures(rapids-project) project(rapids-project LANGUAGES CUDA) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES should exist after calling rapids_cuda_init_architectures()") endif() if(CMAKE_CUDA_ARCHITECTURES STREQUAL "NATIVE") message(FATAL_ERROR "rapids_cuda_init_architectures didn't init CUDA_ARCHITECTURES") endif() include("${rapids-cmake-testing-dir}/cuda/validate-cuda-native.cmake")
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/init_runtime-static.cmake
#============================================================================= # Copyright (c) 2021, 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/init_runtime.cmake) rapids_cuda_init_runtime(USE_STATIC TRUE) if( NOT CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL "STATIC") message(FATAL_ERROR "rapids_cuda_init_runtime didn't correctly set CMAKE_CUDA_RUNTIME_LIBRARY") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/init_arch-all-via-env-deprecated.cmake
#============================================================================= # 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/init_architectures.cmake) set(ENV{CUDAARCHS} "ALL") rapids_cuda_init_architectures(rapids-project) project(rapids-project LANGUAGES CUDA)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/set_arch-invalid-mode.cmake
#============================================================================= # Copyright (c) 2021, 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_architectures.cmake) set(user_value "user-value") set(CMAKE_CUDA_ARCHITECTURES ${user_value}) rapids_cuda_set_architectures(invalid-mode) message(STATUS "CMAKE_CUDA_ARCHITECTURES: ${CMAKE_CUDA_ARCHITECTURES}") if(NOT CMAKE_CUDA_ARCHITECTURES STREQUAL user_value) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES shouldn't be modified by " "rapids_cuda_set_architectures() when past an invalid mode") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/validate-cuda-native.cmake
#============================================================================= # Copyright (c) 2021, 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. #============================================================================= # The only thing we can test is that everything comes # back appended with -real foreach(value IN LISTS CMAKE_CUDA_ARCHITECTURES) # verify it ends with `-real` string(FIND ${value} "-real" location) if(location LESS "0") message(FATAL_ERROR "All values in CMAKE_CUDA_ARCHITECTURES should have `-real`") endif() endforeach()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/init_arch-existing-project-flags.cmake
#============================================================================= # 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. # 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/init_architectures.cmake) # Verify that `RAPIDS` logic works correctly file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/fileA.cmake" "set(file_A MAGIC_VALUE)") set(CMAKE_PROJECT_example_INCLUDE "${CMAKE_CURRENT_BINARY_DIR}/fileA.cmake") set(CMAKE_CUDA_ARCHITECTURES "RAPIDS") rapids_cuda_init_architectures(example) project(example LANGUAGES CUDA) if(NOT DEFINED file_A) message(FATAL_ERROR "rapids_cuda_init_architectures can't overwrite existing `project()` include hooks") endif() # Verify that `NATIVE` logic works correctly file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/fileB.cmake" "set(file_B MAGIC_VALUE)") set(CMAKE_PROJECT_example2_INCLUDE "${CMAKE_CURRENT_BINARY_DIR}/fileB.cmake") set(CMAKE_CUDA_ARCHITECTURES "NATIVE") rapids_cuda_init_architectures(example2) project(example2 LANGUAGES CUDA) if(NOT DEFINED file_B) message(FATAL_ERROR "rapids_cuda_init_architectures can't overwrite existing `project()` include hooks") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/init_runtime-multiple.cmake
#============================================================================= # Copyright (c) 2021, 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/init_runtime.cmake) rapids_cuda_init_runtime(USE_STATIC FALSE) if( NOT CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL "SHARED") message(FATAL_ERROR "rapids_cuda_init_runtime didn't correctly set CMAKE_CUDA_RUNTIME_LIBRARY") endif() rapids_cuda_init_runtime(USE_STATIC TRUE) if( NOT CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL "SHARED") message(FATAL_ERROR "apids_cuda_init_runtime shouldn't override an existing value") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/init_arch-user-via-env.cmake
#============================================================================= # 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(${rapids-cmake-dir}/cuda/init_architectures.cmake) set(ENV{CUDAARCHS} "80") rapids_cuda_init_architectures(rapids-project) project(rapids-project LANGUAGES CUDA) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES should exist after calling rapids_cuda_init_architectures()") endif() if(NOT CMAKE_CUDA_ARCHITECTURES STREQUAL "80") message(FATAL_ERROR "rapids_cuda_init_architectures didn't ignore users CUDA_ARCHITECTURES value") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/set_runtime-shared.cmake
#============================================================================= # 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 "$<TARGET_NAME_IF_EXISTS:CUDA::cudart>" IN_LIST linked_libs) message(FATAL_ERROR "rapids_cuda_set_runtime didn't privately link to CUDA::cudart_static") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/set_arch-native.cmake
#============================================================================= # Copyright (c) 2021, 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_architectures.cmake) # Required by `NATIVE` as it does compiler detection enable_language(CUDA) rapids_cuda_set_architectures(NATIVE) include("${rapids-cmake-testing-dir}/cuda/validate-cuda-native.cmake")
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/validate-cuda-rapids.cmake
#============================================================================= # 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. # 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. #============================================================================= # Make sure last item doesn't have "-real" list(POP_BACK CMAKE_CUDA_ARCHITECTURES last_value) string(FIND ${last_value} "-real" location) if(NOT location EQUAL -1) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES last value shouldn't have `-real`") endif() # Each item should be `number-real` and should be ordered from low to high. # In addition the values should map to Volta+ GPU arch ( 70+ ) set(previous_value 69) foreach(value IN LISTS CMAKE_CUDA_ARCHITECTURES) # verify it ends with `-real` string(FIND ${value} "-real" location) if(location LESS "0") message(FATAL_ERROR "All values but the last in CMAKE_CUDA_ARCHITECTURES should have `-real`") endif() string(REPLACE "-real" "" value "${value}") if( value LESS previous_value ) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES values should be ordered lowest to highest." "with lowest >= 70") endif() endforeach() if( last_value LESS previous_value ) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES values should be ordered lowest to highest." "with lowest >= 70") endif() list(APPEND CMAKE_CUDA_ARCHITECTURES ${last_value})
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/patch_toolkit.cmake
#============================================================================= # Copyright (c) 2022, 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/patch_toolkit.cmake) function(verify_links_to target library) get_target_property(link_libs ${target} INTERFACE_LINK_LIBRARIES) if(NOT ${library} IN_LIST link_libs) message(FATAL_ERROR "${target} doesn't link to ${library}") endif() endfunction() # Verify we can call before find_package rapids_cuda_patch_toolkit() find_package(CUDAToolkit) rapids_cuda_patch_toolkit() if(TARGET CUDA::cublas_static) verify_links_to(CUDA::cublas CUDA::cublasLt) verify_links_to(CUDA::cublas_static CUDA::cublasLt_static) verify_links_to(CUDA::cusolver_static CUDA::cusolver_lapack_static) endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/init_arch-all-deprecated.cmake
#============================================================================= # 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/init_architectures.cmake) set(CMAKE_CUDA_ARCHITECTURES "ALL") rapids_cuda_init_architectures(rapids-project) project(rapids-project LANGUAGES CUDA)
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/init_runtime-existing.cmake
#============================================================================= # Copyright (c) 2021, 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/init_runtime.cmake) set(user_value "fake-value") set(CMAKE_CUDA_RUNTIME_LIBRARY ${user_value}) rapids_cuda_init_runtime(USE_STATIC TRUE) if( NOT CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL user_value) message(FATAL_ERROR "rapids_cuda_init_runtime shouldn't override user value") endif() rapids_cuda_init_runtime(USE_STATIC FALSE) if( NOT CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL user_value) message(FATAL_ERROR "rapids_cuda_init_runtime shouldn't override user value") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/set_arch-rapids.cmake
#============================================================================= # 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. # 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_architectures.cmake) rapids_cuda_set_architectures(RAPIDS) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES should exist after calling rapids_cuda_set_architectures()") endif() include("${rapids-cmake-testing-dir}/cuda/validate-cuda-rapids.cmake")
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/set_runtime-static.cmake
#============================================================================= # 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 "$<TARGET_NAME_IF_EXISTS:CUDA::cudart_static>" IN_LIST linked_libs) message(FATAL_ERROR "rapids_cuda_set_runtime didn't privately link to CUDA::cudart_static") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/init_arch-rapids.cmake
#============================================================================= # 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. # 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/init_architectures.cmake) set(CMAKE_CUDA_ARCHITECTURES "RAPIDS") rapids_cuda_init_architectures(rapids-project) project(rapids-project LANGUAGES CUDA) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES should exist after calling rapids_cuda_init_architectures()") endif() if(CMAKE_CUDA_ARCHITECTURES STREQUAL "RAPIDS") message(FATAL_ERROR "rapids_cuda_init_architectures didn't init CUDA_ARCHITECTURES") endif() include("${rapids-cmake-testing-dir}/cuda/validate-cuda-rapids.cmake")
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/set_runtime-on-interface-target.cmake
#============================================================================= # 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 "$<TARGET_NAME_IF_EXISTS:CUDA::cudart_static>" IN_LIST linked_libs) message(FATAL_ERROR "rapids_cuda_set_runtime shouldn't set CUDA::cudart_static in target linked libraries correctly") endif()
0
rapidsai_public_repos/rapids-cmake/testing
rapidsai_public_repos/rapids-cmake/testing/cuda/init_arch-native-via-env.cmake
#============================================================================= # 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(${rapids-cmake-dir}/cuda/init_architectures.cmake) set(CMAKE_ERROR_DEPRECATED ON) set(ENV{CUDAARCHS} "NATIVE") rapids_cuda_init_architectures(rapids-project) project(rapids-project LANGUAGES CUDA) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES should exist after calling rapids_cuda_init_architectures()") endif() if(CMAKE_CUDA_ARCHITECTURES STREQUAL "NATIVE") message(FATAL_ERROR "rapids_cuda_init_architectures didn't init CUDA_ARCHITECTURES") endif() include("${rapids-cmake-testing-dir}/cuda/validate-cuda-native.cmake")
0
rapidsai_public_repos/rapids-cmake/testing/cuda
rapidsai_public_repos/rapids-cmake/testing/cuda/patch_toolkit-nested/CMakeLists.txt
#============================================================================= # Copyright (c) 2022, 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.23.1) project(rapids-project LANGUAGES CUDA) include(${rapids-cmake-dir}/cuda/patch_toolkit.cmake) function(verify_links_to target library) get_target_property(link_libs ${target} INTERFACE_LINK_LIBRARIES) if(NOT ${library} IN_LIST link_libs) message(FATAL_ERROR "${target} doesn't link to ${library}") endif() endfunction() find_package(CUDAToolkit) rapids_cuda_patch_toolkit() add_subdirectory(subdir) if(TARGET CUDA::cublas_static) verify_links_to(CUDA::cublas CUDA::cublasLt) verify_links_to(CUDA::cublas_static CUDA::cublasLt_static) verify_links_to(CUDA::cusolver_static CUDA::cusolver_lapack_static) endif()
0
rapidsai_public_repos/rapids-cmake/testing/cuda/patch_toolkit-nested
rapidsai_public_repos/rapids-cmake/testing/cuda/patch_toolkit-nested/subdir/CMakeLists.txt
#============================================================================= # Copyright (c) 2022, 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/patch_toolkit.cmake) rapids_cuda_patch_toolkit() find_package(CUDAToolkit) rapids_cuda_patch_toolkit() if(TARGET CUDA::cublas_static) verify_links_to(CUDA::cublas CUDA::cublasLt) verify_links_to(CUDA::cublas_static CUDA::cublasLt_static) verify_links_to(CUDA::cusolver_static CUDA::cusolver_lapack_static) endif()
0
rapidsai_public_repos/rapids-cmake/testing/cuda
rapidsai_public_repos/rapids-cmake/testing/cuda/init_arch-all-via-undef/CMakeLists.txt
#============================================================================= # 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. # 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/init_architectures.cmake) cmake_minimum_required(VERSION 3.23.1) unset(CMAKE_CUDA_ARCHITECTURES ) rapids_cuda_init_architectures(rapids-project) project(rapids-project LANGUAGES CUDA) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(FATAL_ERROR "rapids_cuda_init_architectures didn't init CUDA_ARCHITECTURES") endif() if(CMAKE_CUDA_ARCHITECTURES STREQUAL "ALL") message(FATAL_ERROR "rapids_cuda_init_architectures didn't init CUDA_ARCHITECTURES") endif() include("${rapids-cmake-testing-dir}/cuda/validate-cuda-rapids.cmake")
0
rapidsai_public_repos/rapids-cmake/testing/cuda
rapidsai_public_repos/rapids-cmake/testing/cuda/init_arch-native-via-empty-str-deprecated/CMakeLists.txt
#============================================================================= # 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/init_architectures.cmake) cmake_minimum_required(VERSION 3.23.1) set(CMAKE_CUDA_ARCHITECTURES "") rapids_cuda_init_architectures(rapids-project) project(rapids-project LANGUAGES CUDA) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(FATAL_ERROR "rapids_cuda_init_architectures didn't init CUDA_ARCHITECTURES") endif() if(CMAKE_CUDA_ARCHITECTURES STREQUAL "") message(FATAL_ERROR "rapids_cuda_init_architectures didn't init CUDA_ARCHITECTURES") endif() include("${rapids-cmake-testing-dir}/cuda/validate-cuda-native.cmake")
0