[CMake] CMAKE_C*_FLAGS undefined.

Philip Lowman philip at yhbt.com
Sat Apr 4 15:21:40 EDT 2009


On Sat, Apr 4, 2009 at 2:37 PM, Óscar Fuentes <ofv at wanadoo.es> wrote:

> Philip Lowman <philip at yhbt.com> writes:
>  > One suggestion would be if you have non-definition flags you want to add
> to
> > every compilation you make, simply use CMAKE_C_FLAGS or CMAKE_CXX_FLAGS.
> >
> > if(CMAKE_COMPILER_IS_GNU_CC)
> >    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,s -save-temps")
> > endif()
>
> Wouldn't this conflict with the cache?


Local variables override the cache.  That is to say once you define
CMAKE_CXX_FLAGS any references to the variable from that point on are to the
local variable unless you unset it.

> add_definitions() was originally intended for preprocessor definitions
> > only.  If you're using it to non-definition compilation flags I have no
> idea
> > how you'll be able to pull those out again.
>
>
> As per my interpretation of the docs, add_definitions is the recommended
> way of adding extra compiler options. I may wrong.


I don't know what the preferred method is.  I think many people use
add_definitions() just because remove_definitions() exists.  I do an
add_definitions(-Wall) at my toplevel just because remove_definitions(-Wall)
is so much easier to read then string(REPLACE "-Wall" "" CMAKE_CXX_FLAGS
${CMAKE_CXX_FLAGS}).


-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090404/89f9200b/attachment.htm>


More information about the CMake mailing list