[CMake] Weird if nesting problem

James Bigler bigler at cs.utah.edu
Tue Dec 5 16:44:17 EST 2006


I have this little block of code that is causing problems.  Note that I 
bumped up the version number in order to get cmake 2.4 to go the else block.

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

------------------------------------------------------------

CMake barfs on the first IF(EXISTS ${PARSER_EXECUTABLE}), probably 
because it is trying to evaluate if this expression is part of the ENDIF 
or something.  It does this with 2.2.3, 2.4.3, 2.4.5 on Linux.

Here's the output.

----------------------------------------------------------
You need at least version 2.4 for generating flex and bison parsers.  Go 
get it from http://www.cmake.org/HTML/Download.html

  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:
 
/tmp/bigler/manta/trunk/src/scenes/galileo/CMakeLists.txt;/tmp/bigler/manta/t
  runk/src/CMake/FindParsers.cmake

----------------------------------------------------------

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.

Thanks,
James


More information about the CMake mailing list