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

Jerry Gagelman gagelman at gmail.com
Wed Jul 6 09:41:39 EDT 2011


I'm redistributing a library for which the original authors have hand coded
their own Makefile, but I would like to streamline everything with CMake.
Their Makefile provides for Debug and Release flavored configurations, each
has its own set of CFLAGS, and for consistency I would like to incorporate
the same set of flags.

Using the following commands, the configuration can be selected in the
cache:

if( DEFINED CMAKE_BUILD_TYPE )

set( CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Options are: Debug
Release")

else( DEFINED CMAKE_BUILD_TYPE )

set(CMAKE_BUILD_TYPE Debug CACHE STRING "Options are: Debug Release")

endif( DEFINED CMAKE_BUILD_TYPE )


That works. Next, I tried to update the C_FLAGS :


set( CMAKE_C_FLAGS_DEBUG "-Wall -Wno-format -g -DDEBUG" CACHE STRING
"Recommended debug flags." )

set( CMAKE_C_FLAGS_RELEASE "-Wall -Wno-unknown-pragmas -Wno-format -O3"
CACHE STRING "Recommended release flags." )

However running "make edit_cache" always reflects the default
CMAKE_C_FLAGS_{type}, not the new ones that I supplied. I have tried several
variations on this theme, but can't make it work. Before posting a bug
report, I thought I'd post this here in case there is anything obvious that
I'm missing.

Incidentally, I'm running CMake version 2.8.4, built by MacPorts.

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


More information about the CMake mailing list