[fixed top-posting and missing quotation characters] On 05/02/2011 12:20 PM, [email protected] wrote: >> 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 > <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 >> >> From the documentation of the IF() command: >> >>> Note that the expression in the else and endif clause is optional. >> >> Michael > > > 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 >
In the else() and endif() clause you have to use the expression used in the initial if() clause. Michael _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
