Adding dependency to generated files to a single source file?

In my use case, I have commands at configure time that generates files from input files, something like :

# Copy to where Input.cpp lives
file(COPY ....)

And then in my Input.cpp file, I #include ""

This raises a few questions:

  • is not automatically regenerated when changes
  • Input.cpp is not recompiled when changes


  • libInput which contains Input.cpp might not be created yet when this CMakeLists is being run. (Uncontrollable by me)
  • libInput is not created in the same level as current CMakeLists.txt

Why not just configure directly into wherever file(COPY) puts the file? That might solve the issue.

This looks like that this will change the source directory. You should generally try to avoid that. Maybe adapt the include path instead…