blob: d2acbc85c69d17cea4ae4085cc5be5cb9ece96fd [file] [log] [blame]
Ryan Prichard7aea7e92022-01-13 17:30:17 -08001enable_language
2---------------
3Enable a language (CXX/C/OBJC/OBJCXX/Fortran/etc)
4
5.. code-block:: cmake
6
7 enable_language(<lang> [OPTIONAL] )
8
9Enables support for the named language in CMake. This is
10the same as the :command:`project` command but does not create any of the extra
11variables that are created by the project command. Example languages
12are ``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
27If enabling ``ASM``, enable it last so that CMake can check whether
28compilers for other languages like ``C`` work for assembly too.
29
30This command must be called in file scope, not in a function call.
31Furthermore, it must be called in the highest directory common to all
32targets using the named language directly for compiling sources or
33indirectly through link dependencies. It is simplest to enable all
34needed languages in the top-level directory of a project.
35
36The ``OPTIONAL`` keyword is a placeholder for future implementation and
37does not currently work. Instead you can use the :module:`CheckLanguage`
38module to verify support before enabling.