[CMake] If syntax

Mika.Rajala at patria.fi Mika.Rajala at patria.fi
Mon May 2 06:20:36 EDT 2011


Hi

if(expression)
 ...
endif(expression2)

Makes an error since the expressions didn't match

I think this is the case with "else" as well.

However, i'm uncertain how to write it when you use elseif, maybe it still 
needs to match with the expression in the IF thing


The reasoning behind this, AFAIK, is to provide checking for errors in 
your scripts.

Feel free to leave those out from else and endif if you trust yourself : )

-mika



From:   Michael Wild <themiwi at gmail.com>
To:     cmake at cmake.org
Date:   02.05.2011 07:56
Subject:        Re: [CMake] If syntax
Sent by:        cmake-bounces at cmake.org



On 05/01/2011 10:30 PM, David Doria wrote:
> According to this:
> http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:if
> 
> the syntax is:
> 
>   if(expression)
>     ...
>   elseif(expression2)
>     ...
>   else(expression)
>     ...
>   endif(expression)
> 
> I was recently made aware that:
> 
> 
>   if(expression)
>     ...
>   elseif(expression2)
>     ...
>   else()
>     ...
>   endif()
> 
> should also work. Should the documentation be updated to reflect this
> possibility? Or are they different in some way?
> 
> David



More information about the CMake mailing list