Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make CMake reconfiguration depend on custom file?

I have a project under CMake with some files generated with python generator from XML files. I cannot specify all files generated by this generator in CMakeLists.txt so I use file globbing for this.

The problem is that when I update my XML files or generator sources (which are in the same repository) I would like to have my build system reconfigured so changed files are taken into account when rebuilding the code (via make for example).

Is it possible to make CMake treat some files like it treats CMakeLists.txt files and to make it regenerate build system when those file are changed?

like image 259
Netrix Avatar asked Jun 16 '14 14:06

Netrix


2 Answers

It doesn't require any kind of workarounds. The standard way is to use CMAKE_CONFIGURE_DEPENDS property:

set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS <filename>)
like image 90
roolebo Avatar answered Oct 21 '22 00:10

roolebo


Yes, you should be able to do that by (ab)using configure_file(). Configuring a file makes the source a dependency of the CMake run, so that any changes in it cause a reconfiguration. Simply like this:

configure_file(MyInputFile.xml DummyOutput.xml)
like image 37
Angew is no longer proud of SO Avatar answered Oct 21 '22 02:10

Angew is no longer proud of SO