[CMake] Add_definitions() also affects RC_FLAGS ?

Bob Paddock bob.paddock at gmail.com
Sat Jun 28 08:58:05 EDT 2008


On Sunday 22 June 2008 03:25:21 pm Bill Hoffman wrote:
> Don't use add_definitions for compiler flags.  Use CMAKE_CXX_FLAGS or
> CMAKE_C_FLAGS.

Can you show an example please?

When I try these:

SET (CMAKE_CXX_FLAGS_DEBUG "-Wall" )
SET (CMAKE_CXX_FLAGS_RELEASE "-Wall" )
SET (CMAKE_C_FLAGS_DEBUG "-Wall" )
SET (CMAKE_C_FLAGS_RELEASE "-Wall" )

I do not find "-Wall" in the resultant Makefile (Actually 'Wall' doesn't
appear *anyplace* in the build directory???),
for that mater I don't find the default values in
the Makefile either.  What am I doing wrong?

This after doing a rm -rf Build;mkdir Build... to remove any potential of a 
cached file being found.

I'm using this to show the values, which do show what I expect to see:
MESSAGE("c init = ${CMAKE_C_FLAGS_INIT}")
MESSAGE("c debug init = ${CMAKE_C_FLAGS_DEBUG_INIT}")
MESSAGE("c release = ${CMAKE_C_FLAGS_RELEASE}")
MESSAGE("c debug = ${CMAKE_C_FLAGS_DEBUG}")
MESSAGE("c++ init = ${CMAKE_CXX_FLAGS_INIT}")
MESSAGE("c++ debug init = ${CMAKE_CXX_FLAGS_DEBUG_INIT}")
MESSAGE("c++ release = ${CMAKE_CXX_FLAGS_RELEASE}")
MESSAGE("c++ debug = ${CMAKE_CXX_FLAGS_DEBUG}")

Also if I try to this:

SET (CMAKE_C_FLAGS_RELEASE "-Wall" ${CMAKE_C_FLAGS_RELEASE} )

I get this:

c release = -Wall;-O3 -DNDEBUG

Note the added ";".  Where did that come from?

This is with under Linux with CMake 2.4 patch 8,
with GCC as the target compiler.


-- 
                http://www.wearablesmartsensors.com/
 http://www.softwaresafety.net/ http://www.designer-iii.com/
                 http://www.unusualresearch.com/


More information about the CMake mailing list