Feature request: automatically depends on CMake scripts & its dependencies inside the add_custom_command/add_custom_target
Short problem description
Need a way to add/pass script or list of CMake scripts for add_custom_command
and add_custom_target
, that should be tracked as a dependencies with its subdependencies (similar to the DEPENDS
argument).
Long problem description
I have an IDL files preprocessor for Windows & Linux. This preprocessor generates a list of C++ source files & headers from the every IDL file.
The IDL files can include each other, similar to the usual C++ headers.
I'm using the CMake script as a wrapper for converting compiler dependency output to the CMake-supported one with some patches applying, because of internal IDL preprocessor working algorithm. Also, I've patched some process environmet via ${CMAKE_COMMAND} -E env ...
call.
I'm using add_custom_command and add_custom_target for calling preprocessor on the build stage, as described here.
My CMake scripts uses include() calls for loading required dependencies.
The problem that I have: regenerate the files if the script or its dependencies were changed.
I don't like to manually track the dependencies, because it's unstable & can be broken, if something was added as an additional include.
Suggestion
Add the DEPENDS_CMAKE_SCRIPT
argument or the CMAKE_SCRIPT
subarguments to the DEPENDS
or another similar, that will accept CMake script or some CMake scripts, because the few COMMAND
calls may be done with the different scripts.
This list of DEPENDS_CMAKE_SCRIPT
and all of the its current includes (should be tracked by CMake internally as a prebuild call/postbuild call/additional COMMAND
call, that is automatically generated/...) should be processed similar to the usual DEPENDS
or merged with the DEPFILE
.
Usual DEPFILE
flag should also work with the new DEPENDS_CMAKE_SCRIPT
for passing usual IDL dependencies. Or we can provide an additional CMake function/macro/module/... for passing this data from the CMake script to the CMake dependency processor.
This feature will be nice for all generators, because it looks like generator-independent. For now, I'm using Ninja
on Linux & MSBuild
/Visual Studion 15 2017
for Windows.