On Wednesday 18 July 2012, Yngve Inntjore Levinsen wrote:
> Hi Romain,
> 
> Have a look at the help for the function set:
> $ cmake --help-command set
> 
> If I understand the documentation, this should be what you are looking for:
> set(MY_VAR NEW_VALUE FORCE)

I don't think this does what you want.
It sets MY_VAR to "NEW_VALUE;FORCE".
set() without CACHE always sets/overrides anything set before.

The only time when you may need to enforce overriding is when the variable in 
question is a cache variable.

set(MY_VAR "foo" CACHE STRING "docs...")
set(MY_VAR "bar" CACHE STRING "docs...")

will leave MY_VAR at "foo", since setting a value in the cache only actually 
sets its value if it is not yet in the cache.
To set it anyway, you have to use FORCE:

set(MY_VAR "foo" CACHE STRING "docs...")
set(MY_VAR "bar" CACHE STRING "docs..." FORCE)

Using CACHE and non-CACHE variables with the same name may result in not quite 
obvious behaviour.

Alex
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to