[CMake] Forcing CMake to rerun

Jakob van Bethlehem jsvanbethlehem at gmail.com
Sun Dec 13 05:21:32 EST 2015


Hej,

My first guess would be to have a look at the add_custom_command() function. One of the possible invocations of that function creates a target of which the outputs are always considered out-of-date (well, if memory serves me correctly, it seems cmake.org is currently down so I can’t double check).

Anyways, if the ‘command’ you wish to run is actually a CMake script, have a look at the ‘cmake -P’ option. This allows you to run CMake scripts as a custom command.

Sincerely,
Jakob

> On 10 Dec 2015, at 22:26, Nicholas Clark <nicholas.clark at gmail.com> wrote:
> 
> Hi all,
> 
> I'm working on using CMake to create a build system that targets an incredibly hard-to-deal-with IDE/build system, used for doing some embedded programming (Xilinx's Vivado suite).
> 
> One of the pieces I need to get working is a conditional dependency between two files (a project-file generator script that gets archived in Git, and the actual project files that get generated).
> 
> The graph basically looks like this:
> 
> Path 1: .tcl file (in Git) -> .xpr file (used by IDE)
> Path 2: .xpr file (after a user changes something in the IDE) -> .tcl file (needs to be regenerated)
> 
> So on any clean build, the source-controlled TCL file autogenerates a bunch of required project files. On iterative builds at a developer's desk, he might change some IDE setting and then the TCL file needs to be regenerated (without triggering a rebuild of the project files as well). It's kind of a conditional and/or psuedo-circular dependency.
> 
> In pure GNU Make, I can express a conditional dependency with an 'if' statement that uses timestamp checks. It's also easy for me to express this dependency in CMakeLists.txt - I can check the file timestamps, and I can conditionally emit the relevant custom_target/custom_rule. 
> 
> That only works when CMakeLists.txt gets parsed, however. Is there any way for me to force a CMake-generated Makefile to _always_ rerun CMake before trying to build the 'all' target? If not, is there any other clever way that I could express this conditional dependency?
> 
> -Nick
> 
> 
> 
> -- 
> 
> Powered by www.kitware.com
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
> 
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake



More information about the CMake mailing list