[CMake] Adding a new language

Hendrik Sattler post at hendrik-sattler.de
Thu Nov 10 01:38:35 EST 2011


Am 09.11.2011 23:00, schrieb Stefan Monnier:
> I'm trying to use cmake for a project using OCaml, so I'm trying to 
> add
> support for a new language.
>
> Among the many problems I encounter, the most pressing is the
> following: the rule to build object files 
> (CMAKE_OCaml_COMPILE_OBJECT)
> seems to want a command that takes <SOURCE> and generates <OBJECT>, 
> both
> of which absolute file names.
>
> Problems is, `ocamlc' seems to insist on sending the result to a file
> name of its own choosing (basically <SOURCE> with the extension
> modified).  Worse yet: it generates 2 files (a .cmo object file and
> a .cmi that is similar to a header file).
>
> The rule below "works":
>
> set (CMAKE_OCaml_COMPILE_OBJECT
>   "<CMAKE_OCaml_COMPILER> -c <SOURCE> \; mv \"$$(dirname
> <SOURCE>)/$$(basename <OBJECT>)\" <OBJECT>")
>
> but it's clearly not what we want.
> - How do I tell Cmake that `ocamlc' generates 2 files?
> - How do I tell Cmake that `ocamlc' does not let us choose where to 
> put
>   the result?

According to http://caml.inria.fr/pub/docs/manual-ocaml/manual022.html, 
it does:
-o exec-file
     Specify the name of the output file produced by the compiler. The 
default output name is a.out under Unix and camlprog.exe under Windows. 
If the -a option is given, specify the name of the library produced. If 
the -pack option is given, specify the name of the packed object file 
produced. If the -output-obj option is given, specify the name of the 
output file produced. If the -c option is given, specify the name of the 
object file produced for the next source file that appears on the 
command line.

So using
set (CMAKE_OCaml_COMPILE_OBJECT "<CMAKE_OCaml_COMPILER> -c -o <OBJEJCT> 
<SOURCE>")

does not work?

HS



More information about the CMake mailing list