[CMake] [PATCH] Optionally skip link dependencies on shared library files

Brad King brad.king at kitware.com
Fri Oct 26 11:13:15 EDT 2012


On 10/26/2012 10:39 AM, Leif Walsh wrote:
> Sure thing. Can you let me know where to find an example test? I'll pattern match one over the weekend. 

Most CMake tests just verify that binaries build correctly.
The "Tests/BuildDepends" test is the only one that actually
tests rebuild behavior.  It has custom commands to build a
sub-project in its Project subdirectory multiple times while
making modifications in between.

You'll have to modify the inner test project to add a shared
library and an executable that links to it.  Set the new
property on the executable only.  After the first build,
verify that the executable's time is newer than the library
time.  Between builds, modify a the shared library source
(which of course will have to be in the build tree to avoid
modifying CMake's source tree).  After the second build
verify that the library is newer than the executable.

Checking the file times is probably most easily done as a
custom target on the inner project that depends on the
executable.  Its COMMAND should run a cmake script and
pass -Dexe=$<TARGET_FILE:exe> -Dlib=$<TARGET_FILE:lib> to
it.  The script can compare the ${lib} and ${exe} file
times with if(... FILE_IS_NEWER ...).

Thanks,
-Brad


More information about the CMake mailing list