[CMake] Newbie questions: verbosity and compiler invocation

Michael Wild themiwi at gmail.com
Wed Sep 8 10:55:57 EDT 2010


On 8. Sep, 2010, at 16:33 , David Aldrich wrote:

> Hi
> 
> I am experimenting with using CMake to replace our manually written gnu makefiles on Linux. I have a couple of questions:
> 
> 1) VERBOSITY
> 
> I would like to see the compiler command on the console when running make. I know that one can run:
> 
> make VERBOSE=1
> 
> but that displays a lot of detail, for example:
> 
> make[1]: Entering directory ...
> 
> Is there a way that I reduce the commentary to just show the compiler commands? For example:
> 
> /usr/bin/c++     -o CMakeFiles/Kernel.dir/ErrorHandler.cpp.o -c /<mypath>/Kernel/ErrorHandler.cpp

AFAIK there's no way to do that (apart from writing a wrapper script which echoes the command to stdout and then invokes it).

> 
> 2) COMPILER
> 
> As shown above, cmake is invoking:
> 
> /usr/bin/c++     
> 
> I don't know what this tool is.  How can I specify to use /usr/bin/g++ ?
> 
> Best regards
> 
> David

The first time you invoke CMake, do it like this:

CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake /path/to/source

Alternatively, you can pass -DCMAKE_C_COMPILER=/usr/bin/gcc to the cmake program (similarly CMAKE_CXX_COMPILER for the c++ compiler), but that can have some nasty side-effects (e.g deleting and rebuilding the whole cache if it already exists).

Usually, on Linux systems, /usr/bin/c++ is just another name for /usr/bin/g++. It is traditional to call the default C++ compiler /usr/bin/c++, such that hand-crafted Makefiles don't have to guess a name. Similarly, /usr/bin/cc is the default C compiler.

Hope this clears things up a bit for you

Michael

--
There is always a well-known solution to every human problem -- neat, plausible, and wrong.
H. L. Mencken

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100908/14995f2c/attachment.pgp>


More information about the CMake mailing list