enable_language.rst 1.0 KB

12345678910111213141516171819202122232425262728
  1. enable_language
  2. ---------------
  3. Enable languages (CXX/C/OBJC/OBJCXX/Fortran/etc)
  4. .. code-block:: cmake
  5. enable_language(<lang>... [OPTIONAL])
  6. Enables support for the named languages in CMake. This is the same as
  7. the :command:`project` command but does not create any of the extra
  8. variables that are created by the :command:`project` command.
  9. .. include:: SUPPORTED_LANGUAGES.txt
  10. The following restrictions apply to where ``enable_language()`` may be called:
  11. * It must be called in file scope, not in a function call.
  12. * It must not be called before the first call to :command:`project`.
  13. See policy :policy:`CMP0165`.
  14. * It must be called in the highest directory common to all targets
  15. using the named language directly for compiling sources or
  16. indirectly through link dependencies. It is simplest to enable all
  17. needed languages in the top-level directory of a project.
  18. The ``OPTIONAL`` keyword is a placeholder for future implementation and
  19. does not currently work. Instead you can use the :module:`CheckLanguage`
  20. module to verify support before enabling.