summaryrefslogtreecommitdiff
path: root/Help/policy/CMP0104.rst
blob: 85167169f0efc2cb0560edfd6d73b9be88f4585f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
CMP0104
-------

Initialize :variable:`CMAKE_CUDA_ARCHITECTURES` when
:variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``.
Raise an error if :prop_tgt:`CUDA_ARCHITECTURES` is empty.

:variable:`CMAKE_CUDA_ARCHITECTURES` introduced in CMake 3.18 is used to
initialize :prop_tgt:`CUDA_ARCHITECTURES`, which passes correct code generation
flags to the CUDA compiler.

Previous to this users had to manually specify the code generation flags. This
policy is for backwards compatibility with manually specifying code generation
flags.

The ``OLD`` behavior for this policy is to not initialize
:variable:`CMAKE_CUDA_ARCHITECTURES` when
:variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``.
Empty :prop_tgt:`CUDA_ARCHITECTURES` is allowed.

The ``NEW`` behavior of this policy is to initialize
:variable:`CMAKE_CUDA_ARCHITECTURES` when
:variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``
and raise an error if :prop_tgt:`CUDA_ARCHITECTURES` is empty during generation.

If :prop_tgt:`CUDA_ARCHITECTURES` is set to a false value no architectures
flags are passed to the compiler. This is intended to support packagers and
the rare cases where full control over the passed flags is required.

This policy was introduced in CMake version 3.18.  CMake version
|release| warns when the policy is not set and uses ``OLD`` behavior.
Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
explicitly.

.. include:: DEPRECATED.txt

Examples
^^^^^^^^

.. code-block:: cmake

  set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES 35 50 72)

Generates code for real and virtual architectures ``30``, ``50`` and ``72``.

.. code-block:: cmake

  set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES 70-real 72-virtual)

Generates code for real architecture ``70`` and virtual architecture ``72``.

.. code-block:: cmake

  set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES OFF)

CMake will not pass any architecture flags to the compiler.