[CMake] CMAKE_BUILD_TYPE does not work correctly for Linux and CMake-2.4.6

Alan W. Irwin irwin at beluga.phys.uvic.ca
Tue Apr 3 12:19:21 EDT 2007


On 2007-04-01 13:59-0700 Alan W. Irwin wrote:

> I have found two bugs in compiler flag support for Linux that I would like
> to discuss here before making formal bug reports.
>
> 1.  A general compiler flag bug with ENABLE_LANGUAGE.
>
> The combination
>
> PROJECT(free_eos CXX)
> ENABLE_LANGUAGE(C)
>
> defines the correct CXX flags, but blanks the C flags in the cache rather
> than defining them properly[...]
> With these compile flags blanked, it turns, e.g., CMAKE_BUILD_TYPE=Debug
> into a no-op for the C language.
>
> If I try, instead
>
> PROJECT(free_eos C)
> ENABLE_LANGUAGE(CXX)
>
> then the C flags are defined correctly, but the CXX flags are blanked
> turning, e.g., CMAKE_BUILD_TYPE=Debug into a no-op for the C++ language.
>
> I don't know a fix for this bug in ENABLE_LANGUAGE for Linux, and the only
> workaround is never to use it, and always specify required languages with
> the PROJECT command (which is awkward if you want to have language support
> at the user's option).

Since there was no discussion of this bug here, I assume it has not been
fixed in CVS and is instead a new discovery so it is now bug 4772.

>
> #######Bug in Fortran flags.
>
> Even if I use
>
> PROJECT(free_eos Fortran)
>
> to avoid the first general compiler flag bug, then the
> cached Fortran flags I get with Linux/g77 for 2.4.6 are all blanked [....]

which _always_ turns, e.g., CMAKE_BUILD_TYPE=Debug into a no-op for g77 on
Linux.

>
> A fix for this bug is to put the following lines at the end of
> Platform/gcc.cmake:
>
> # Treat g77 the same as gcc and g++
> INCLUDE(Platform/g77)

N.B. ENABLE_LANGUAGE is broken for Fortran just as it is for C and C++ (see
bug 4772 above) so you must work around that issue by specifying Fortran in
the PROJECT command before the above two-line fix will work.

Since there was no discussion of this bug here, I assume it has not been
fixed in CVS and is instead a new discovery so it is now bug 4773.

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 Yorick front-end to PLplot (yplot.sf.net); 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