[CMake] Where to change default link line on Cmake

Rene Salmon salmr0 at bp.com
Wed May 5 09:19:58 EDT 2010


Hi,

 
> CMake was not really designed to do that.  The idea of a cross platform
> build system is that it should not force a compiler choice from the
> build files.  CMake has an order of picking compilers, if there is more
> than one on the system, it is going to pick the wrong one some of the
> time by definition.  So, you have tell it which one to use.  If you
> really want to do this, you would have to set those variables BEFORE the
> project command.  However, at that point you would not have
> CMAKE_SYSTEM_* or any other vars set.  So, you would have to call uname
> or something from execute_process to figure that out.  However, I would
> not recommend this, as someone might want to use a different compiler
> some day with your project, and this will not allow that.

Excellent point. I thought about that right after I hit send to my email.
The whole reason we are looking at Cmake is so that we give our users more
flexibility for building our software and not the other way around.  I will
remove those lines from the Cmake files.

On the other hand we always want to use or default to XLC or XLF on an IBM
Power machine and not gcc or gfrotran so I can see our users seeing having
to set CC, CXX etc every time as a bit of a pain.  Sure they can just put
that in their .bashrs or .cshrc files and forget about it but that is not
really what we want.

Is there maybe a way to hint to cmake to only use gcc gfortran as a last
resort or to look for xlc and xlf first and use them always if found instead
of gcc?

Thanks for all the help and advise.

Rene
 



More information about the CMake mailing list