[CMake] Re: Weird if nesting problem
Brandon J. Van Every
bvanevery at gmail.com
Wed Dec 6 13:56:39 EST 2006
James Bigler wrote:
>
>
> If you look at the original code. The PARSER_EXECUTABLE variable
> isn't defined until inside the first ELSE branch.
>
> # You need at least version 2.4 for this to work.
> IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
> MESSAGE("You need at least version 2.4 for generating stuff. Go get
> it from http://www.cmake.org/HTML/Download.html")
> SET(PARSERS_FOUND 0)
>
> ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
>
> 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})
>
> ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
>
> -----------------------------------------------------------
>
> PARSER_EXECUTABLE doesn't exist until I'm in the ELSE block.
> IF(EXISTS ${PARSER_EXECUTABLE}) should *NEVER* get evaluated, but it
> does.
Well, if you get rid of the first IF..ELSE, do things work? i.e.
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})
And how about:
IF(TRUE)
MESSAGE("Yeah it's true baby.")
ELSE(TRUE)
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})
ENDIF(TRUE)
You need to isolate where your problem occurs. You've got slightly too
much going on to be useful.
Cheers,
Brandon Van Every
More information about the CMake
mailing list