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 ?
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 .
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.
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.
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.
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).
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++
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With