[CMake] set(... CACHE ) broken for CMAKE_C_FLAGS_{DEBUG, RELEASE, ...} ?

Jerry Gagelman gagelman at gmail.com
Wed Jul 6 12:59:45 EDT 2011


2011/7/6 Alexander Neundorf <a.neundorf-work at gmx.net>

> On Wednesday 06 July 2011, Jerry Gagelman wrote:
>
> If these variables exist already in the cache, then a simple
> set(... CACHE ...)
> does not override the value which is already in the cache.
> You can only override a value in the cache from a CMakeLists.txt by using
> set(... CACHE... FORCE)
> This will put the given value always in the cache. Which also means if the
> user changes the value using "make edit_cache", the set(...CACHE ... FORCE)
> will override his changes again.
>
> Is this the behaviour you are seeing ?
>
>
Thanks. That is the behavior I'm seeing. But it's still not satisfactory. Is
it not possible to "initialize" variables in the cache with values using the
set() command?

I just tried the following, ignoring the cache altogether:

set( CMAKE_C_FLAGS_DEBUG "-Wall -Wno-format -g -DDEBUG" )
set( CMAKE_C_FLAGS_RELEASE "-Wall -Wno-unknown-pragmas -Wno-format -O3" )

I rebuilt everything, ensured that the CMAKE_BUILD_TYPE variable in the
cache is set to "Debug," and built the library using verbose Makefiles. The
compilation commands don't include the extra CMAKE_C_FLAGS_DEBUG flags as
directed.

I even tried it without quotes around the flag strings.

Evidently the cache is overriding commands in CMakeLists.txt.

Does anyone know if this is supposed to be a feature? If so, it feels rather
strange. I'm happy to file a bug report.

Thanks,
Jerry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110706/3c9ce0b5/attachment.htm>


More information about the CMake mailing list