[CMake] Globally add compiler options for gcc

Eric Noulard eric.noulard at gmail.com
Fri Jan 4 13:24:01 EST 2008


2008/1/4, James Bigler <bigler at cs.utah.edu>:
> On Jan 4, 2008, at 10:57 AM, Alexander Neundorf wrote:
> >
> > No, I think you are wrong here, it does work.
> > What happens is:
> >
> > CMAKE_C_FLAGS is read from the cache, e.g. "-O2 -ansi"
> > Then the set happens and appends the -Wall, so CMAKE_C_FLAGS is now
> > "-O2 -ansi -Wall"
> > This new value isn't saved to the cache, but stays only in the
> > "regular" cmake
> > variable. To get it in the cache SET(... CACHE ... FORCE) would
> > have to be
> > used. Only then it would be appended everytime again.
>
> I had suspisions that this was how that bit of code worked, so thanks
> for clearing this up for me.

Thanks you from my side too Alex.
I was wondering why it seems to work for me and was ready test
in order to seek where I missed the point :=)
You saved me time.

> There's still the outstanding issue of a flag being added that the
> user can't control (and may get irritated at), but perhaps a new
> cached CMake variable could be added to turn the warnings on and off.

Yes you are right
or one may add an OPTION in order to control
this kind of extra flags.

Note that one usually add a global -Wall in order to _FIX_ all
the phony warnings before release.
Once you do not have any warning you won't irritate your user :=)

-- 
Erk


More information about the CMake mailing list