• Craig Scott's avatar
    FetchContent: Don't update timestamps if files don't change · b0da6712
    Craig Scott authored
    The refactoring in 17e5516e (FetchContent: Invoke steps directly and
    avoid a separate sub-build, 2021-01-29) uses a different way of writing
    out the step scripts and updating time stamps when steps are executed.
    That inadvertently always wrote out the scripts for custom commands,
    even when the contents didn't change. This caused their timestamp to
    always be updated, resulting in those steps always being seen as
    out-of-date and needing to be re-executed.
    
    The way timestamps were checked to determine whether to re-execute
    a step also did not adequately account for file systems which only have
    second-resolution timestamps. The IS_NEWER_THAN if condition also
    returns true when timestamps are the same, so one needs to use the
    negative form to get a true "is newer than" test.
    
    ExternalProject is not susceptible to this problem because it uses
    file(GENERATE) to write out the script files and that only updates the file's
    timestamp if the contents change. It also mostly leaves timestamp
    checking to the build tool.
    b0da6712
ExternalProject.cmake 139 KB