[CMake] Programmatically-generated dependencies

Jakub Zakrzewski jzakrzewski at e2e.ch
Thu Dec 11 10:06:07 EST 2014


Hi,

CMake provides functions to execute commands and capture the output. You would use them as a part of configure step to get dependencies.
Then add_custom_command to actually generate the C file and use the output to generate the DEPENDS section.

--
Gruesse,
Jakub




-----Original Message-----
From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of ax487
Sent: Donnerstag, 11. Dezember 2014 15:49
To: cmake at cmake.org
Subject: Re: [CMake] Programmatically-generated dependencies

*bump*

On 09.12.2014 10:38, ax487 wrote:
> Hello all,
> 
> I am mainly asking having glib-compile-resources in mind. This little 
> program translates files into C source code to be used with the 
> gresource system. It works in the following way: You have a file.xml 
> describing the resources:
> 
> <?xml version="1.0" encoding="UTF-8"?> <gresources> <gresource 
> prefix="/some/prefix">
> 
> <file>some_file.txt</file>
> </gresource>
> </gresources>
> 
> To generate the source you use `glib-compile-resources 
> --generate-source --target=output.c file.xml`. Clearly the generated 
> output.c depends on file.xml. But it also depends on some_file.txt. It 
> is possible to get a list of dependencies using 
> `glib-compile-resources --generate-dependencies file.xml` which will 
> output
> 
> some_file.txt
> 
> The situation is similar to the case of auto-generated header 
> dependencies for C/C++ source code using the "-MM" option of gcc.
> I saw the following version on github:
> 
> https://github.com/bgK/vba-ttb/blob/master/cmake/GResource.cmake
> 
> which does not correctly detect dependencies, but nothing apart from 
> that. But since the process works with C/C++ source code I figured 
> there is no reason why it shouldn't also work in this case. Could 
> anyone give me some pointers on how to get this to work?
> 
> ax487
> 
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list