enable_language.rst 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. enable_language
  2. ---------------
  3. Enable a language (CXX/C/OBJC/OBJCXX/Fortran/etc)
  4. .. code-block:: cmake
  5. enable_language(<lang> [OPTIONAL] )
  6. Enables support for the named language in CMake. This is
  7. the same as the :command:`project` command but does not create any of the extra
  8. variables that are created by the project command. Example languages
  9. are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``OBJCXX``, ``Fortran``,
  10. ``HIP``, ``ISPC``, and ``ASM``.
  11. .. versionadded:: 3.8
  12. Added ``CUDA`` support.
  13. .. versionadded:: 3.16
  14. Added ``OBJC`` and ``OBJCXX`` support.
  15. .. versionadded:: 3.18
  16. Added ``ISPC`` support.
  17. .. versionadded:: 3.21
  18. Added ``HIP`` support.
  19. If enabling ``ASM``, enable it last so that CMake can check whether
  20. compilers for other languages like ``C`` work for assembly too.
  21. This command must be called in file scope, not in a function call.
  22. Furthermore, it must be called in the highest directory common to all
  23. targets using the named language directly for compiling sources or
  24. indirectly through link dependencies. It is simplest to enable all
  25. needed languages in the top-level directory of a project.
  26. The ``OPTIONAL`` keyword is a placeholder for future implementation and
  27. does not currently work. Instead you can use the :module:`CheckLanguage`
  28. module to verify support before enabling.