[CMake] a backwards compatible language simplification

Ken Martin ken.martin at kitware.com
Thu May 11 09:46:34 EDT 2006


> Having spent all day hacking a massive project using cmake, I wonder...
> 
> could this
> 
> FOREACH (foo ${foolist})
>   IF (${foo} STREQUAL "bar")
>     ...
>   ELSE (${foo} STREQUAL "bar")
>     ...
>   ENDIF (${foo} STREQUAL "bar")
> ENDFOREACH (foo ${foolist})
> 
> change to this:
> 
> FOREACH (foo ${foolist})
>   IF (${foo} STREQUAL "bar")
>     ...
>   ELSE
>     ...
>   ENDIF
> ENDFOREACH
> 
> Temporarily supporting gunk after the ELSE/ENDIF/ENDFOREACH for migration?

Well the ENDFOREACH only needs the iteration variable so your example could
be changed to:

FOREACH (foo ${foolist})
  IF (${foo} STREQUAL "bar")
    ...
  ELSE (${foo} STREQUAL "bar")
    ...
  ENDIF (${foo} STREQUAL "bar")
ENDFOREACH (foo)

But to answer the meat of your question I do not think it can be trivially
changed to not require the extra text but I'll try to take a look at it over
the next few days. Personally I like the extra text but I certainly
understand how it might drive some folks batty.

Ken



More information about the CMake mailing list