Commit Graph

193 Commits

Author SHA1 Message Date
Peter Kokot
50e57aa4ca CMAKE_COMPILER_IS_*: Replace with CMAKE_<LANG>_COMPILER_ID
Variables such as CMAKE_COMPILER_IS_GNUCC are documented as
obsolete/deprecated and ideally shouldn't be used in the code anymore
to have clearer compiler identifications.

In the past QCC compiler was identified as GNU and also had this
variable set to 1 (see policy CMP0047).  Same still applies for LCC
compiler (see policy CMP0129).
2025-03-29 20:31:49 +01:00
Brad King
05efcdd464 FindCUDA: Sync target directory table with FindCUDAToolkit
The table has been duplicated since commit 69fcad9332 (CUDAToolkit: Add
support for cross-compiling, 2020-01-21, v3.17.0-rc1~104^2~1).
2025-03-04 13:51:29 -05:00
Brad King
7afa58b15d Modules/Find*: Include FindPackageHandleStandardArgs normally
Since commit d74210a8bd (CMP0017: Remove support for OLD behavior,
2024-11-17) we can rely on CMP0017's NEW behavior unconditionally.
Calling `include(FindPackageHandleStandardArgs)` in a builtin module
will always get the builtin `FindPackageHandleStandardArgs`.
2025-01-30 08:53:12 -05:00
Nikita Nemkin
9890cfc4ec Help: More syntax highlighting for literal blocks
Covers almost all blocks containing actual code, except:

* Parsed-literal blocks can't be highlighted, including many command
  summaries and substitution-heavy docs like find_... commands.
  This is a Sphinx limitation.

* Code with errors, like CMP0049, DEPLOYMENT_ADDITIONAL_FILES,
  DEPLOYMENT_REMOTE_DIRECTORY, @PACKAGE_INIT@ substitution in the
  tutorial, bracket arguments/comments in cmake-language.7 and
  cmake-developer.7.

* FindQt4 module, which needs reformatting.
2025-01-29 16:48:53 -05:00
Peter Kokot
4e6a13f211 Use lower case style for commands
Where possible this syncs the CS for command names:

- check_c_source_compiles()
- check_cxx_compiler_flag()
- check_cxx_source_compiles()
- check_cxx_symbol_exists()
- check_include_file_cxx()
- check_include_file()
- check_include_files()
- check_library_exists()
- check_source_compiles()
- check_struct_has_member()
- check_symbol_exists()
- check_type_size()
- cmake_dependent_option()
- cmake_parse_arguments()
- feature_summary()
- file()
- find_package_handle_standard_args()
- if(), endif...
- install(FILES)
- list()
- message()
- pkg_check_modules()
- select_library_configurations()
- set_package_info()
- test_big_endian()
2025-01-28 13:51:46 -05:00
Peter Kokot
9f2efc3270 Remove optional arguments from else() and end*() commands
This adds a brief explanation of the optional condition in the `else()`
and removes all legacy usages of `else()` and `end*()` commands.
2025-01-28 03:01:23 +01:00
Alex Turbov
bc8621d999 Fix: A lot of typos in code found by typos
Yet another great code spellchecker: https://github.com/crate-ci/typos/

(Will be added later as a `pre-commit` hook)
2025-01-12 18:49:34 +04:00
Brad King
7605228f5e codespell: Fix typos 2024-10-25 08:43:04 -04:00
Jinzhe Zeng
3016a64862 FindCUDA: Support cross-compilation to sbsa-linux
Port commit 743d4181b4 (FindCUDAToolkit: Support cross-compilation to
sbsa-linux, 2023-01-11, v3.26.0-rc1~118^2) to FindCUDA too.

Issue: #24192
2024-03-11 10:33:45 -04:00
Jinzhe Zeng
6e8f64950b FindCUDA: Cache CUDA_TOOLKIT_ROOT_DIR when cross-compiling
Previously we cached `CUDA_TOOLKIT_ROOT_DIR` when building for the host,
but not when cross-compiling.  Make it consistent.
2024-03-10 10:55:32 -04:00
Brad King
2744f14db1 codespell: Fix typos 2023-11-17 09:58:21 -05:00
Brad King
04b0d5c862 codespell: Fix typos 2023-05-22 16:51:15 -04:00
Andrey Alekseenko
eb86afebc4 FindCUDA: Mark CUDA_rt_LIBRARY as advanced 2023-03-16 14:52:52 +01:00
Brad King
7a7793e6d7 FindCUDA: Disallow with CMP0147 under Visual Studio
FindCUDA's custom commands invoke `nvcc`, which invokes `cl`.  Under VS
this is done without a `/FS` flag, so `.pdb` generation races if we
use `BuildInParallel`.  The FindCUDA module has already been removed by
policy CMP0146 after being deprecated since CMake 3.10, so it is
simplest to just disallow this combination of features.

Issue: #24576
2023-03-12 07:52:15 -04:00
Brad King
2c146a7fc5 FindCUDA: Add policy to remove this module
The `FindCUDA` module has been deprecated since CMake 3.10.
Add a policy to pretend it doesn't exist in order to encourage
projects to port away from it.
2023-03-09 07:39:36 -05:00
Oleksii Udod
3ddfdc38eb FindCUDA: Do not use CUDA_nppicom_LIBRARY in CUDA 11.0+
Extend the change from commit 1d9f2f9714 (FindCUDA: Do not search for
the deprecated nppicom when CUDA >= 11, 2020-06-22, v3.18.0-rc3~14^2)
to also not use the `CUDA_nppicom_LIBRARY` variable.

Issue: #20845
2022-11-18 15:25:05 -05:00
James Bigler
a7758394af FindCUDA: Fix varaible reset with CUDA_TOOLKIT_TARGET_DIR
CUDA_TOOLKIT_TARGET_DIR doesn't always exist in the cache or defined by the user
previous to using FindCUDA. In this case it will always reset the variables
making it impossible to manually change or set them. This can be fixed by
checking to see if the variable is defined before checking against the
previously used version stored in CUDA_TOOLKIT_TARGET_DIR_INTERNAL.
2022-06-14 15:48:30 -04:00
David Berard
f590ea506a FindCUDA: Make version extraction robust to empty output
I found that `NVCC_OUT` was sometimes empty when I was building.
2022-01-26 14:07:17 -05:00
Raul Tambre
15fda9384a FindCUDA: Improve deprecation guidance wording
Simplified the text regarding adding sources to be more general as there's also
target_sources().

Improved the wording for FindCUDAToolkit to be more explicit of its usecase and
avoid using "superseded" since the common usecase of FindCUDA was superseded by
the language support.

Wording suggestions incopropated from discussion on #22203.
2021-05-22 11:39:19 +03:00
Raul Tambre
e16b06f4b9 FindCUDA: Make the deprecation notice more prominent
FindCUDA is still widely used, but has been superseded by the much more robust
native language support. However the deprecation hasn't been noticed well
enough and real-world experience shows there's still new code written to use
it.

Change this particular notice to a warning to get a hard to miss red box.
We lose the semantic meaning, but we don't want to make all notices like this.
If there are similar cases in the future requiring it would be worth adding a
custom variant of the deprecated directive.

Fixes #22203.
2021-05-22 11:38:52 +03:00
Robert Maynard
5e931c5a97 CUDA: improve regex for CUDA Toolkit root from nvcc verbose output
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
2021-05-06 12:08:24 -04:00
Brad King
9ea66b2d86 CUDA: Capture all nvcc output when extracting toolkit root
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.
2021-02-12 07:23:48 -05:00
Robert Maynard
3cef91a321 CUDA: Always extract CUDA Toolkit root from nvcc verbose output
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.
2021-02-08 12:13:01 -08:00
Rong Ou
fb2afef620 CUDA: Support nvcc symlinking to ccache
Invoke `nvcc -v` to find the real CUDA bin directory.
This is needed if `nvcc` is a symlink to `ccache` or `colornvcc`.

Fixes: #21177
2021-01-11 00:18:04 -08:00
Nikita Nemkin
8fea95319b Help: Add .. versionadded directives to module docs
Issue: #19715
2020-12-02 21:00:30 +05:00
Nikita Nemkin
8634561dca Help: Improve formatting for FindBoost and FindCUDA
* Split large literal blocks into definitions lists.
* Add section headers.
* Add links to standard commands and variables.
* Use inline literals liberally.
* Enable code highlighting in literal blocks.
* Format command signatures according to modern conventions.
2020-12-02 21:00:29 +05:00
janbernloehr
bcdd486bf7 CUDA: Enable support on QNX
This fixes the following two issues with the CUDA support on QNX:

* cuda target name is not derived correctly (should be `aarch64-qnx`).
* linking `cudart` must not be linked against `rt`, `dl`, `pthread`.

This enables to use cmake's native cuda support on QNX.

Fixes: #21381
2020-11-02 09:39:36 -05:00
Robert Maynard
1d9f2f9714 FindCUDA: Do not search for the deprecated nppicom when CUDA >= 11
The nppicom library has been removed in preference of nvjpeg starting
in CUDA 11.

Fixes: #20845
2020-06-22 11:56:51 -04:00
Robert Maynard
b9d67447c3 FindCUDA: Only depend on Threads::Threads on platforms that need it
In commit 46371132b3 (FindCUDA: CUDA_LIBRARIES doesn't contain raw
`-pthread`, 2019-11-11, v3.17.0-rc1~455^2) we introduced use of the
`Threads::Threads` target, but we do not `find_package(Threads)` on all
platforms.  Use the target only if it exists.
2020-02-24 14:14:38 -05:00
Robert Maynard
e2a5d8374f FindCUDAToolkit: Improve usage, library set, and tests
Refined the initial design of FindCUDAToolkit and improve it
by adding more library support, more toolkit information and
tests.
2019-12-16 11:15:12 -05:00
Kyle Edwards
5695b0464b Merge topic 'cmake-e-rm'
2d0100fac7 replace remove and remove_directory with rm in tests
5239fc5c75 cmake -E: Add rm with improved semantics over remove and remove_directory

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3949
2019-11-15 09:57:56 -05:00
Johnny Jazeix
2d0100fac7 replace remove and remove_directory with rm in tests 2019-11-13 18:02:18 -05:00
Robert Maynard
46371132b3 FindCUDA: CUDA_LIBRARIES doesn't contain raw -pthread
If a person tried to pass `CUDA_LIBRARIES` to nvcc compiler it could
fail as it might have `-pthread` which nvcc doesn't support. Instead
we now use the `Threads::Threads` so that nvcc gets the correct
`-Xcompiler -pthread` flag.
2019-11-11 11:52:02 -05:00
Hong Xu
2e9feddf68 FindCUDA: Use find_program instead of find_path when searching for nvcc.
Before this commit, nvcc would not be found if it is in env PATH but a
non-standard location. This commit fixes this issue.
2019-11-04 14:17:20 -08:00
Brad King
f4eebeb447 FindCUDA: Revert "Use find_program instead of find_path to find nvcc"
Revert commit 067ee518f7 (FindCUDA: Use find_program instead of
find_path to find nvcc, 2019-10-31).  It causes `CUDA_TOOLKIT_ROOT_DIR`
to contain the path to nvcc rather than the toolkit directory.
2019-11-04 14:50:04 -05:00
Hong Xu
067ee518f7 FindCUDA: Use find_program instead of find_path to find nvcc
Otherwise nvcc is not found if it is in env PATH but a non-standard
location.
2019-11-01 09:57:11 -04:00
Eyal Rozenberg
421be81413 FindCUDA: Add nvToolsExt and OpenCL libraries
Find these libraries with CUDA 5 and above.

Fixes: #19386
2019-06-18 08:56:34 -04:00
Kitware Robot
932dcce1e6 Modules: Consistently use 2 space indentation 2019-05-14 15:26:46 -04:00
Brad King
83dab0c123 FindThreads: Drop IRIX-specific options and results
We do not need to support IRIX anymore, so drop relevant parts.  In
particular, the `CMAKE_THREAD_PREFER_PTHREAD` is frequently confused
with `THREADS_PREFER_PTHREAD_FLAG`.

Also remove references to the IRIX-specific options and results
from other modules and tests.
2018-12-07 13:33:01 -05:00
Joachim Wuttke (o)
19998d7b3c Help: Use 'deprecated' template, and date deprecation of modules 2018-10-25 12:23:33 +02:00
Kitware Robot
df4ed1e9ff Help: Convert remaining modules to block-style comments 2018-10-22 11:09:34 -04:00
Brad King
9964808108 Merge topic 'FindCUDA-ccbin-env'
8085799ce3 FindCUDA: Add option to set CUDA_HOST_COMPILER via environment

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2391
2018-09-20 09:35:45 -04:00
peterjc123
8085799ce3 FindCUDA: Add option to set CUDA_HOST_COMPILER via environment
Re-use the `CUDAHOSTCXX` environment variable from the first-class
CUDA language support to specify the host compiler for FindCUDA.
2018-09-18 11:41:47 -04:00
Nikolaus Wittenstein
6209434b44 FindCUDA: Fix "alphabetical" typo 2018-09-14 14:53:03 -04:00
Kenta Kubo
bdf1f36135 FindCUDA: Do not find cublas_device on CUDA >= 9.2
The `cublas_device` has been deprecated and will be removed in
future versions of CUDA.

Issue: #18290
2018-08-23 14:49:46 -04:00
luz.paz
be28106880 Fix misc. typos
Found via `codespell` and `grep`
2018-06-04 10:32:49 -04:00
Brad King
d54796cbd9 Merge topic 'FindCUDA-sccache'
53ffff2277 FindCUDA: Add support for sccache

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2050
2018-05-11 09:22:01 -04:00
Will Feng
53ffff2277 FindCUDA: Add support for sccache
When `CMAKE_C_COMPILER` is `sccache`, pass plain `cl` as the host
compiler to `nvcc`.  Otherwise, `nvcc` does not accept it.
2018-05-09 08:24:22 -04:00
Brad King
6ab7267d2a Merge topic 'FindCUDA-revert-sepcomp-cublas'
9a66345752 FindCUDA: Fix regression in separable compilation without cublas

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2048
2018-05-08 08:26:46 -04:00
Brad King
9a66345752 FindCUDA: Fix regression in separable compilation without cublas
Revert commit v3.11.0-rc1~274^2 (FindCUDA: Add cublas device library to
separable compilation, 2017-11-03).  It breaks targets that do not link
to cublas.  Another solution will be needed to solve the original
problem in a more compatible way.

Fixes: #17965
2018-05-07 11:30:21 -04:00