[CMake] file(COPY) is copying even if file hasn't changed

Nicholas Devenish ndevenish at gmail.com
Thu Jul 20 12:52:27 EDT 2017


For what it's worth, I'm not seeing this on Sierra 10.12.5, CMake
3.9.0<release> on a simple test case of:

    cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
    file(COPY afile DESTINATION .)

I ran through Instruments to check the otherwise silent copy, it
copies the first time but thereafter only stat calls are ever made,
the file timestamp stays matching the source, and even the INSTALL
option also gives the "Up-to-date" message. It looks as though a chmod
might be run, but that doesn't seem to affect the output stamp.

So it must be something more complicated. Are you able to reduce the
behaviour to a simple test-case?

Completely wild guess: Are you running on something different from
HFS, like APFS? If my reading of the chmod isn't wrong, I suppose *in
theory* a different filesystem could treat a chmod attempt as a
modification....

Nick

On Thu, Jul 20, 2017 at 5:00 PM, Robert Dailey <rcdailey.lists at gmail.com> wrote:
> FYI I decided to file an issue for this here:
> https://gitlab.kitware.com/cmake/cmake/issues/17087
>
> On Wed, Jul 19, 2017 at 4:05 PM, Robert Dailey <rcdailey.lists at gmail.com> wrote:
>> Oh also file(INSTALL) does the same thing; the "Installing:" message
>> gets printed each time for the same file, and never says that it is
>> "up to date".
>>
>> On Wed, Jul 19, 2017 at 4:04 PM, Robert Dailey <rcdailey.lists at gmail.com> wrote:
>>> According to the documentation for file(COPY) [1]: "Copying preserves
>>> input file timestamps, and optimizes out a file if it exists at the
>>> destination with the same timestamp"
>>>
>>> However this is not the case. My host OS is Windows 10 and I'm using
>>> CMake 3.9.0-rc5. Each time my CMakeLists.txt is run, the file(COPY) is
>>> copying over the file even if it didn't change. The "date modified"
>>> timestamp for the destination file is updated. I do not want the copy
>>> to occur if the source file has not changed (this appears to be the
>>> intended behavior based on the documentation).
>>>
>>> Am I understanding this correctly or is this a bug?
>>>
>>> [1]: https://cmake.org/cmake/help/latest/command/file.html
> --
>
> 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