IF(FOO) when FOO is "NO"

David Faure faure at kde.org
Tue Apr 18 12:57:02 CEST 2006


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?

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)?

--
David Faure
faure at kde.org



More information about the Kde-buildsystem mailing list