What are the possible values for the LANGUAGE variable in CMAKE

Just take a look at all the CMakeDetermine<Language>Compiler.cmake scripts CMake ships with.

This would result - in alphabetic order - in the following you could put in the enable_language() call:

  1. ASM
  2. ASM-ATT
  3. ASM-MASM
  4. ASM-NASM
  5. C
  6. CSharp
  7. CUDA
  8. CXX
  9. Fortran
  10. Java
  11. OBJC (Objective C)
  12. OBJCXX (Objective C++)
  13. RC (Windows Resource Compiler)
  14. Swift

Evaluated with CMake Version 3.16

References

  • enable_language()
  • Generic rule from makefile to CMake

Update for CMake 3.16 and later: CMake added native support for Objective-C in version 3.16. The corresponding language strings are OBJC and OBJCXX. Thanks to squareskittles for pointing this out.

Original answer: The support for languages varies across platforms.

Currently CMake supports C, CXX and Fortran out of the box on most platforms. There is also support for certain Assemblers on some platforms. For a complete list, check out the contents of the Modules/Platform folder.

The idea is that the language given to the LANGUAGE field of the project command or the enable_language command is just a string, which will then be used by CMake together with the language dependent variables to setup the build system. The Platform scripts shipping with CMake do this configuration for C and C++. In theory, one can add their own language simply by setting the correct variables (although this is quite involved and I do not know of anyone ever successfully doing this).

As for adding support for Objective-C: Since most toolchains use the same compiler for C and Objective-C, you do not need to configure a new language. Simply compile your code as if it was plain C and add the appropriate compiler flags for Objective-C support.

Unfortunately, this is not very comfortable to use and can easily break in corner cases. But until CMake adds explicit support for Objective-C as a first class language, I'm afraid this is as good as it gets.

Tags:

Cmake