[CMake] Weird if nesting problem
Brandon J. Van Every
bvanevery at gmail.com
Tue Dec 5 23:04:30 EST 2006
James Bigler wrote:
>
>
> FIND_PROGRAM(PARSER_EXECUTABLE
> NAMES my_parser
> PATHS ${PARSER_DIR} )
>
> IF(EXISTS ${PARSER_EXECUTABLE})
> SET(PARSERS_FOUND 1)
> ELSE(EXISTS ${PARSER_EXECUTABLE})
> SET(PARSERS_FOUND 0)
> ENDIF(EXISTS ${PARSER_EXECUTABLE})
>
> CMake Error: Error in cmake code at
> /tmp/bigler/manta/trunk/src/CMake/FindParsers.cmake:20:
> IF had incorrect arguments: EXISTS ${BISON_EXECUTABLE} (Unknown
> arguments specified).
> Current CMake stack:
>
> Is this a bug, or am I doing something wrong. I would expect that
> nothing in the else block to be evaluated if the if statement were true.
Try IF(${PARSER_EXECUTABLE}).
A FIND_PROGRAM always sets a variable to -NOTFOUND when it doesn't find
anything. This is equivalent to FALSE.
Now having said that, I'd expect EXISTS to work. But I'm a little tired
to go over your program behavior. The general drill with things like
this, is to isolate the offending code snippet down to a trivial
reproducer. Your current snipped is almost but-not-quite trivial. I
note the docs say, "[EXISTS] behavior is well-defined only for full
paths." Is PARSER_EXECUTABLE in fact a full path?
BTW, given the -NOTFOUND output, seems like PARSERS_FOUND is a redundant
variable.
Cheers,
Brandon Van Every
More information about the CMake
mailing list