[CMake] Building from generated code

Christian Hoffmann christian_hoffmann at gmx.net
Tue Mar 4 14:25:00 EST 2008


Alexander Neundorf schrieb:
> On Tuesday 04 March 2008, Christian Hoffmann wrote:
>> -- snip --
>> However, I am currently stuck and cannot find an answer in the Wiki or the
>> list:
>>
>> I have two packages P_A and P_B, both built by CMake. To build P_B, the
>> following steps are required:
>>
>> 1. Build P_A - no problem. Provides me with executable E.
>> 2. In P_B: call E to generate sources
>>     P_B contains a set of sources S and a "configuration file" C,
>>     both provided by the user (Yes, our users are programmers!).
>>     When E is called, it reads C, and, depending on its content, generates
>>     new sources S'.
>> 3. Compile and link sources S and S' to a single library in P_B.
>>
>> All steps should be performed without minimal user interaction.
>>
>> Without parsing C by myself ( this is NO option!;) ), I cannot predict WHAT
>> sources S' will be generated by E. However, it is possible to determine
>> them from E's std-output, its log file, or using globs/regexps.
>>
>> Point 2, running E is not the problem. That was quite straight-forward
>> using ADD_CUSTOM_COMMAND() or ADD_CUSTOM_TARGET().
>>
>> But how to perform point 3? How to get the list of generated sources back
>> into CMake to build the lib?
> 
> Can you run E also at cmake time using execute_process(), i.e. not at build 
> time ?
Thanks for the quick answer! The reply-delay in this list is just awesome!

It possible to perform it at compile-time, but itwould take *very* long - much
longer than the actual compile and link process. But - why not? Im am just
trying this approach. it seems to work. Is there some way to send the output
of the command BOTH to an output variable AND to the screen? As the
computation takes quite long, it would be nice to see the progression report
of the called process.

Chris



More information about the CMake mailing list