[CMake] Restoring a variable.. but only once!

David Cole david.cole at kitware.com
Tue Jun 12 12:57:21 EDT 2007


Use "pairs of values", where you provide a named value that CMake does not
know anything about... Then use that value to force the cache value of the
variable that CMake does know about...

As in:
PROJECT(whatever CXX)

SET(MY_CMAKE_BUILD_TYPE "Debug" CACHE STRING "User settable value always
forces CMAKE_BUILD_TYPE value...")
SET(CMAKE_BUILD_TYPE "${MY_CMAKE_BUILD_TYPE}" CACHE INTERNAL "Internal
setting always contains value of MY_CMAKE_BUILD_TYPE..." FORCE)
MESSAGE(STATUS "MY_CMAKE_BUILD_TYPE='${MY_CMAKE_BUILD_TYPE}'")
MESSAGE(STATUS "CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}'")

SET(MY_SETTABLE_VALUE "can be set to anything..." CACHE STRING "User
settable value always forces UNSETTABLE_VALUE value...")
SET(UNSETTABLE_VALUE "${MY_SETTABLE_VALUE}" CACHE INTERNAL "Internal setting
always contains value of MY_SETTABLE_VALUE..." FORCE)
MESSAGE(STATUS "MY_SETTABLE_VALUE='${MY_SETTABLE_VALUE}'")
MESSAGE(STATUS "UNSETTABLE_VALUE='${UNSETTABLE_VALUE}'")


Good luck -- HTH,
David


On 6/12/07, Vitor Vasconcelos Araujo Silva <vasconcv at loria.fr> wrote:
>
>
> > Have a look here at the _SET_FANCY macro:
> >
> http://websvn.kde.org/trunk/KDE/kdelibs/cmake/modules/FindKDE4Internal.cmake?revision=668049&view=markup
> > http://www.cmake.org/mailman/listinfo/cmake
>
>     Hello Alex and all,
>
>         I read it, but my case is a little bit different.
>         I wish to define the CMAKE_BUILD_TYPE as the default type. But I
> don't
> want to use the FORCE rule, because my users may want to change it. My
> problem is: I'm only able to put the "Release" value in ccmake interface
> if I force it... I'm using Cmake 2.4 patch 3. Any tips?
>         Thanks.
>
>         Vitor Vasconcelos
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20070612/69cbc668/attachment.html


More information about the CMake mailing list