Seems to me that it would be great if cmake could produce Makefiles that work 
like the proposal below.

This approach can eliminate a lot of unnecessary downstream rebuilds. It is 
similar to how I imagine ccache <https://ccache.samba.org/> works, but unlike 
ccache which is only for compiling C/C++, the approach should work for any kind 
of target production.

It seems reasonable that cmake could do the work of generating rules to work 
like this, but it also might be possible that make and ninja could be made to 
work like this, optionally.

Proposal

For every target foo there will be a foo-stamp timestamp file.

If foo-stamp doesn’t exist or is older than any of foo's dependencies
    # Build foo without clobbering the old foo.
    make-foo > tmpdir/foo
    # See if what we made is different from the existing target.
    If tmpdir/foo ≠ foo, then
        mv -f tmpdir/foo foo
        # foo is now newer than it was and will cause downstream rebuilds.
    else
        rm -f tmpdir/foo
        # This is no longer needed, and foo is still its old self.
    # Prevent make-foo from having to run until a dependency is touched.
    touch foo-stamp

-- 

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

Reply via email to