[CMake] Dependency checker

Benjamin Schindler bschindler at inf.ethz.ch
Fri Sep 10 05:05:54 EDT 2010


Hi Justin

Thank you for the input. I think that's actually a doable solution, even
though performance would probably suck. But still, better than having
bugs in the system.

Thanks
Benjamin

On 09/09/2010 05:43 PM, KSpam wrote:
> Benjamin,
> 
>> Thank you for your quick answer. I had a quick glance - what I don't
>> quite understand is how can I integrate this into my custom cmake
>> script? I have a ADD_CUSTOM_COMMAND, and in the depends I need this list
>> of dependent files (the generated files, not the xsd's themselves).
>>
>> If you could shed some light on this, that would be very helpful
> 
> I have done something similar (with a different file type).  The low tech 
> solution is to use "file(READ ${fileName} fileContents)" to get the contents of 
> the file, and then search through the file contents for dependencies.  Another 
> option that might work would be "file(STRINGS" with the REGEX option in order 
> to reduce the resulting matches.
> 
> You can then use "string(REGEX MATCH" to search through the file contents for 
> the dependency match and then add the dependency to "DEPENDS" in your 
> add_custom_command.
> 
> This approach does not read the XML, but it should work as long as you can 
> create a reasonable regular expression to find the dependencies in the file.
> 
> A more complicated option would be to create a separate application that reads 
> the file and prints a list of dependencies.  You could then wrap that 
> executable in a custom command and parse the results into your dependency 
> list.
> 
> Respectfully,
> Justin



More information about the CMake mailing list