summaryrefslogtreecommitdiff
path: root/Modules/CMakeDetermineCUDACompiler.cmake
Commit message (Collapse)AuthorAgeFilesLines
* Modules: Record system inspection steps in the configure logBrad King2023-01-181-6/+6
| | | | | | | | Replace old-style `file(APPEND .../CMake{Output,Error}.log)` logging with calls to `message(CONFIGURE_LOG)` to record the steps in the `CMakeConfigureLog.yaml` configure log instead. Issue: #23200
* Merge topic 'cuda_support_sm90a'Brad King2022-09-071-1/+1
|\ | | | | | | | | | | | | 234aa7e0aa CUDA: Support upcoming sm90a architecture Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !7649
| * CUDA: Support upcoming sm90a architectureRobert Maynard2022-09-061-1/+1
| | | | | | | | | | | | The architecture values are being extended to have at time a trailing `a`. This updates the CMake regex to support this syntax.
* | CMakeParseImplicitLinkInfo: Better detection of msvcRobert Maynard2022-09-021-1/+2
|/ | | | Use the compiler id information in addition to checking for `cl.exe`.
* CUDA: Restore CMAKE_CUDA_ARCHITECTURES support for -real and -virtual suffixesBrad King2022-04-291-3/+4
| | | | | | Fix the validation regex added by commit c267ed205a (CUDA: Defer architecture testing to the compiler testing step, 2022-04-25) to allow these values.
* CUDA: Defer architecture testing to the compiler testing stepBrad King2022-04-251-93/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Verifying the architectures during compiler identification is redundant, and requires a lot more up-front information than we should need. It also causes unsupported architectures to break the compiler id and version detection, so the resulting output from CMake does not report the compiler version, which is useful information to know why the specified architectures are not supported. The "detecting compiler ABI info" and "check for working compiler" steps already pass `CMAKE_CUDA_ARCHITECTURES` into their test projects. Therefore we can just drop the earlier architecture testing. Bad architectures will be reported as a not-working compiler, and the output will include the compiler's error message. This reverts the approach from: * commit 19cc5bc296 (CUDA: Throw error if user-specified architectures don't work, 2020-05-26, v3.18.0-rc1~79^2) * commit 650c1029a0 (CUDA: Detect non-working user-specified architectures on NVCC, 2020-05-28, v3.18.0-rc1~51^2) * commit 01428c5560 (CUDA: Fail fast if CMAKE_CUDA_ARCHITECTURES doesn't work during detection, 2020-08-29, v3.19.0-rc1~241^2). Their goal was in part to avoid waiting until the test for working compiler to detect unsupported architectures. However, experience has shown that failing earlier is more trouble than it's worth. Fixes: #23161 Issue: #20756
* CUDA: Generate better error message when detecting nvccRobert Maynard2022-03-211-4/+4
| | | | Issue: #23322, #23323
* CUDA: Add support for CUDA_ARCHITECTURES=nativeBrad King2022-03-101-2/+13
| | | | | | | | | | | CUDA 11.6 added the `nvcc -arch=native` flag to automatically compile for the host GPUs' architectures. Add support for specifying this special `native` value in `CMAKE_CUDA_ARCHITECTURES` and `CUDA_ARCHITECTURES`. During the compiler ABI detection step, detect the native architectures so we can pass them explicitly when using Clang or older versions of nvcc. Fixes: #22375
* CUDA: Add FIXME comments about deferring architecture testingBrad King2022-03-101-0/+3
| | | | Issue: #23161
* CUDA: Restore support for CMAKE_CUDA_ARCHITECTURES=OFFRobert Maynard2022-03-091-2/+2
| | | | Fixes: #23309
* VS: Fix CUDA compiler id with CMAKE_CUDA_ARCHITECTURES={all,all-major}Brad King2022-03-021-1/+3
| | | | | | | | Skip the architecture verification check for these values on Visual Studio. It cannot be implemented correctly until future work delays the check to the main compiler test step. Issue: #23164, #23161
* CUDA: Fix CMAKE_CUDA_ARCHITECTURES=all/all-major with NVCC 11.5+Brad King2022-03-011-1/+4
| | | | | | | | | | Changes in commit 8f64df0a7c (CUDA: Generic all and all-major support, 2021-12-19, v3.23.0-rc1~23^2) broke our architecture verification checks when using `-arch={all,all-major}` with NVCC 11.5+. If we test the compiler with `-arch={all,all-major}`, we have no expected list of architectures, so skip the check. Fixes: #23278
* CUDA: Simplify CMAKE_CUDA_ARCHITECTURES special value logicBrad King2022-02-281-20/+18
| | | | | | Refactor the logic checking `CMAKE_CUDA_ARCHITECTURES` special values. Switch on the value first, and then make other decisions for each case. This makes room for other special values to be added later.
* CUDA: Generic all and all-major supportRaul Tambre2022-02-011-42/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 14d8a276 (CUDA: Support nvcc 11.5 new -arch=all|all-major flags, 2021-08-17) added all and all-major options to CUDA_ARCHITECTURES. These are fairly generic and likely to see real-world use by distributors. Thus it's desirable to support these also for Clang and older NVCC versions. The supported architectures are dependent on the toolkit version. We determine the toolkit version prior to compiler detection. For NVCC we get the version from the vendor identification output, but for Clang we need to invoke NVCC separately. The architecture information is mostly based on the Wikipedia list with the earliest supported version being CUDA 7.0. This could be documented and expanded in the future to allow projects to query CUDA toolkit version and architecture information. For Clang we additionally constrain based on its support. Additionally the architecture mismatch detection logic is fixed, improved and updated for generic support: * Commit 01428c55 (CUDA: Fail fast if CMAKE_CUDA_ARCHITECTURES doesn't work during detection, 2020-08-29) enabled CMAKE_CUDA_COMPILER_ID_REQUIRE_SUCCESS if CMAKE_CUDA_ARCHITECTURES is specified. This results in CMakeDetermineCompilerID.cmake printing the compiler error and our code for presenting the mismatch in a user-friendly way being useless. The custom logic seems preferable so go back to not enabling it. * Commit 14d8a276 (CUDA: Support nvcc 11.5 new -arch=all|all-major flags, 2021-08-17) tried to support CMP0054 but forgot to add x to the interpolated result. Thus the conditions would always evaluate to false. This is fixed as a byproduct of removing NVIDIA specific checks, improving the error message and replacing architectures_mode with a simpler architectures_explicit. Visual Studio support omits testing the flags during detection due to complexities in determining the toolkit version when using it. A long-term proper implementation would be #23161. Implements #22860.
* CUDA: Fix issuing error if default architecture detection failsRaul Tambre2022-01-271-32/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | We require CUDA_ARCHITECTURES to be set for targets (see CMP0104). If not set anything after compiler detection such as ABI detection will fail to generate. This means we need to error if CMAKE_CUDA_ARCHITECTURES is not set to a valid value as a result of compiler detection. Currently we fail to issue the error if compiler detection failed and the ID is unset. In such a case we won't define detected_architecture making the code responsible for the error unreachable. Simplify the detection of architectures used during compiler detection by always detecting all of them, which enables us to simply the check in the "default to compiler" path if CMAKE_CUDA_ARCHITECTURES is empty. As a result we need to move the error checking and CMAKE_CUDA_ARCHITECTURES=OFF handling fully into the default path thus simplifying the code and unifying the code paths for NVCC and CUDA. This also happens to fix: 1. CMAKE_CUDA_ARCHITECTURES=OFF on Clang. 2. A theoretical issue of a compiler defaulting to multiple architectures. I've additionally added printing of the compiler output along the error to better reveal possible underlying compiler/system configuration issues. Fixes #23010.
* CUDA: Error on empty/invalid CMAKE_CUDA_ARCHITECTURES set by userRaul Tambre2022-01-271-1/+8
| | | | | | | | If empty we otherwise treat it the same as unset in most places, but still end up failing eventually with a confusing "Failed to find a working CUDA architecture". This also detects some other basic invalid ones (e.g. "al").
* CUDA: Actually use reverse architecture deprecation order for ClangRaul Tambre2022-01-271-1/+1
| | | | | | The code now matches what the comment describes. This mistake seems to have been present since the initial introduction in commit 5df21adf (CUDA: Add support for Clang compiler, 2020-05-07).
* CUDA: Fix CMAKE_CUDA_COMPILER_ARG1 cache descriptionRaul Tambre2022-01-151-9/+9
| | | | Also corrected the misleading indentation.
* CUDA: Support nvcc 11.5 new -arch=all|all-major flagsRobert Maynard2021-11-011-8/+30
|
* CUDA: Fix detection of implicit link information with CUDA 6.5samuel100u2021-09-301-2/+3
| | | | Fixes: #22701
* CUDA: Extract nvvm libdevice location from compiler verbose outputRobert Maynard2021-07-221-2/+17
| | | | | Depending on the CUDA installation the nvvm/libdevice folder can be in different locations. Since `nvcc` outputs the expected location use that when possible.
* Merge topic 'improve_cuda_toolkit_extraction_regex'Brad King2021-05-071-1/+1
|\ | | | | | | | | | | | | | | 5e931c5a97 CUDA: improve regex for CUDA Toolkit root from nvcc verbose output Acked-by: Kitware Robot <kwrobot@kitware.com> Reviewed-by: Raul Tambre <raul@tambre.ee> Merge-request: !6094
| * CUDA: improve regex for CUDA Toolkit root from nvcc verbose outputRobert Maynard2021-05-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The original regular expression was greedy and would match any environment variable ending with `TOP` (like `DESKTOP`). This is an issue on windows where `nvcc -v` would output all environment variables before the compiler's verbose output. To resolve this issue we use a tighter match algorithm that looks for `#$ TOP=` instead of `TOP=`. Fixes: #22158
| * Merge topic 'better_cuda_compiler_detection_error_messages' into release-3.20Brad King2021-02-241-5/+5
| |\ | | | | | | | | | | | | | | | | | | | | | a0fc64ac24 CUDA: Improve error messages when CUDA compiler detection fails Acked-by: Kitware Robot <kwrobot@kitware.com> Reviewed-by: Raul Tambre <raul@tambre.ee> Merge-request: !5844
* | | CUDA: Add CMAKE_CUDA_HOST_COMPILER support on Windows non-VS generatorsunknown2021-04-221-6/+9
| | |
* | | CUDA: Add support for finding nvcc in CUDA_PATHTobias Ribizel2021-03-151-0/+2
| | | | | | | | | | | | | | | | | | Previously, nvcc needed to be present in PATH or specified by CUDACXX. On Windows with vcpkg, the PATH is heavily modified, which lead to nvcc not being found with the Ninja generator.
* | | Merge topic 'better_cuda_compiler_detection_error_messages'Brad King2021-02-241-5/+5
|\ \ \ | |/ / |/| / | |/ | | | | | | | | a0fc64ac24 CUDA: Improve error messages when CUDA compiler detection fails Acked-by: Kitware Robot <kwrobot@kitware.com> Reviewed-by: Raul Tambre <raul@tambre.ee> Merge-request: !5844
| * CUDA: Improve error messages when CUDA compiler detection failsRobert Maynard2021-02-231-5/+5
| |
* | CUDA: Capture all nvcc output when extracting toolkit rootBrad King2021-02-121-3/+4
|/ | | | | | | | | Since commit fb2afef620 (CUDA: Support nvcc symlinking to ccache, 2021-01-07) and commit 3cef91a321 (CUDA: Always extract CUDA Toolkit root from nvcc verbose output, 2021-02-03) we always run the command `nvcc -v __cmake_determine_cuda` to look for the toolkit root in its stderr. On Windows, that command may print to stdout instead, so capture that as well.
* CUDA: Always extract CUDA Toolkit root from nvcc verbose outputRobert Maynard2021-02-081-13/+11
| | | | | | | | | | | | Fixes #21750, #21763 Given that NVCC can be provided by multiple different sources (NVIDIA HPC SDK, CUDA Toolkit, distro) each of which has a different layout, we need to extract the CUDA toolkit root from the compiler itself, allowing us to support numerious different scattered toolkit layouts. The NVIDIA HPC SDK specifically ships two copies of nvcc one in `compilers/bin/` and one in `cuda/bin`. Thus when using `compilers/bin/nvcc` the Toolkit root logic fails.
* CUDA: Support nvcc symlinking to ccacheRong Ou2021-01-111-1/+14
| | | | | | | Invoke `nvcc -v` to find the real CUDA bin directory. This is needed if `nvcc` is a symlink to `ccache` or `colornvcc`. Fixes: #21177
* CUDA: Initialize CMAKE_CUDA_ARCHITECTURES using $ENV{CUDAARCHS}Raul Tambre2020-11-301-0/+4
| | | | | | | NVCC's default architecture may be newer than the one supported by the machine's GPU. In such cases it's useful to have an environment variable for initializing CMAKE_CUDA_ARCHITECTURES to avoid specifying it for every invocation.
* CUDA: Error if can't determine toolkit library rootRaul Tambre2020-11-221-0/+2
| | | | | | | Finding the toolkit is required for Clang and is assumed to have been correctly found by FindCUDAToolkit if the CUDA language is found. Error out early with an useful error instead of failing later on due to the path not being set.
* CUDA: Clang CUDA 11.1 supportRaul Tambre2020-11-221-4/+4
| | | | | | | | | version.txt is gone from CUDA 11.1 installations, but the rest is the same. Instead of looking for version.txt look for <CUDA path>/nvvm/libdevice, which is the main thing that Clang requires (though it also checks for the existence of bin and include). Fixes #21353.
* CUDA: Clang separable compilationRaul Tambre2020-09-241-2/+14
| | | | | | | | | | | | For NVCC the compiler takes care of device linking when passed the "-dlink" flag. Clang doesn't support such magic and requires the buildsystem to do the work that NVCC does behind the scenes. The implementation is based on Bazel's device linking documentation: https://github.com/tensorflow/tensorflow/blob/7cabcdf073abad8c46e9dda62bb8fa4682d2061e/third_party/nccl/build_defs.bzl.tpl#L259 Closes: #20726
* CUDA: Support scattered installations when crosscompiling with ClangRaul Tambre2020-09-141-2/+5
| | | | | | | Previously when CMAKE_CROSSCOMPILING was ON we'd end up not setting the target directory if the non-scattered one didn't exist. Fix this by assuming a scattered installation if the target directory isn't set after the crosscompiling logic.
* CUDA: Fail fast if CMAKE_CUDA_ARCHITECTURES doesn't work during detectionRaul Tambre2020-08-291-18/+19
| | | | | Also re-ordered the code to avoid testing flags for other compilers, since we know the vendor before full detection.
* CUDA: Fail if compiler detection using the host compiler failsRaul Tambre2020-08-291-0/+4
| | | | | | | | | | | | | | | | | | | If an user specified a host compiler we should fail if we are unable to perform compiler detection with it. Previously we would try without and likely succeed and continue. Then we'd fail during ABI detection and compiler testing since we'd still try to use it. This is particularly problematic when crosscompiling since we extract the host linker from the compiler detection link line. This would result in the wrong host linker being used and a linking error due to architecture mismatch during ABI detection where other necessary flags may already be present to make the host compiler work. See #21076 for an example. Fix this by adding CMAKE_<LANG>_COMPILER_ID_REQUIRE_SUCCESS to CMakeDetermineCompilerId, which throws a fatal error if executing the compiler results in a non-zero exit code. Fixes #21120.
* Toolchain: Capture all arguments from CMAKE_<LANG>_COMPILERFred Baksik2020-07-231-1/+1
| | | | | | | | | | | Capture CMAKE_<LANG>_COMPILER_ARG1 from CMAKE_<LANG>_COMPILER in the same fashion that it is from $ENV{<LANG>}. Since get_filename_component() returns a single string of all the arguments from $ENV{<LANG>}, a single string of arguments will be constructed from the items contained in CMAKE_<LANG>_COMPILER. Fixes #20089
* Fix typos identified using codespellJean-Christophe Fillion-Robin2020-07-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See https://github.com/codespell-project/codespell#readme The following command was used: ``` codespell -q6 --skip="\ .git,\ *.json,\ ./Copyright.txt,\ ./Help/command/foreach.rst,\ ./Help/prop_test/REQUIRED_FILES.rst,\ ./Help/variable/CTEST_COVERAGE_COMMAND.rst,\ ./Modules/CMakeCheckCompilerFlagCommonPatterns.cmake,\ ./Modules/CMakeRCInformation.cmake,\ ./Modules/Internal/CPack/NSIS.template.in,\ ./Modules/FindMatlab.cmake,\ ./Modules/MatlabTestsRedirect.cmake,\ ./Modules/Platform/Windows-Clang.cmake,\ ./Modules/Platform/Windows-Intel-Fortran.cmake,\ ./Modules/Platform/Windows-MSVC.cmake,\ ./Source/CMakeVersion.cmake,\ ./Source/cmConvertMSBuildXMLToJSON.py,\ ./Source/cmCreateTestSourceList.cxx,\ ./Source/cmGlobalVisualStudio10Generator.cxx,\ ./Source/cmExportBuildFileGenerator.cxx,\ ./Source/cmExportInstallAndroidMKGenerator.cxx,\ ./Source/cmExportInstallFileGenerator.cxx,\ ./Source/cmExportSet.cxx,\ ./Source/cmExportTryCompileFileGenerator.cxx,\ ./Source/cmFindPackageCommand.cxx,\ ./Source/cmInstallCommand.cxx,\ ./Source/cmGeneratorExpressionLexer.cxx,\ ./Source/cmLocalVisualStudio7Generator.cxx,\ ./Source/cmOrderDirectories.cxx,\ ./Source/cmTarget.cxx,\ ./Source/kwsys/*,\ ./Source/QtDialog/CMakeSetupDialog.ui,\ ./Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx,\ ./Source/CTest/cmParseCoberturaCoverage.h,\ ./Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in,\ ./Tests/RunCMake/CPack/tests/DMG_SLA/English.license.rtf,\ ./Tests/RunCMake/CPack/tests/DMG_SLA/German.license.txt,\ ./Tests/RunCMake/CPack/tests/DMG_SLA/German.menu.txt,\ ./Tests/RunCMake/GoogleTest/xml_output.cpp,\ ./Tests/RunCMake/Make/TargetMessages*,\ ./Utilities/*,\ " \ -L "\ dependees,\ endwhile,\ fo,\ filetest,\ helpfull,\ nd,\ objext,\ stoll,\ supercedes,\ superceded,\ vas,\ varn,\ " ```
* NVCC: Handle host compiler with spaces in pathRaul Tambre2020-07-141-2/+2
| | | | | | | Need to surround it with quotes otherwise the different bits are passed as separate arguments. Fixes #20954.
* CUDA: Fix CMAKE_CUDA_COMPILER_TOOLKIT_ROOT detection in Visual StudioBrad King2020-06-181-108/+121
| | | | | | | | | | When using a Visual Studio generator, we do not know the path to `CMAKE_CUDA_COMPILER` until after the compiler id detection project extracts it. However, based on the VS toolchain configuration we know that the compiler id will be NVIDIA, so use that to drive the CUDA architecture flag logic. After the main compiler id step we know `CMAKE_CUDA_COMPILER`, so `CMAKE_CUDA_COMPILER_TOOLKIT_ROOT` can then be computed.
* CUDA: Re-order some logic for determining the compilerBrad King2020-06-181-11/+9
|
* CUDA: Remove unused variables while determining compilerBrad King2020-06-181-2/+0
|
* CUDA: Simplify CMAKE_CUDA_COMPILER_TOOLKIT_ROOT computationBrad King2020-06-181-1/+1
|
* CUDA: Skip the entire search for nvcc when it is CMAKE_CUDA_COMPILERBrad King2020-06-181-80/+80
|
* CUDA: Fix NVCC executable search during compiler detectionRaul Tambre2020-06-181-7/+1
| | | | | | | | The result variable was `CUDAToolkit_NVCC_EXECUTABLE` instead of `_CUDA_NVCC_EXECUTABLE`, which the rest of the code used. Also, we can simply `set()` the `_CUDA_NVCC_EXECUTABLE` value without searching. Fixes: #20847
* CUDA: Throw error for Clang on WindowsRaul Tambre2020-06-161-0/+4
| | | | | | Supporting compiling on Windows is more complicated than initially expected, so it won't make it into CMake 3.18. Add a helpful error for users.
* Merge topic 'cuda_clang_toolkit_path' into release-3.18Brad King2020-06-151-15/+195
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | ec59fb6c31 CUDA: Determine CUDA toolkit location for NVCC 0a056246a1 CUDA: Pass toolkit path to Clang 9c43972127 FindCUDAToolkit: Avoid unnecessary temporary variable computing binary dir 9eebb5b8b2 FindCUDAToolkit: Remove unnecessary checks around searches 8f01fe7bf1 FindCUDAToolkit: Use list(SORT) to sort in natural order 8c144fe9ad FindCUDAToolkit: Compute CUDAToolkit_INCLUDE_DIR instead of searching 403f8d31e3 FindCUDAToolkit: Add CUDAToolkit_LIBRARY_ROOT 6636693134 FindCUDAToolkit: Re-unify with Internal/CUDAToolkit Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4828
| * CUDA: Determine CUDA toolkit location for NVCCRaul Tambre2020-06-121-122/+123
| | | | | | | | | | Similar to how we already do for Clang. Avoids a lot of redundant work in FindCUDAToolkit.