[CMake] CMake and Lua

Bill Hoffman bill.hoffman at kitware.com
Wed Feb 27 16:34:40 EST 2008


If people want a tower of babel set of languages that can drive CMake, 
they can do it now.  Just write most of your build system in X, tell 
your users they have to install CMake and X.  Then use the powerful 
language X to generate simple CMake files. (where X is python, tcl, 
perl, lua, or what ever someone likes.) For the most part the actual 
build part of CMake is pretty simple:

add_library(foo ...)
add_executable(bar ...)
target_link_libraries(bar foo)

Even find modules could be written in Lua or some other language then 
called with execute_process.   The trick is the people that are building 
that package will need CMake and X.  The original intent of having CMake 
create it's own language was to have minimal dependencies on CMake 
itself. To build CMake, you need a C++ compiler and its native build 
tools.  Since CMake was developed to build C++ programs, this seemed 
like a good dependency.   Having to install CMake on the system you want 
to build on is often a show stopper for people looking at CMake compared 
to autotools.  Having to install CMake, and X, Y, or maybe Z would be 
even worst.

Lua is interesting since it is small and easy to embed.  I am still not 
sure it is worth the effort. However, the idea of having multiple 
languages is IMO horrible.  Unless all of those languages are built in 
and delivered with the one CMake binary it will turn CMake projects that 
use these extra languages into a pain in the neck to build.   You will 
have what I like to call the "easter egg hunt" to build packages.  Users 
will have to install several packages just to build one package.

Also, backwards compatibility is something we take very seriously.  If 
someone picks CMake as a build tool, we have to respect that choice and 
try our best not to break that project. There are very large projects 
that have many lines of CMake code in them.  People have put a great 
deal of effort into creating those files.  If they don't have the time 
to re-write in a new language, I don't blame them.  I also won't try to 
force them to do it, by obsoleting the current language.   So, we might 
have two official languages someday, but no more than that.

If you want to use other languages, then use execute_process inside your 
CMake files, and make sure to tell your uses what they have to install 
to build your package.

-Bill

-Bill


More information about the CMake mailing list