[CMake] Choice of compilers

Alan W. Irwin irwin at beluga.phys.uvic.ca
Thu Jun 17 10:40:12 EDT 2010


Hi Alok:

I have changed the subject line to something more appropriate.

On 2010-06-16 22:25-0700 Alok Govil wrote:

> 
> Alan wrote:
> 
> > Isn't that the complete issue? My experience (under Wine, but the
> principle
> > is the same) is you must have mingw32-make.exe on your PATH in order for
> -G
> > "MinGW Makefiles" to work. So you will have to be careful of dependencies,
> > but you should be able to download and unpack mingw32-make.exe from the
> > normal SF location for that (under mingw) while keeping the normal MinGW
> gcc
> > compilers off your PATH (since you want to use the different compilers,
> > MinGW-W32 and MinGW-W64).
> 
> I did not realize that cmake calls mingw32-make.exe, since the user has to
> call it explicitly after running cmake.  But I see now.  Cmake tries
> compiling as a part of finding the compilation tools.

"tries compiling" is part of the story, but the CMake generator you choose
with the -G option also configures the build tool.  So "Unix Makefiles"
configures Makefiles under Linux that GNU make can understand, "MinGW
Makefiles" configures Makefiles under either Windows or Wine which
mingw-make.exe understands, etc.  That configuration fails if the build
tool (GNU make, mingw-make.exe, etc.) is not available.

> 
> Your suggestion worked, for both W32 and W64.  I used -G "MinGW Makefiles"
> for both cases.

Good.

> 
> This also works with CMake 2.8 stable/release version.  So I still cannot
> figure what's new in RC2 with respect to MinGW-W64.  Since it works, there
> is no issue really.

That's good as well.  In fact that is pretty typical of CMake.  Normally,
new versions just work like the old.

> 
> Just like CMake is able to distinguish different versions of Visual Studio,
> would it distinguish MinGW-32 with MinGW-64 also (which means either both
> would be in path simultaneously, or neither would be, and cmake picks the
> right one based on the generator specifed)?  Let me know if so, and I'll be
> happy to test this.

I had never heard of those MinGW variants until you mentioned them, and it
appears CMake is not specifically aware of them either.  I presume that's
why you had to rename to gcc.exe (something CMake specifically recognizes)
to get them to work.  But that is a brute-force way to get CMake to
recognize a compiler with a different name.  I would forget the renaming,
and instead use CMAKE_<LANG>_COMPILER (e.g., CMAKE_C_COMPILER,
CMAKE_CXX_COMPILER, etc.) to allow you to choose which compiler (the 32-bit
variant or 64-bit variant) you want to use.  See the CMake documentation for
how to use CMAKE_<LANG>_COMPILER.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list