[CMake] CMake and Lua

Ken Martin ken.martin at kitware.com
Mon Feb 25 10:06:35 EST 2008


> In principle CMake implements two thing,
>      - a scripting language,
>      - and a make/build-file generator.
> 
> As I understand it, these two things are currently
> mixed up in CMakeLib: all commands parse the arguments
> (scripting functionality) and then call the generator
> function with the found arguments, for instance
>    this->Makefile->AddSubDirectory(..
> 
> This makes it hard to introduce a new scripting language,
> if it should not only be a wrapper of the current cmake
> commands.
> Isn't this your ansatz in your Lua experiment?
> http://www.cmake.org/Wiki/CMake:Experiments_With_Lua
> http://www.assembla.com/wiki/show/CMakeLua
> 
> 
> I would choose a different way:
> First I would split the current CMakeLib into two libs,
> one which implements the macro language, and the other
> which implements the generator stuff only, nothing knowing
> about any scripting/macro language.

In VTK and ITK we did design a language independent toolkit and wrapped it
into Tcl, Python, Java etc so we have done that and have a good feel for it.
But for CMake I do not think it is a good idea for a couple reasons. One is
fragmentation of the community/support. 

The other is that a non-trivial portion of CMake is written in the scripting
language ala the Modules directory. So supporting multiple languages becomes
problematic. Most languages are not designed to mix with other languages. I
doubt you can mix python and Lua and expect them to be able to access each
other's variables out of the box. But with the Modules directory we either
have to have a copy of each module for every possible scripting language, on
the fly converters between any two scripting languages, or something like
that to make it work. Trying to figure out how to manage the mixed
CMakeScript/Lua variables by itself is already a bit of an issue to
providing a Lua binding much less adding other languages on top of that.
Hopefully that makes some sense :)

Thanks
Ken



More information about the CMake mailing list