[CMake] CMake 2.8.1 / Win: Neither if nor else?`

Droscy droscy85 at yahoo.it
Sat May 22 04:50:32 EDT 2010


Hi Torsten

Torsten Rohlfing ha scritto:
> IF(ZLIB_FOUND)
>   MESSAGE( WARNING "HAVE system zlib" )
> ELSEIF(ZLIB_FOUND)
>   MESSAGE( WARNING "NO system zlib" )
> ENDIF(ZLIB_FOUND)
>
> [...]
>
> Can someone explain to me what I am missing?
You are not missing anything, simply you are wrongly using the IF
construct because the second command should be ELSE, not ELSEIF.

Your construct can be interpreted like this one
IF(ZLIB_FOUND)
    MESSAGE( WARNING "HAVE system zlib" )
ELSE(ZLIB_FOUND)
    IF(ZLIB_FOUND)
        MESSAGE( WARNING "NO system zlib" )
    ENDIF(ZLIB_FOUND)
ENDIF(ZLIB_FOUND)
so, of course you get no output if zlib is not found, and two outputs if
zlib is found.

The right construct is
IF(ZLIB_FOUND)
    MESSAGE( WARNING "HAVE system zlib" )
ELSE(ZLIB_FOUND)
    MESSAGE( WARNING "NO system zlib" )
ENDIF(ZLIB_FOUND)


Bye
Droscy




More information about the CMake mailing list