blob: b125729ddf341d2b402a2f66fe5f2a09c207f196 [file] [log] [blame]
Ryan Prichard7aea7e92022-01-13 17:30:17 -08001CMP0104
2-------
3
4.. versionadded:: 3.18
5
6Initialize :variable:`CMAKE_CUDA_ARCHITECTURES` when
7:variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``.
8Raise an error if :prop_tgt:`CUDA_ARCHITECTURES` is empty.
9
10:variable:`CMAKE_CUDA_ARCHITECTURES` introduced in CMake 3.18 is used to
11initialize :prop_tgt:`CUDA_ARCHITECTURES`, which passes correct code generation
12flags to the CUDA compiler.
13
14Previous to this users had to manually specify the code generation flags. This
15policy is for backwards compatibility with manually specifying code generation
16flags.
17
18The ``OLD`` behavior for this policy is to not initialize
19:variable:`CMAKE_CUDA_ARCHITECTURES` when
20:variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``.
21Empty :prop_tgt:`CUDA_ARCHITECTURES` is allowed.
22
23The ``NEW`` behavior of this policy is to initialize
24:variable:`CMAKE_CUDA_ARCHITECTURES` when
25:variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``
26and raise an error if :prop_tgt:`CUDA_ARCHITECTURES` is empty during generation.
27
28If :prop_tgt:`CUDA_ARCHITECTURES` is set to a false value no architectures
29flags are passed to the compiler. This is intended to support packagers and
30the rare cases where full control over the passed flags is required.
31
32This policy was introduced in CMake version 3.18. CMake version
33|release| warns when the policy is not set and uses ``OLD`` behavior.
34Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
35explicitly.
36
37.. include:: DEPRECATED.txt
38
39Examples
40^^^^^^^^
41
42.. code-block:: cmake
43
44 set_target_properties(tgt PROPERTIES CUDA_ARCHITECTURES "35;50;72")
45
46Generates code for real and virtual architectures ``30``, ``50`` and ``72``.
47
48.. code-block:: cmake
49
50 set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES 70-real 72-virtual)
51
52Generates code for real architecture ``70`` and virtual architecture ``72``.
53
54.. code-block:: cmake
55
56 set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES OFF)
57
58CMake will not pass any architecture flags to the compiler.