CMake KDE release

Alexander Neundorf neundorf at kde.org
Mon Jan 30 17:44:22 GMT 2006


Hi Simon,

On Monday 30 January 2006 08:26, Simon Hausmann wrote:
...
> I can identify three problems:
>
> 1) It's inconsistent, see paragraph at the end of this mail. There's a
> reason why other programming languages avoid redundant terms unless they
> improve readability.

See below.

> ) It's error-prone. You can be sure that most people will frequently forget
> to adjust the else and endif part when changing a condition. It wonderfully
> combines with typos people are going to make in the repetitions:
>
> IF (NOT APPLE AND WIN32 OR UNIX AND DEFINED HAVE_GETENV)
>     add_foo_bar()
>     IF (APPLE OR WIN32)
>         baz()
>     ENDIF (APPLE OR WIN32)
> ELSE (NOT APPLE AND WIN32 OR UNIX AND DEFINED HAVE_GETVN)
>     foo()
> ENDIF (NOT APPLE AND WIN32 OR UNIX AND DEFINED HAVE_GETENV)
>
> If I understand the mail at
>
> 	http://public.kitware.com/pipermail/cmake/2002-August/002942.html
>
> correctly, then cmake doesn't even warn about the typo in the above
> construct because the condition in ELSE is actually evaluated! That's a
> recipe for bugs.

The mail you mentioned is more than three years old.
It contains the following words: "I'll take a stab at changing
it later today."
So before stating that that's a recipe for bugs, a quick test would have 
revealed:

$ cat CMakeLists.txt
if(UNIX)
else(WIN32)
endif(UNIX)
$ cmake .
CMake Error: Error in cmake code at
/home/alex/src/tests/cmakeelse/CMakeLists.txt:2:
ELSE An ELSE command was found outside of a proper IF ENDIF structure. Or its 
arguments did not match the opening IF command.
-- Configuring done
$

So, no chance for this kind of bugs.

...
> For someone trying to learn the KDE platform it does not matter whether the
> build system uses a full fledged programming language or just some
> descriptive configuration file syntax. What matters is that the syntax is
> intuitive and consistent. I don't believe the cmake way of repeating the
> condition in the else and endif part qualifies for that. Off-hand I can't
> think of any other programming language (or configuration/macro language as
> you said) that has a similar requirement for conditionals.

How about HTML or XML ? Basically everybody is able to write simple 
HTML-pages. 

IMO this is a matter of taste, there are pros and cons.
If I would have designed the cmake IF/ELSE/ENDIF commands, I wouldn't have 
implemented the way it is now with requiring to repeat the argument of the 
opening IF.
Still, I'm using cmake now for more than two years, and this requirement was 
unusual at the beginning, but has never been a real problem. You get used to 
it.

Just chose any programming language, and I'm sure you'll find in every 
language things which can be considered "insane" by people who don't like 
this language (be it C, C++, Java, Ruby, Python, Perl, m4, whatever).

Bye
Alex
-- 
Work: alexander.neundorf AT jenoptik.com - http://www.jenoptik-los.de
Home: neundorf AT kde.org                - http://www.kde.org
      alex AT neundorf.net               - http://www.neundorf.net




More information about the kde-core-devel mailing list