What is "XX" in CXX in a cmake CMakeLists.txt file

Many filesystems do not allow + in filenames, which is why a number of naming conventions emerged for C++ source files over the years, inlcuding .cpp, .cc and .cxx.

CMake has a similar problem as its macro language is built around strings that are not allowed to hold special characters like +. This is simply a limitation to keep CMake's parser from becoming too complicated. So whenever they write CXX, what they really mean is just C++.


XX stands for "++" (each X is like a "plus" rotated by 45°), CXX stands for "C++".

Why "CXX"?

  • "C++" is not possible because of macro identifiers limitations (they can't contain a +);
  • "CPP" (for "C Plus Plus") is usually already used to stand for "C PreProcessor".

For example in a GNU Makefile you can define the following "variables":

  • CPPFLAGS : extra flags for the C preprocessor (also used in C++).
  • CFLAGS   : extra flags for the C compiler.
  • CXXFLAGS : extra flags for the C++ compiler.

(Usually you will use CPPFLAGS and CFLAGS for a C project, and CPPFLAGS and CXXFLAGS for a C++ project.)


See also Difference between CPPFLAGS and CXXFLAGS in GNU Make and CFLAGS vs CPPFLAGS.

Also related: Correct C++ file extension (and duplicate links).

Tags:

C++

Cmake