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

Philip Lowman philip at yhbt.com
Sat May 22 11:19:42 EDT 2010


On Sat, May 22, 2010 at 4:50 AM, Droscy <droscy85 at yahoo.it> wrote:

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

And if compatibility with CMake < 2.4.4 isn't a concern, an even better way
to do this is:

# set this at your topmost CMakeLists.txt
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)

if(ZLIB_FOUND)
   message("HAVE system zlib")
else()
   message("NO system zlib")
endif()

P.S.
The WARNING option to message() is new to CMake 2.8.  For
better compatibility with CMake 2.6 and lower, simply omit it which should
give you a similar effect.

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100522/509e96f0/attachment.htm>


More information about the CMake mailing list