enable_language.rst 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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. ``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. If enabling ``ASM``, enable it last so that CMake can check whether
  18. compilers for other languages like ``C`` work for assembly too.
  19. This command must be called in file scope, not in a function call.
  20. Furthermore, it must be called in the highest directory common to all
  21. targets using the named language directly for compiling sources or
  22. indirectly through link dependencies. It is simplest to enable all
  23. needed languages in the top-level directory of a project.
  24. The ``OPTIONAL`` keyword is a placeholder for future implementation and
  25. does not currently work. Instead you can use the :module:`CheckLanguage`
  26. module to verify support before enabling.