Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

cmake

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

Why is it "XX" not PP against a CPP file ?

like image 429
user2618142 Avatar asked Aug 01 '13 05:08

user2618142


People also ask

What does CXX mean in CMake?

This is a CMake Environment Variable. Its initial value is taken from the calling process environment. Preferred executable for compiling CXX language files. Will only be used by CMake on the first configuration to determine CXX compiler, after which the value for CXX is stored in the cache as CMAKE_CXX_COMPILER .

What is the difference between CXX and CPP?

CXX file extensions are native file formats used in C++ programming language. The CXX file type basically comes in use for the source code files that have been coded on C++ programming language.

How does CMake choose compiler?

CMake does check for the compiler ids by compiling special C/C++ files. So no need to manually include from Module/Compiler or Module/Platform . This will be automatically done by CMake based on its compiler and platform checks.

Is CMake a C++ compiler?

CMake is an open-source, cross-platform tool that uses compiler and platform independent configuration files to generate native build tool files specific to your compiler and platform. The CMake Tools extension integrates Visual Studio Code and CMake to make it easy to configure, build, and debug your C++ project.


2 Answers

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).

like image 190
gx_ Avatar answered Sep 22 '22 05:09

gx_


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++.

like image 45
ComicSansMS Avatar answered Sep 19 '22 05:09

ComicSansMS