-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[cuda] Export vcpkg_find_cuda.cmake #13440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| Source: cuda | ||
| Version: 10.1 | ||
| Port-Version: 2 | ||
| Port-Version: 3 | ||
| Description: A parallel computing platform and programming model | ||
| Homepage: https://developer.nvidia.com/cuda-toolkit |
This file contains hidden or 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 hidden or 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,91 @@ | ||
| function(vcpkg_find_cuda) | ||
| cmake_parse_arguments(PARSE_ARGV 0 vfc "" "OUT_CUDA_TOOLKIT_ROOT" "") | ||
|
|
||
| if(NOT vfc_OUT_CUDA_TOOLKIT_ROOT) | ||
| message(FATAL_ERROR "vcpkg_find_cuda() requres an OUT_CUDA_TOOLKIT_ROOT argument") | ||
| endif() | ||
|
|
||
| set(CUDA_REQUIRED_VERSION "10.1.0") | ||
|
|
||
| set(CUDA_PATHS | ||
| ENV CUDA_PATH | ||
| ENV CUDA_BIN_PATH | ||
| ENV CUDA_PATH_V11_0 | ||
| ENV CUDA_PATH_V10_2 | ||
| ENV CUDA_PATH_V10_1) | ||
|
Comment on lines
+10
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of search in all those dirs env |
||
|
|
||
| if (VCPKG_TARGET_IS_WINDOWS) | ||
| find_program(NVCC | ||
| NAMES nvcc.exe | ||
| PATHS | ||
| ${CUDA_PATHS} | ||
| PATH_SUFFIXES bin bin64 | ||
| DOC "Toolkit location." | ||
| NO_DEFAULT_PATH | ||
| ) | ||
| else() | ||
| if (VCPKG_TARGET_IS_LINUX) | ||
| set(platform_base "/usr/local/cuda-") | ||
| else() | ||
| set(platform_base "/Developer/NVIDIA/CUDA-") | ||
| endif() | ||
|
|
||
| file(GLOB possible_paths "${platform_base}*") | ||
| set(FOUND_PATH ) | ||
| foreach (p ${possible_paths}) | ||
| # Extract version number from end of string | ||
| string(REGEX MATCH "[0-9][0-9]?\\.[0-9]$" p_version ${p}) | ||
| if (IS_DIRECTORY ${p} AND p_version) | ||
| if (p_version VERSION_GREATER_EQUAL CUDA_REQUIRED_VERSION) | ||
| set(FOUND_PATH ${p}) | ||
| break() | ||
| endif() | ||
| endif() | ||
| endforeach() | ||
|
|
||
| find_program(NVCC | ||
| NAMES nvcc | ||
| PATHS | ||
| ${CUDA_PATHS} | ||
| PATHS ${FOUND_PATH} | ||
| PATH_SUFFIXES bin bin64 | ||
| DOC "Toolkit location." | ||
| NO_DEFAULT_PATH | ||
| ) | ||
| endif() | ||
|
|
||
| set(error_code 1) | ||
| if (NVCC) | ||
| execute_process( | ||
| COMMAND ${NVCC} --version | ||
| OUTPUT_VARIABLE NVCC_OUTPUT | ||
| RESULT_VARIABLE error_code) | ||
| endif() | ||
|
|
||
|
|
||
| if (error_code) | ||
| message(STATUS "Executing ${NVCC} --version resulted in error: ${error_code}") | ||
| message(FATAL_ERROR "Could not find CUDA. Before continuing, please download and install CUDA (v${CUDA_REQUIRED_VERSION} or higher) from:" | ||
| "\n https://developer.nvidia.com/cuda-downloads\n") | ||
| endif() | ||
|
|
||
| # Sample output: | ||
| # NVIDIA (R) Cuda compiler driver | ||
| # Copyright (c) 2005-2016 NVIDIA Corporation | ||
| # Built on Sat_Sep__3_19:05:48_CDT_2016 | ||
| # Cuda compilation tools, release 8.0, V8.0.44 | ||
| string(REGEX MATCH "V([0-9]+)\\.([0-9]+)\\.([0-9]+)" CUDA_VERSION ${NVCC_OUTPUT}) | ||
| message(STATUS "Found CUDA ${CUDA_VERSION}") | ||
| set(CUDA_VERSION_MAJOR ${CMAKE_MATCH_1}) | ||
| set(CUDA_VERSION_MINOR ${CMAKE_MATCH_2}) | ||
| set(CUDA_VERSION_PATCH ${CMAKE_MATCH_3}) | ||
|
|
||
| if (CUDA_VERSION_MAJOR LESS 10 AND CUDA_VERSION_MINOR LESS 1) | ||
| message(FATAL_ERROR "CUDA ${CUDA_VERSION} found, but v${CUDA_REQUIRED_VERSION} is required. Please download and install a more recent version of CUDA from:" | ||
| "\n https://developer.nvidia.com/cuda-downloads\n") | ||
| endif() | ||
|
|
||
| get_filename_component(CUDA_TOOLKIT_ROOT "${NVCC}" DIRECTORY) | ||
| get_filename_component(CUDA_TOOLKIT_ROOT "${CUDA_TOOLKIT_ROOT}" DIRECTORY) | ||
| set(${vfc_OUT_CUDA_TOOLKIT_ROOT} "${CUDA_TOOLKIT_ROOT}" PARENT_SCOPE) | ||
| endfunction() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason not to go full
vcpkg_find_fortranand useCMakeDetermineCUDACompiler.cmake? Just trick it to ingore theFATAL_ERRORby settingCMAKE_GENERATORtoNinja