-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proprietary_binary now supports cuda toolkit version placeholders (#377)
This will allow rapids_cpm to customize download urls based on the CUDA Toolkit version. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: #377
- Loading branch information
1 parent
7db9ade
commit c992589
Showing
9 changed files
with
222 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#============================================================================= | ||
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
testing/cpm/cpm_proprietary-url-ctk-version-find-ctk.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#============================================================================= | ||
# Copyright (c) 2023, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
include(${rapids-cmake-dir}/cpm/init.cmake) | ||
include(${rapids-cmake-dir}/cpm/package_override.cmake) | ||
include(${rapids-cmake-dir}/cpm/detail/get_proprietary_binary_url.cmake) | ||
include(${rapids-cmake-dir}/cpm/detail/package_details.cmake) | ||
|
||
rapids_cpm_init() | ||
|
||
# Need to write out an override file with a proprietary blob url | ||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/override.json | ||
[=[ | ||
{ | ||
"packages" : { | ||
"test_binary" : { | ||
"version" : "2.6.1", | ||
"proprietary_binary" : { | ||
"x86_64-linux" : "https://fake.url.com/${version}/${cuda-toolkit-version}/x86_64_${cuda-toolkit-version-major}.tgz", | ||
"aarch64-linux" : "https://fake.url.com/${version}/${cuda-toolkit-version}/aarch64_${cuda-toolkit-version-major}.tgz", | ||
} | ||
} | ||
} | ||
} | ||
]=]) | ||
rapids_cpm_package_override(${CMAKE_CURRENT_BINARY_DIR}/override.json) | ||
|
||
# Verify that the placeholders are evaluated correctly from `enable_language(CUDA)` | ||
rapids_cpm_package_details(test_binary version repository tag shallow exclude) | ||
rapids_cpm_get_proprietary_binary_url(test_binary ${version} url) | ||
|
||
find_package(CUDAToolkit) | ||
set(CTK_VER ${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}) | ||
set(CTK_VER_M ${CUDAToolkit_VERSION_MAJOR}) | ||
set(valid_url "https://fake.url.com/2.6.1/${CTK_VER}/${CMAKE_SYSTEM_PROCESSOR}_${CTK_VER_M}.tgz") | ||
if(NOT valid_url STREQUAL url) | ||
message(FATAL_ERROR "Expected: ${valid_url} got: ${url}") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#============================================================================= | ||
# Copyright (c) 2023, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
include(${rapids-cmake-dir}/cpm/init.cmake) | ||
include(${rapids-cmake-dir}/cpm/package_override.cmake) | ||
include(${rapids-cmake-dir}/cpm/detail/get_proprietary_binary_url.cmake) | ||
include(${rapids-cmake-dir}/cpm/detail/package_details.cmake) | ||
|
||
rapids_cpm_init() | ||
|
||
# Need to write out an override file with a proprietary blob url | ||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/override.json | ||
[=[ | ||
{ | ||
"packages" : { | ||
"test_binary" : { | ||
"version" : "2.6.1", | ||
"proprietary_binary" : { | ||
"x86_64-linux" : "https://fake.url.com/${version}/${cuda-toolkit-version}/x86_64_${cuda-toolkit-version-major}.tgz", | ||
"aarch64-linux" : "https://fake.url.com/${version}/${cuda-toolkit-version}/aarch64_${cuda-toolkit-version-major}.tgz", | ||
} | ||
} | ||
} | ||
} | ||
]=]) | ||
rapids_cpm_package_override(${CMAKE_CURRENT_BINARY_DIR}/override.json) | ||
|
||
# Verify that the placeholders are evaluated correctly from `find_package(CUDAToolkit)` | ||
find_package(CUDAToolkit REQUIRED) | ||
rapids_cpm_package_details(test_binary version repository tag shallow exclude) | ||
rapids_cpm_get_proprietary_binary_url(test_binary ${version} url) | ||
|
||
set(CTK_VER ${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}) | ||
set(CTK_VER_M ${CUDAToolkit_VERSION_MAJOR}) | ||
set(valid_url "https://fake.url.com/2.6.1/${CTK_VER}/${CMAKE_SYSTEM_PROCESSOR}_${CTK_VER_M}.tgz") | ||
if(NOT valid_url STREQUAL url) | ||
message(FATAL_ERROR "Expected: ${valid_url} got: ${url}") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#============================================================================= | ||
# Copyright (c) 2023, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
include(${rapids-cmake-dir}/cpm/init.cmake) | ||
include(${rapids-cmake-dir}/cpm/package_override.cmake) | ||
include(${rapids-cmake-dir}/cpm/detail/get_proprietary_binary_url.cmake) | ||
include(${rapids-cmake-dir}/cpm/detail/package_details.cmake) | ||
|
||
rapids_cpm_init() | ||
|
||
# Need to write out an override file with a proprietary blob url | ||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/override.json | ||
[=[ | ||
{ | ||
"packages" : { | ||
"test_binary" : { | ||
"version" : "2.6.1", | ||
"proprietary_binary" : { | ||
"x86_64-linux" : "https://fake.url.com/x86_${version}.tgz", | ||
"aarch64-linux" : "https://fake.url.com/aarch_${version}.tgz", | ||
} | ||
} | ||
} | ||
} | ||
]=]) | ||
rapids_cpm_package_override(${CMAKE_CURRENT_BINARY_DIR}/override.json) | ||
|
||
rapids_cpm_package_details(test_binary version repository tag shallow exclude) | ||
rapids_cpm_get_proprietary_binary_url(test_binary ${version} nvcomp_url) | ||
|
||
# Verify that we didn't go searching for the CUDAToolkit | ||
if(TARGET CUDA::cudart_static OR TARGET CUDA::cudart) | ||
message(FATAL_ERROR "test_binary didn't use the cuda toolkit placeholder, but searching for it still occurred") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters