17

I haven't been able to find a list of possible values for the LANGUAGE variable on the CMAKE.org site or anywhere else. Would someone please enumerate the values CMAKE recognises? I specifically need to specify Objective C++.

2 Answers 2

12

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

1
  • Looks like HIP and ISPC have been added getting up to CMake Version 3.21.1
    – mheyman
    Aug 22, 2021 at 11:01
9

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.

1
  • 1
    As of CMake 3.16, CMake now supports Objective-C or Objective C++ as a language.
    – Kevin
    Oct 10, 2019 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.