[CMake] Adding a new language

Bill Hoffman bill.hoffman at kitware.com
Wed Nov 16 12:02:46 EST 2011


On 11/16/2011 3:52 AM, Michael Hertling wrote:
> On 11/16/2011 04:13 AM, Stefan Monnier wrote:
>>>> I'd still like to know how to explain to cmake that the command produces
>>>> 2 files, but at least I can get rid of my hack.
>>> That (assuming just a simple object file is produced by compilation)
>>> is one of several general limitations with CMake language support. For
>>> example, my understanding is this issue has been taken care of for
>>> Fortran 95 (where compilation produces both object and module files)
>>> with Fortran-95 specific changes to the C++ cmake code.  But I would far
>>> prefer to see a generic mechanism for this to not only to deal with
>>> the Fortran 95 module issue, but also the compilation-generated Ada
>>> library identification (*.ali) files, and also the similar issue for
>>> OCaml compiler generated files that you have described.
>>
>> Hmm...
>>
>>> Because of this and other struggles I had trying to implement Ada
>>> language support for CMake, I didn't even consider implementing CMake
>>> language support for OCaml for the PLplot OCaml bindings.  Instead we
>>> currently use (many!) custom commands and targets for that case, but
>>> I would be happy to change to your CMake OCaml language support
>>> if/when that works.
>>
>> I'm trying to use CMake for a new project here.  This project (a new
>> programming language, whose first implementation is in OCaml) is
>> currently in the very first stages (I have barely more than the lexer
>> written) and doesn't require anything sophisticated (there's only
>> 1 OCaml file for now ;-).  So my "language support" is very primitive
>> and rather than fight CMake, I'll probably just switch to something
>> else :-(
>
> In addition to custom commands/targets, as suggested meanwhile by Alan
> and Bill, you might also use the diverse RULE_LAUNCH properties. These
> allow to take arbitrary actions at build time, and you may grant them
> access to the placeholders used in rule variables, like<SOURCE>  and
> <OBJECT>, so it should be well possible to address the OCaml-related
> issues you have reported on. Search the ML's archive for examples of
> these properties' usage. However, they are currently restricted to
> Makefiles, but your CMAKE_OCaml_COMPILE_OBJECT rule is too, AFAIK.
>

I would not recommend using RULE_LAUNCH as it will only work with 
makefile based builds.  Normal custom commands will work everywhere.

-Bill



More information about the CMake mailing list