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

Reply via email to