[CMake] Generated CMakeLists.txt

Łukasz Tasz lukasz at tasz.eu
Wed Nov 9 10:27:20 EST 2011


Hi Michael, Hi all,

The workflow you described works fine, with one remark,
cmake phase will be triggered each time when input for generator is
changing, it means reconfiguration will happen even in cases it's not
needed.

The issue is that as I wrote:
>> The setup looks like: generator has some input, and depending on this
>> input files are generated.
In most cases changes in input are because some structure changes,
interface changes and so, number of generated files is not changing,
but there of course are cases that developer will add / remove some
file and those are the cases configuration must be reexecuted.


In case of small project you can rerun reconfiguration as much as you
want, but if configuration parses lot of cmake files, imports lot of
modules,
then it should not be triggered when not needed. That's why I ask for
kind of hook to cmake --check-build-system action which is
prerequisite to each make phase.

My very simple example is attached in generator.tar file.
- CMakeLists.txt
- model.xml - imput for model,
- genfiles.py - simple&dummy generaor


testcase is:
mkdir test
cp ....generator.tar test
tar xvf generator.tar
mkdir obj && cd obj
cmake ../cmake_issue
make -j
then add new structure in model.xml e.g test.abc
make -j
#linking error will occurs since configuration is
make -j
# cmake phase will fix configuration and linking will be fine.

Please remind that dummy model.xml in most cases is changed because of
internal structure changes.
I think you got my question about attaching to cmake
--check-build-system commnad genfiles.py --cmake-only ...

thanks in advance
Lukasz


2011/11/8 Michael Hertling <mhertling at online.de>:
> On 11/08/2011 03:30 PM, Łukasz Tasz wrote:
>> Hi All,
>>
>> I have one issue connected with generated code.
>>
>> What is recommended way to proceed with generators which provides
>> source which is dynamic?
>>
>> The setup looks like: generator has some input, and depending on this
>> input files are generated.
>> From cmake point of view I need only this list of source files to
>> create library.
>>
>> Generator is providing simple command to generate such a list.
>>
>>
>> During cmake phase, I'm calling generator to generate list.cmake with
>> list of source file,
>> then such a list is included, and configuration is generated. Source
>> file are marked as generated, and appropriate
>> ADD_CUSTOM_COMMAND(OUTPUT list) is registerd.
>>
>>
>> In lifecycle cmake -> make -> edit-input_files -> make -> edit ... make
>>
>> everything works smooth with one remark, If you will edit input files
>> in a way that new source file will be introduced, then regeneration is
>> not enough, I need to regenerate configuration,
>> with current approach it looks like:
>> edit-input-adding-new-file ->
>>      make-step1-generate: will regenerate the code + regenerate
>> cmakelist - since new file is there
>>      make-step2-compile-sources:
>>      make-step3-linking - will fail since new file is not added to
>> configuration,
>>
>> with next run of make, cmake --check-build-system will recognize
>> changes in cmakelist and configuration will be regenerated, and build
>> will be successfull (if code changes was smart enough:) )
>>
>> The question is if there are some hooks to cmake --check-build-system
>> that also additionaly my generate --cmake action will be called? (to
>> regenerate cmakelist which holds list of files)
>>
>> Or maybe my approach is wrong?
>>
>> thanks in advance
>> Lukasz
>
> If I understand correctly, you need to establish a dependency of the
> CMakeLists.txt file on the input for the code generator. You might
> use a CONFIGURE_FILE() command for this purpose, e.g.
>
> CONFIGURE_FILE(input.txt input.txt.bak COPYONLY)
>
> with input.txt being the code generator's input file. In this way, a
> change of input.txt outdates the CMakeLists.txt file, and the entire
> project is reconfigured and rebuilt the next time Make is called. If
> the machinery works by now when you reconfigure the project by hand,
> this should do the trick. If not, please come up with a minimal but
> complete example to show exactly what you are doing at the moment,
> what does not work and what you'd like to see instead.
>
> Regards,
>
> Michael
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



-- 
Lukasz Tasz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: generator.tar
Type: application/x-tar
Size: 10240 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111109/e527bc4a/attachment.tar>


More information about the CMake mailing list