I am newbie of CMake, and I was wondering for a C++/C project in the LINUX environmental how CMake can choose compilers between gcc and g++. More specifically, my questions are as follows:
Shortly, yes to both.
You can mangle with pretty much everything. There are flags and variables that bind extensions to language; and then language to compiler options/executables that define toolsets and build targets.
Check following links to documentation. Those are some pleasant short readings.
Note: The wiki might be outdated but it should hold in case of important and educational matter.
PS. There is whole bunch of related options. For some longer read you can check following sections of documentation: Properties on Source Files and Variables for Languages. 2. and 3. come from these sections.
As far as I know CMake only look at the file extensions. So if you rename your .c file to .cpp it will, as far as I know, be compiled with g++.
It is easy to change that behaviour. CMake uses environment variables to see which compiler to use. If you would like to change compiler to e.g. clang and clang++, you can just do
export CC=clang export CXX=clang++
before running cmake.
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