[CMake] Build Library from Thrift generated files

Eric Noulard eric.noulard at gmail.com
Thu Sep 5 10:03:51 EDT 2013


2013/9/5 Pascal Bach <pasci.bach at gmail.com>:
>>>
>>
>> >> Unknown source file name is just painful.
>> >>
>> >> Can't the thrift generator tell you the name of the files he will generate?
>> >> Something like:
>> >> thrift --generated-file-list Service.thrift
>> >>
>>
>> How wouldn't the output depend on the content of the input :-]... just kidding.
>>
>> The "not predictable output"  is is a biased point of view :-)
>>
>> Even if thrift needs to generate several classes, functions whatever
>> nothing prevent the tool of putting that in 2 (possibly) big files, like:
>>
>> Services.thrift
>> -->
>> Services.hh
>> Services.cpp
>>
>> I do use a (home made) source generator which does just that.
>> Generating 1 file per class is a convention not an obligation.
>> At least in C, C++ and Python.
>
> I discussed you proposal with one of the thrift maintainers. He will
> discuss the idea of a generated-list option and maybe it will be
> added.

I do not use thrift but they seem open minded, good to know.

> In the meantime I will go with the files pre generated and I treat
> them as all the other source files. This means the developer has to
> trigger the regeneration process manually. For the moment this is
> acceptable for me.

I suggest you keep an  add_custom_target for that purpose.
I used that very often for gengetopt generated files.

I put the generated files in the VCS and I have a custom target
which may be invoked like:

make GenCmdlineSrc

so that the developer do not have to remember how to launch gengetopt
(or any other kind of source file generator).

Since add_custom_target has no specified output and no other target
depends on it is NEVER launched unless you ask to build it explicitely.


> Thanks for your help.

You are welcome.

-- 
Erk
L'élection n'est pas la démocratie -- http://www.le-message.org


More information about the CMake mailing list