In short: I know how to add dependencies to targets, in a CMake-generated build system. But I would like to add dependencies to the generated build-system itself.
Longer question: In the CMake-generated build process of cgal, we would like CMake to automatically re-run the configuration step, when certain files are modified. Unneeded details are hidden below:
As a matter of fact, we generate using CMake the build system for the CGAL libraries/examples/demos, but also at the same time the build system for our Doxygen-generated documentation. The
Doxyfile
is generated from multiple files.
When the CMake generator is "Makefile
", there is a special target in the Makefile
, that is named rebuild_cache
, but that target (at the Makefile level) is not a CMake-target. And anyway, I look for a solution that is cross-platform, that is: usable with all CMake generators. I have the impression that what I want is not yet doable with CMake. Can you please confirm, so that I can fill a documented feature-request?
Since CMake 3.0, you can add such a file to the directory property
CMAKE_CONFIGURE_DEPENDS
. This property holds a list of files; if any of them changes, CMake will trigger re-configuration.Here is a small example. Assuming your
Doxyfile
is generated fromDoxyfile.in.1
andDoxyfile.in.2
in the current source directory, the property could be used like this:If you're using CMake 2.x, the property
CMAKE_CONFIGURE_DEPENDS
is not available, but you can use the following trick:Pass the files through
configure_file()
, even if you justCOPYONLY
them someplace and don't use the resulting copies.configure_file()
introduces precisely the buildsystem dependency you're looking for.This works, but it adds the overhead of copying the file.
(Note: This trick was also the original content of this answer, since I was not aware of
CMAKE_CONFIGURE_DEPENDS
at time of answering).