CMP0104.rst 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. CMP0104
  2. -------
  3. .. versionadded:: 3.18
  4. Initialize :variable:`CMAKE_CUDA_ARCHITECTURES` when
  5. :variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``.
  6. Raise an error if :prop_tgt:`CUDA_ARCHITECTURES` is empty.
  7. :variable:`CMAKE_CUDA_ARCHITECTURES` introduced in CMake 3.18 is used to
  8. initialize :prop_tgt:`CUDA_ARCHITECTURES`, which passes correct code generation
  9. flags to the CUDA compiler.
  10. Previous to this users had to manually specify the code generation flags. This
  11. policy is for backwards compatibility with manually specifying code generation
  12. flags.
  13. The ``OLD`` behavior for this policy is to not initialize
  14. :variable:`CMAKE_CUDA_ARCHITECTURES` when
  15. :variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``.
  16. Empty :prop_tgt:`CUDA_ARCHITECTURES` is allowed.
  17. The ``NEW`` behavior of this policy is to initialize
  18. :variable:`CMAKE_CUDA_ARCHITECTURES` when
  19. :variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``
  20. and raise an error if :prop_tgt:`CUDA_ARCHITECTURES` is empty during generation.
  21. If :prop_tgt:`CUDA_ARCHITECTURES` is set to a false value no architectures
  22. flags are passed to the compiler. This is intended to support packagers and
  23. the rare cases where full control over the passed flags is required.
  24. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.18
  25. .. |WARNS_OR_DOES_NOT_WARN| replace:: warns
  26. .. include:: STANDARD_ADVICE.txt
  27. .. include:: DEPRECATED.txt
  28. Examples
  29. ^^^^^^^^
  30. .. code-block:: cmake
  31. set_target_properties(tgt PROPERTIES CUDA_ARCHITECTURES "35;50;72")
  32. Generates code for real and virtual architectures ``30``, ``50`` and ``72``.
  33. .. code-block:: cmake
  34. set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES 70-real 72-virtual)
  35. Generates code for real architecture ``70`` and virtual architecture ``72``.
  36. .. code-block:: cmake
  37. set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES OFF)
  38. CMake will not pass any architecture flags to the compiler.