[CMake] Dependency checker
KSpam
keesling_spam at cox.net
Thu Sep 9 11:43:19 EDT 2010
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