[CMake] User-accessible hook on internal cmake_check_build_system target?

Brad King brad.king at kitware.com
Tue Sep 7 17:13:02 EDT 2010


On 09/07/2010 04:27 PM, Andreas Mohr wrote:
> Or well, ideally there would be a way to have a nice clean chain between
> starting CMake execution, realizing that vcproj2cmake needs to process an update,
> _then_ realizing that CMakeLists.txt changed and starting a configure
> run, and then continuing with make execution. IOW, I simply need to find
> a way to have my vcproj2cmake rebuild step cleanly registered _right
> before_ the cmake_check_build_system step.

Things like cmake_check_build_system are undocumented implementation
details.  The other generators work differently.  What is in common
is that if an input to the CMake process changes then CMake will run
again.

Two possible approaches come to mind:

(1) Run vcproj2cmake during the CMake process.  Start with a small
top-level CMakeLists.txt file that uses "if(f1 IS_NEWER_THAN f2)"
and execute_process() to create other CMake files to be include()d
or loaded with add_subdirectory.  You can use configure_file() to
copy the input vcproj file to dummy timestamp files.  That will
cause CMake to consider them inputs and will cause CMake to rerun
when the vcproj files change.

(2) Generate a two-level build system.  Start with a small top-level
CMakeLists.txt file that adds two custom targets.  The first target
runs vcproj2cmake in custom commands.  The second target drives
the generated CMake files as a subproject.  See the ExternalProject
module.

Option #1 is a bit hackish but option #2 is a clean solution.

-Brad


More information about the CMake mailing list