Re: [CMake] Enable warnings

2008-02-25 Thread Alan W. Irwin

On 2008-02-25 11:53+0100 BlinkEye wrote:


On Mon, February 25, 2008 11:11, dizzy wrote:

That looks fairly unportable (how do you make sure your compiler supports
those flags? if it doesn't it won't compile at all which is not probably what
you want since you are using cmake I supose you want it portable).

I prefer first to detect supported compiler arguments with
CheckCXXCompilerFlag() and if yes add it to the CFLAGS of targets using
SET_TARGET_PROPERTIES(target PROPERTIES COMPILE_FLAGS ...) (and if one wants
to share several flags among many targets, put the flags in some variables
and expand the variables in the SET_TARGET_PROPERTIES commands).


That's not very portable, true. But you understand the problem of the OP, do 
you?
He's new to cmake and he was asking on how to set compiler specific flags. Even
though your answers not wrong it doesn't help him at all. And no, cmake isn't 
used
just because it's portable.


However, portability is often an important issue so it's certainly
legitimate to discuss it (especially when others besides the OP will be
reviewing this thread).

I agree with dizzy that coding a bunch of compiler flags into CMake scripts
is a mistake for all projects that care about portability.  A solution that
has not been mentioned so far in this thread but which I far prefer to any
other is to use the CC environment variable to set both the compiler and its
options before cmake is invoked, e.g.,

export CC='gcc -O2'
cmake 

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
__
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Enable warnings

2008-02-25 Thread Alexander Neundorf
On Monday 25 February 2008, dizzy wrote:
> On Sunday 24 February 2008 23:22:58 blinkeye wrote:
> >  >> On 2/24/08, David Sveningsson <[EMAIL PROTECTED]> wrote:
> > >>
> > >> Hi, I'm quite new with cmake and I can't figure out how to enable
> > >> warnings for the generated makefiles/projects. For instance, I would
> > >> like to use the -Wall flag with gcc.
> >
> > like that for example:
> >
> > set( CMAKE_C_FLAGS   "-fstack-protector -fstack-protector-all" )
> > set( CMAKE_C_FLAGS_DEBUG   "-O2 -Wall -ggdb" )
> > set( CMAKE_C_FLAGS_RELEASE   "-Os -Wall" )
> >
> > set( CMAKE_CXX_FLAGS "-fstack-protector -fstack-protector-all" )
> > set( CMAKE_CXX_FLAGS_DEBUG "-O2 -Wall -ggdb" )
> > set( CMAKE_CXX_FLAGS_RELEASE "-Os -Wall" )
>
> That looks fairly unportable (how do you make sure your compiler supports
> those flags? if it doesn't it won't compile at all which is not probably
> what you want since you are using cmake I supose you want it portable).
>
> I prefer first to detect supported compiler arguments with
> CheckCXXCompilerFlag() and if yes add it to the CFLAGS of targets using
> SET_TARGET_PROPERTIES(target PROPERTIES COMPILE_FLAGS ...) (and if one
> wants to share several flags among many targets, put the flags in some
> variables and expand the variables in the SET_TARGET_PROPERTIES commands).

Or the simpler option:
if(CMAKE_COMPILER_IS_GNUCC)
... set gcc specific options


with cmake cvs/coming 2.6 you can do 

if (${CMAKE_C_COMPILER_ID} MATCHES GNU)
... set gcc specific options

Alex

___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Enable warnings

2008-02-25 Thread BlinkEye
On Mon, February 25, 2008 11:11, dizzy wrote:
> On Sunday 24 February 2008 23:22:58 blinkeye wrote:
>>  >> On 2/24/08, David Sveningsson <[EMAIL PROTECTED]> wrote:
>> >>
>> >> Hi, I'm quite new with cmake and I can't figure out how to enable
>> >> warnings for the generated makefiles/projects. For instance, I would
>> >> like to use the -Wall flag with gcc.
>>
>> like that for example:
>>
>> set( CMAKE_C_FLAGS   "-fstack-protector -fstack-protector-all" )
>> set( CMAKE_C_FLAGS_DEBUG   "-O2 -Wall -ggdb" )
>> set( CMAKE_C_FLAGS_RELEASE   "-Os -Wall" )
>>
>> set( CMAKE_CXX_FLAGS "-fstack-protector -fstack-protector-all" )
>> set( CMAKE_CXX_FLAGS_DEBUG "-O2 -Wall -ggdb" )
>> set( CMAKE_CXX_FLAGS_RELEASE "-Os -Wall" )
>
> That looks fairly unportable (how do you make sure your compiler supports
> those flags? if it doesn't it won't compile at all which is not probably what
> you want since you are using cmake I supose you want it portable).
>
> I prefer first to detect supported compiler arguments with
> CheckCXXCompilerFlag() and if yes add it to the CFLAGS of targets using
> SET_TARGET_PROPERTIES(target PROPERTIES COMPILE_FLAGS ...) (and if one wants
> to share several flags among many targets, put the flags in some variables
> and expand the variables in the SET_TARGET_PROPERTIES commands).
>
That's not very portable, true. But you understand the problem of the OP, do 
you?
He's new to cmake and he was asking on how to set compiler specific flags. Even
though your answers not wrong it doesn't help him at all. And no, cmake isn't 
used
just because it's portable.


___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Enable warnings

2008-02-25 Thread dizzy
On Sunday 24 February 2008 23:22:58 blinkeye wrote:
>  >> On 2/24/08, David Sveningsson <[EMAIL PROTECTED]> wrote:
> >>
> >> Hi, I'm quite new with cmake and I can't figure out how to enable
> >> warnings for the generated makefiles/projects. For instance, I would
> >> like to use the -Wall flag with gcc.
>
> like that for example:
>
> set( CMAKE_C_FLAGS   "-fstack-protector -fstack-protector-all" )
> set( CMAKE_C_FLAGS_DEBUG   "-O2 -Wall -ggdb" )
> set( CMAKE_C_FLAGS_RELEASE   "-Os -Wall" )
>
> set( CMAKE_CXX_FLAGS "-fstack-protector -fstack-protector-all" )
> set( CMAKE_CXX_FLAGS_DEBUG "-O2 -Wall -ggdb" )
> set( CMAKE_CXX_FLAGS_RELEASE "-Os -Wall" )

That looks fairly unportable (how do you make sure your compiler supports 
those flags? if it doesn't it won't compile at all which is not probably what 
you want since you are using cmake I supose you want it portable).

I prefer first to detect supported compiler arguments with 
CheckCXXCompilerFlag() and if yes add it to the CFLAGS of targets using 
SET_TARGET_PROPERTIES(target PROPERTIES COMPILE_FLAGS ...) (and if one wants 
to share several flags among many targets, put the flags in some variables 
and expand the variables in the SET_TARGET_PROPERTIES commands).

-- 
Mihai RUSU  Email: [EMAIL PROTECTED]
"Linux is obsolete" -- AST
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Enable warnings

2008-02-24 Thread blinkeye

>> On 2/24/08, David Sveningsson <[EMAIL PROTECTED]> wrote:

Hi, I'm quite new with cmake and I can't figure out how to enable
warnings for the generated makefiles/projects. For instance, I would
like to use the -Wall flag with gcc.



like that for example:

set( CMAKE_C_FLAGS   "-fstack-protector -fstack-protector-all" )
set( CMAKE_C_FLAGS_DEBUG   "-O2 -Wall -ggdb" )
set( CMAKE_C_FLAGS_RELEASE   "-Os -Wall" )

set( CMAKE_CXX_FLAGS "-fstack-protector -fstack-protector-all" )
set( CMAKE_CXX_FLAGS_DEBUG "-O2 -Wall -ggdb" )
set( CMAKE_CXX_FLAGS_RELEASE "-Os -Wall" )
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Enable warnings

2008-02-24 Thread E. Wing
In ccmake or CMakeSetup, add the flag to either CMAKE_C_FLAGS or
CMAKE_CXX_FLAGS.

-Eric


On 2/24/08, David Sveningsson <[EMAIL PROTECTED]> wrote:
> Hi, I'm quite new with cmake and I can't figure out how to enable
> warnings for the generated makefiles/projects. For instance, I would
> like to use the -Wall flag with gcc.
>
> --
>
>
> //*David Sveningsson [eXt]*
>
> Freelance coder | Game Development Student
> http://sidvind.com
>
> Thou shalt make thy program's purpose and structure clear to thy fellow
> man by using the One True Brace Style, even if thou likest it not, for
> thy creativity is better used in solving problems than in creating
> beautiful new impediments to understanding.
> ___
> CMake mailing list
> CMake@cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake