summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCUDACompiler.cmake
Commit message (Collapse)AuthorAgeFilesLines
* 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.
| * CUDA: Pass toolkit path to ClangRaul Tambre2020-06-121-120/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang isn't very good at finding the installed CUDA toolkit. The upstream recommendation is that we should pass the toolkit explicitly. Additionally: * Avoids Clang having to search for the toolkit on every invocation. * Allows the user to use a toolkit from a non-standard location by simply setting CUDAToolkit_ROOT. The same way as with FindCUDAToolkit. Clang wants the directory containing the device library and version.txt as the toolkit path. We thus pass the newly introduced CUDAToolkit_LIBRARY_ROOT as the toolkit path. We save CUDAToolkit_ROOT_DIR and CUDAToolkit_LIBRARY_ROOT on Clang to have them available in try_compile() and avoid unnecessary re-searching or a possibly different installation being found in FindCUDAToolkit. This however means that the selected toolkit can't be changed after the initial language enablement. We now determine CUDA compiler ID before doing actual detection, as we don't want to spend time finding the CUDA toolkit for NVIDIA. Implements #20754.
| * FindCUDAToolkit: Remove unnecessary checks around searchesRaul Tambre2020-06-121-6/+4
| | | | | | | | | | find_*() don't search if the result variable is already set. Remove the if()s around such cases.
| * FindCUDAToolkit: Use list(SORT) to sort in natural orderRaul Tambre2020-06-121-36/+4
| | | | | | | | | | We had a custom loop to sort in the natural order. Since CMake 3.18 this is supported natively by CMake and simplifies the code significantly.
| * FindCUDAToolkit: Compute CUDAToolkit_INCLUDE_DIR instead of searchingRaul Tambre2020-06-121-4/+7
| | | | | | | | | | | | | | We can avoid searching for this since CUDAToolkit_TARGET_DIR always contains the include/ directory. But add a warning just in case. Also apply this in CMakeDetermineCUDACompiler for Clang code.
| * FindCUDAToolkit: Add CUDAToolkit_LIBRARY_ROOTRaul Tambre2020-06-121-0/+12
| | | | | | | | | | | | | | | | | | On scattered installations version.txt and nvvm are located at this location. This may be useful to users and will allow us in the future to parse version.txt instead of invoking nvcc to figure out the CUDA toolkit version. We also add it to CMakeDetermineCUDACompiler in preparation for future use by Clang code.
| * FindCUDAToolkit: Re-unify with Internal/CUDAToolkitRaul Tambre2020-06-121-3/+179
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A portion of FindCUDAToolkit was previously split in commit dc2eae1f (FindCUDAToolkit: Factor out discovery code into a separate file, 2020-04-22) out into Internal/CUDAToolkit to allow re-use of the code in CMakeDetermineCUDACompiler for Clang support. This has turned out to be a bad solution due to Clang requiring quite a bit of special handling and special handling for NVCC leaking out from Internal/CUDAToolkit into the Clang code using it. Thus it seems better to re-unify this code and duplicate the parts of the code necessary for Clang where it's required. This will help us get logic correct for both NVCC and CUDA handling. We can still unify the common parts in the future once the code has matured.
* | CUDA: Add support for disabling CUDA_ARCHITECTURESRaul Tambre2020-06-151-1/+1
|/ | | | | | | | | | The ability to disable adding architectures completely for packaging purposes and cases requiring passing the architectures flags explicitly has been requested. Support a false value for CUDA_ARCHITECTURES and CMAKE_CUDA_ARCHITECTURES for this purpose. Implements #20821.
* CUDA: Fix checking working architectures with specifiersRaul Tambre2020-06-051-2/+10
| | | | | | | | | | | | | We don't distinguish real/virtual architectures during compiler detection. If the user passes -DCMAKE_CUDA_ARCHITECTURES="70-virtual" we'll test with only the real architecture. If it works "architectures" will end up as "70". We check equality using strings, so this fails and we incorrectly throw an error. Fix this by comparing against CMAKE_CUDA_ARCHITECTURES with the specifiers stripped. We need to deduplicate tested_architectures for the same reason in case the user specified something like "70-real;70-virtual".
* CUDA: Detect non-working user-specified architectures on NVCCRaul Tambre2020-05-291-19/+35
| | | | | | | | | | | Extend the improved error message added for Clang by commit 19cc5bc296 (CUDA: Throw error if user-specified architectures don't work, 2020-05-26) to cover NVCC as well. Also fix the error incorrectly being thrown if the user-specified list differed in order to the architectures parsed from the compiler output. Implements: #20757
* CUDA: Throw error if user-specified architectures don't workRaul Tambre2020-05-261-6/+33
| | | | | | | | | | | | | Previously if an user specified CMAKE_CUDA_ARCHITECTURES and they didn't work we would end up erroring during compiler testing. Instead check if the architectures we successfully compiled with are the same as the user-specified (if any). If they don't match, then throw a more helpful error than compiler testing would. Additionally, to make this work correctly I made it try all user-specified architectures at once instead of each separately. Implements: #20756
* CUDA: Simplify Clang implicit host linker settingsBrad King2020-05-221-14/+6
| | | | | | | | | | | | | | The purpose of `CMAKE_CUDA_HOST_IMPLICIT_LINK_*` is to capture the extra link libraries and directories that the CUDA compiler passes when invoking the host linker. We need this when using NVCC because CMake drives the host linker directly rather than through NVCC. However, this is not needed with Clang because: * Clang does not pass any CUDA libraries automatically. * We drive linking with the Clang compiler anyway. Drop the detection logic for Clang because it only gives the normal C++ runtime libraries which we do not need here.
* CUDA: Fix implicit runtime library filtering on WindowsBrad King2020-05-221-3/+3
| | | | | The CUDA runtime library names may have a `.lib` suffix. Exclude those too.
* CUDA: Refactor implicit library filteringBrad King2020-05-221-0/+18
| | | | | | Filter CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES just after it is computed. Re-use the same exclusion list for filtering CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES to avoid duplication.
* Merge branch 'backport-cuda-default-runtime' into cuda-default-runtimeBrad King2020-05-221-0/+28
|\
| * CUDA: Compute CMAKE_CUDA_RUNTIME_LIBRARY default from toolchainRobert Maynard2020-05-211-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since commit 0d0145138f (CUDA: Add abstraction for cuda runtime selection, 2019-11-29, v3.17.0-rc1~83^2) we add CUDA runtime library selection flags by default. To maintain backwards compatibility the default CUDA runtime library needs to be computed based on what libraries are found on the initial compiler invocation. For example a toolchain could establish initial flags that have all CUDA compilations using the runtime version, and if we don't detect this we will try to link to both the static and shared runtime. Co-Author: Brad King <brad.king@kitware.com> Fixes: #20708
* | CUDA: Add support for Clang compilerRaul Tambre2020-05-151-5/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When crosscompiling we pass the sysroot. We need to try various architecture flags. Clang doesn't automatically select one that works. First try the ones that are more likely to work for modern installations: * <=sm_50 is deprecated since CUDA 10.2, try sm_52 first for future compatibility. * <=sm_20 is removed since CUDA 9.0, try sm_30. Otherwise fallback to Clang's current default. Currently that's `sm_20`, the lowest it supports. Separable compilation isn't supported yet. Fixes: #16586
* | Merge topic 'cuda_architectures'Brad King2020-04-161-0/+11
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | 21131ca60c CUDA: Add CudaOnly.CompileFlags test f0931b0790 CUDA: Convert tests to use CUDA_ARCHITECTURES e98588aaba CUDA: Add CUDA_ARCHITECTURES target property Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Patrick Stotko <stotko@cs.uni-bonn.de> Merge-request: !4568
| * | CUDA: Add CUDA_ARCHITECTURES target propertyRaul Tambre2020-04-151-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Simplifies CUDA target architecture handling. Required for Clang support as Clang doesn't automatically select a supported architecture. We detect a supported architecture during compiler identification and set CMAKE_CUDA_ARCHITECTURES to it. Introduces CMP0104 for backwards compatibility with manually setting code generation flags with NVCC. Implements #17963.
* | | Compilers: Add paths from -print-sysroot to system prefix pathRobert Maynard2020-04-141-0/+10
|/ /
* | CUDA: Support compiler specific FindBinUtils overridesRobert Maynard2020-03-271-0/+1
| |
* | CUDA: Perform CUDA toolkit include directory detection only on nvccRaul Tambre2020-03-081-25/+28
|/ | | | The code is specific to nvcc.
* CUDA: MSVC generators fill CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIESRobert Maynard2020-01-101-26/+25
| | | | | | Fixes #18733 Correct an oversight where the MSVC generators didn't populate CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES.
* CUDA: Tolerate square brackets in PROMPT environment variableBrad King2019-03-261-0/+5
| | | | | | | The `PROMPT` environment variable affects nvcc's output. Fix our parsing of that output to tolerate square brackets. Fixes: #19089
* CUDA: Do not create CMAKE_CUDA_HOST_COMPILER cache entryBrad King2018-04-241-1/+0
| | | | | | | | | | | | | Users can create it through an explicit command-line option if desired. Initializing the variable as an empty cache entry can wipe out a normal variable of the same name that may have been set by a toolchain file. Since commit v3.8.0-rc1~261^2~11 (CUDA: Use the host compiler for linking CUDA executables and shared libs, 2016-09-19) we save the value of `CMAKE_CUDA_HOST_COMPILER` persistently in the compiler information file as a normal variable. Fixes: #17935
* Drop Visual Studio 8 2005 generatorBrad King2018-04-021-1/+1
| | | | This generator has been deprecated since CMake 3.9. Remove it.
* CMakeFindBinUtils: Improve switch between MSVC- and GNU-like toolsBrad King2017-11-281-0/+3
| | | | | | | | The switch was not considering some languages, such as `ASM`. Instead of memorizing the list of languages in the condition, use a language specified by the includer. Fixes: #17510
* CUDA: Fix default selection of host compiler used to drive linkingBrad King2017-10-041-1/+29
| | | | | | | | | | | | | | | When no explicit `CMAKE_CUDA_HOST_COMPILER` is specified by the user then we do not pass `-ccbin` to `nvcc`. In this case, nvcc's link line we extract during the compiler identification step may not have the absolute path to the host compiler it uses to drive linking. If it is not absolute, use the `PATH=` from nvcc's output to search for it since that is the one `nvcc` would use. This fixes our internal `CMAKE_CUDA_HOST_LINK_LAUNCHER` value used to construct link lines when using `CUDA` as the linker language. It needs to match the host compiler `nvcc` uses internally during compilation. Fixes: #17323
* Drop Visual Studio 7 .NET 2003 generatorBrad King2017-04-191-1/+1
| | | | This generator has been deprecated since CMake 3.6. Remove it.
* VS: Add support for determining CUDA compiler idBrad King2017-03-101-21/+30
| | | | | Teach `CMakeDetermineCompilerId` how to generate a vcxproj file using the `CMAKE_VS_PLATFORM_TOOLSET_CUDA`.
* CMakeDetermineCUDACompiler: Drop out-of-date commentBrad King2017-02-141-7/+0
|
* CUDA: Detect the toolkit include directoriesRobert Maynard2017-02-101-4/+30
| | | | | The `nvcc -v` output provides what include directories need to be added to use the CUDA toolkit from other languages ( C/C++ ).
* CUDA: Detect implicit link information on WindowsBrad King2017-01-121-1/+9
| | | | | The `nvcc -v` output on Windows uses response files, so load the one we need to extract the full link line.
* CUDA: Find MSVC binutils on WindowsBrad King2017-01-121-3/+7
| | | | | On Windows the host link launcher is just `link.exe`. Find and use that instead of trying to extract the launcher from the `nvcc -v` output.
* CUDA: Detect MSVC architecture idBrad King2017-01-121-0/+4
|