[CMake] CMake & OCaml

Eric Noulard eric.noulard at gmail.com
Wed Aug 25 16:20:23 EDT 2010


2010/8/25 Alan W. Irwin <irwin at beluga.phys.uvic.ca>:
> On 2010-08-25 17:50+0200 Eric Noulard wrote:
>
>> 2010/8/25 Magnus Therning <magnus at therning.org>:
>>>
>>> A while ago I started looking at using CMake to build OCaml projects.  As
>>> part
>>> of that I put together some useful (but maybe not very beautiful) macros.
>>> They are available on github[1].
>>>
>>> I've come to the conclusion that while CMake is a rather good build tool,
>>> it
>>> isn't very well designed to add full support for slightly esoteric
>>> languages
>>> and tool chains like OCaml.
>>
>> I'm no OCaml expert but I'd like to know how you decided to build
>> your OCaml project then?
>> using ocamlbuild? custom makefiles ?
>>
>> May be you can give us here a the "main" 3 or so reasons
>> you think CMake cannot handle OCaml project building.
>>
>> It may be useful for other not to go through the same path
>> you did.
>
> Look at my post (which crossed yours) for some of the ocaml issues we
> encountered in the PLplot project.  In short, the detailed
> custom-command/custom-target approach works, but many different kinds
> of build commands are involved (much more than the "normal" compile
> and link)

Read your answer with interest and was about to answer too :-)

[...]
> It is possible somebody with knowledge of the internals of CMake could
> change things around so that the configurable commands to build
> libraries could be a whole set of detailed custom commands and targets
> specified at the language support level.

[...]

I was about to propose such "trapped" extension to language support.
Take my words with "[double]-quotes" because I have not enough knowledge
of that part (language support) of CMake.

My ideas was that some languages:
    - OCaml   (ocamlbuild)
    - ADA      (gnatmake)
    - may Java too (ant/maven)

have already very efficient build tool with some history of usage too.
I don't know many Java developers who speaks "makefile", most
of them speak "Eclipse/Netbeans" and many of them ant (http://ant.apache.org/)
what would be the advantage to go for CMake?

Most of those tools are already cross-platform and they are pretty
efficient (Ant for example is very handy and includes a plugins system
which makes it easy to extend for doing fancy things)
with a good user base.

My point is I don't think it would be useful (for me) to have some
Java/Ocaml/...
builtin support in CMake, because:
   1) I would have to port already working nice build systems
   2) I would have to argue with other on why they would learn CMake
       they don't need because they are only concerned with the Java part.

However I may have some project with mixed "classical compiled+linked languages"
like C/C++/Fortran with some interface/plugins in "not classically
compiled+linked"
Java/OCaml etc...
(looks like the PLplot layout) I'd expect to be able to build
all those thing with.

cmake
make
make package (or make install)

I suggest some language plugins support for CMake which makes it possible
to weave "native" build tools (ant, ocamlbuild, gnatmake) with CMake
control build.

I think this may be more than set of "custom command model" I would want
something like "generic (or specific) build tool interface"

CMake should know about
   sources (directories and files)
   dependencies
   targets

I may do something like:

find_delegate_builtool(Ant)

if (Ant_TOOL_FOUND)
   add_delegated_target(TARGETS JavaPlug1 JavaPlug2
                                   SOURCES  jsrc1 jsrc2 build1.xml build2.xml
                                   BUILD_COMMAND ${Ant_TOOL} all
                                   CHECKDEP_COMMAND ${Ant_TOOL} all
                                   CLEAN_COMMAND ${Ant_TOOL} clean
                                   GETOUTPUTS_COMMAND ${Ant_TOOL} getoutput)
endif(Ant_TOOL_FOUND)

the "delegate build tool" would be responsible for building targets
with "BUILD_COMMAND" and "CHECKDEP_COMMAND" for checking dependencies
SOURCES specifies the list of sources (inputs for the BUIDL TOOL).
"GETOUTPUTS_COMMAND" may be used by CMake to get the list
of may be file/dir produced by the build tool.
the "CLEAN_COMMAND" may be used to clean that part of the project.

This could be something like "ExternalProject_Add"
but may be renamed to "ForeignLanguageProject_Add" :-)

> Do the CMake developers here like the idea of this type of
> generalization of the CMake language support?

Same question for me :-)

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list