[CMake] Howto unset cache variable without UNSET()

Marcel Loose loose at astron.nl
Fri Jul 2 05:15:35 EDT 2010


Hi Tyler,

That's because I would like to use FOO as a sort of tribool variable.
Besides TRUE and FALSE, I'd like to know whether FOO was defined at all.
If not that qualifies and neither TRUE nor FALSE.

'IF(FOO)' will return FALSE, either when FOO is FALSE or when FOO is not
DEFINED. Therefore, I wanted to resort to 'IF DEFINED(FOO)'.

Best regards,
Marcel.

On Thu, 2010-07-01 at 07:43 -0700, Tyler Roscoe wrote:
> Marcel,
> 
> Maybe I missed it earlier ITT, but I don't understand why you can't
just
> use if(FOO) instead?
> 
> tyler
> 
> On Thu, Jul 01, 2010 at 11:53:33AM +0200, Marcel Loose wrote:
> > Hi Fraser,
> > 
> > It doesn't. Well, partly it does, but unfortunately setting FOO to
an
> > empty string doesn't make it undefined; i.e. if(DEFINED FOO) will be
> > TRUE. I've decided to use 'if("${FOO}" MATCHES "^$")' instead.
> > 
> > Best regards,
> > Marcel Loose.
> > 
> > On Wed, 2010-06-30 at 10:57 +0100, Fraser Hutchison wrote:
> > > I think 'set(FOO "" CACHE INTERNAL "Foo")' should do the trick.
> > > 
> > > All the best,
> > > 
> > > Fraser.
> > > 
> > > 
> > > 
> > > On 30/06/2010 9:38 AM, Marcel Loose wrote:
> > > > Hi all,
> > > >
> > > > Is there a way to unset a cache variable, i.e. make it
undefined,
> > > > *without* using unset().
> > > >
> > > > My reason for asking is that my CMake scripts need to be
backward
> > > > compatible with every 2.6 version. Unfortunately, unset() was
added
> > in a
> > > > patch release (2.6.3 if I recall correctly), so I cannot use it.
> > > >
> > > > The problem is that, though 'set(FOO)' will make FOO undefined,
this
> > > > doesn't seem to work for 'set(FOO CACHE INTERNAL "Foo")'.
> > > >
> > > > Any ideas how to accomplish this?
> > > >
> > > > Best regards,
> > > > Marcel Loose.
> > > >
> > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > 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
> > > >    
> > 
> > 
> > _______________________________________________
> > 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




More information about the CMake mailing list