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