> ------------------------------
> Message: 5
> Date: Wed, 06 Dec 2006 10:56:39 -0800
> From: "Brandon J. Van Every" <[EMAIL PROTECTED]>
> Subject: Re: [CMake] Re: Weird if nesting problem
> To: cmake <cmake@cmake.org>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 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})
This works fine.
> 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)
OK, so this simple example works, but when I make it more complicated
(like in my code) it breaks. All I do is add one more FIND_PROGRAM. I
thought I also tested it with finding a single parser. By the way
looking for two programs without the outer IF(1) works fine.
IF(1)
MESSAGE("It's True!")
ELSE(1)
FIND_PROGRAM(PARSER_EXECUTABLE
NAMES my_parser
PATHS ${PARSER_DIR} )
FIND_PROGRAM(PARSER_EXECUTABLE_2
NAMES my_parser_2
PATHS ${PARSER_DIR} )
IF(EXISTS ${PARSER_EXECUTABLE} AND EXISTS ${PARSER_EXECUTABLE_2})
SET(PARSERS_FOUND 1)
ELSE(EXISTS ${PARSER_EXECUTABLE} AND EXISTS ${PARSER_EXECUTABLE_2})
SET(PARSERS_FOUND 0)
ENDIF(EXISTS ${PARSER_EXECUTABLE} AND EXISTS ${PARSER_EXECUTABLE_2})
ENDIF(1)
> You need to isolate where your problem occurs. You've got slightly too
> much going on to be useful.
So, in summary this is broken (got rid of extra bodies for brevity, but
tested the code as below but with real programs for p_1 and p_2):
IF(1)
ELSE(1)
FIND_PROGRAM(P_1 p_1)
FIND_PROGRAM(P_2 p_2)
IF(EXISTS ${P_1} AND EXISTS ${P_2} )
ELSE(EXISTS ${P_1} AND EXISTS ${P_2} )
ENDIF(EXISTS ${P_1} AND EXISTS ${P_2} )
ENDIF(1)
============= ERROR MESSAGE =================
IF had incorrect arguments: EXISTS ${P_1} AND EXISTS ${P_2} (Unknown
arguments specified).
This works:
IF(1)
ELSE(1)
FIND_PROGRAM(P_1 p_1)
FIND_PROGRAM(P_2 p_2)
IF(EXISTS ${P_1})
ELSE(EXISTS ${P_1})
ENDIF(EXISTS ${P_1})
ENDIF(1)
This works:
FIND_PROGRAM(P_1 p_1)
FIND_PROGRAM(P_2 p_2)
IF(EXISTS ${P_1} AND EXISTS ${P_2} )
ELSE(EXISTS ${P_1} AND EXISTS ${P_2} )
ENDIF(EXISTS ${P_1} AND EXISTS ${P_2} )
James
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake