IF(FOO) when FOO is "NO"
Brad King
brad.king at kitware.com
Tue Apr 18 16:22:02 CEST 2006
David Faure wrote:
> The documentation for IF says:
> IF(variable)
> True if the variable's value is not empty, 0, FALSE, OFF, or NOTFOUND.
>
> However with this code:
> message(STATUS "CACHED_AGG=${CACHED_AGG}")
> IF (CACHED_AGG)
> message(STATUS "inside if(CACHED_AGG)")
> ELSE (CACHED_AGG)
> message(STATUS "inside else(CACHED_AGG)")
> ENDIF (CACHED_AGG)
>
> I get:
> -- CACHED_AGG=NO
> -- inside else(CACHED_AGG)
>
> What's the bug? The behavior, or the documentation?
It's a documentation bug. I'll fix it.
> The context is that I want to fix the FindFoo checks so that they don't rerun commands
> when the result is in the cache already; so I added a CACHED_FOO variable which is set
> to YES or NO depending on whether the package was found previously (most packages are or can be optional).
> The IF() tells me that the package was searched for previously and that we can just use
> the results from the cache (YES = it was found, NO = it was not found).
> When the variable is empty, which is the case the very first time of course,
> then I know that the package was never searched for and that we have to check for it now.
> Should I use other values than YES/NO for this?
> Ah, or maybe just IF(DEFINED CACHED_AGG)?
The DEFINED test is the proper choice here. If the test has already
been done and put in the cache then the result variable will be defined.
If not, the variable will not be set and the test will be run.
-Brad
More information about the Kde-buildsystem
mailing list