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