[CMake] automatic cmake run when specific files change

James Bigler jamesbigler at gmail.com
Wed Oct 14 14:42:30 EDT 2009


On Wed, Oct 14, 2009 at 12:02 PM, Hendrik Sattler
<post at hendrik-sattler.de> wrote:
> Am Mittwoch 14 Oktober 2009 17:58:07 schrieb James Bigler:
>> Yes.  What you need to do is add the DocBook/XML files to the
>> dependency list of the add_custom_command that is used to generate the
>> output file.  When those files change, then the add_custom_command
>> will be run again.  See the documentation for add_custom_command.
>
> No. That's not what I meant and it also doesn't trigger a cmake rerun but only
> re-processes the xml file again.
>
> HS
>

OK, sorry I misunderstood.  What you need to do is include a file into
your CMakeLists.txt.  CMake is wired to reconfigure whenever any file
that is included into the build scripts changes.  During the build
process if that file changes then CMake will reconfigure the next time
you run make.  There are a few tricks to get this to work properly,
but an example (albeit complex) can be found in the FindCUDA.cmake
script (in CMake version 2.8).  I based this trick off some code I
found in the VTK build.

See the CUDA_INCLUDE_NVCC_DEPENDENCIES macro and the use of
CUDA_NVCC_DEPEND.  The file you use doesn't have to have any content,
since time stamps are used.

James


More information about the CMake mailing list