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