[CMake] Re-executing CMake from the Makefile.

Óscar Fuentes ofv at wanadoo.es
Thu Aug 14 11:25:52 EDT 2008


Bill Hoffman <bill.hoffman at kitware.com>
writes:

> Óscar Fuentes wrote:
>> Currently, when `make' is executed and a CMakeList.txt file is out of
>> date, `cmake' is automatically invoked and then `make' continues. Is it
>> possible to do this (on a reliable way) with an arbitrary file?
>>
>> I need to re-execute `cmake' whenever certain file changes. I wonder if
>> is possible to do this from `make' itself, so the user does not need to
>> remember that he must execute `cmake' first.
>>
> If the file you depend on is part of the input to cmake then cmake
> will do that automatically.  You could use the configure_file command
> to do this.  If you did something like this:
>
>  configure_file(/my/file/input dummyout)
>
> Then when ever /my/file/input changed cmake would re-run at make time.

Will this work if /my/file/input is the output of some intermediate
`make' execution?

I mean:

$ make  # invoke make, which may modify /my/file/input at some point

Will `make' invoke `cmake' on the fly and keep running with the new
makefiles regenerated by `cmake'?

If this is not possible, I would like to stop `make' when
/my/file/output changes, possibly showing some message to the user
instructing him to invoke `make' again.

All this is because /my/file/input actually is an script that is used
for determining which libraries the executables depends on. The current
build system builds the libraries, then the script and finally the
executables. As initially it is impossible for `cmake' to stablish
dependencies between libraries and executables, I wish the build to stop
or restart once the script is built and re-execute cmake so it can use
the script for inquiring what the dependencies are, re-generate the
makefiles and continue the build.

-- 
Oscar



More information about the CMake mailing list