enable_language¶
Enable languages (CXX/C/OBJC/OBJCXX/Fortran/etc)
enable_language(<lang>... [OPTIONAL])
Enables support for the named languages in CMake. This is the same as
the project() command but does not create any of the extra
variables that are created by the project() command.
Supported languages are C, CXX (i.e. C++), CSharp (i.e. C#), CUDA,
OBJC (i.e. Objective-C), OBJCXX (i.e. Objective-C++), Fortran, HIP,
ISPC, Swift, ASM, ASM_NASM, ASM_MARMASM, ASM_MASM, and ASM-ATT.
在 3.8 版被加入: Added
CSharpandCUDAsupport.在 3.15 版被加入: Added
Swiftsupport.在 3.16 版被加入: Added
OBJCandOBJCXXsupport.在 3.18 版被加入: Added
ISPCsupport.在 3.21 版被加入: Added
HIPsupport.在 3.26 版被加入: Added
ASM_MARMASMsupport.
If enabling ASM, list it last so that CMake can check whether
compilers for other languages like C work for assembly too.
The following restrictions apply to where enable_language() may be called:
It must be called in file scope, not in a function call.
It must not be called before the first call to
project(). See policyCMP0165.It must be called in the highest directory common to all targets using the named language directly for compiling sources or indirectly through link dependencies. It is simplest to enable all needed languages in the top-level directory of a project.
The OPTIONAL keyword is a placeholder for future implementation and
does not currently work. Instead you can use the CheckLanguage
module to verify support before enabling.