<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 08-Oct-15 21:03, Mantis Bug Tracker
      wrote:<br>
    </div>
    <blockquote cite="mid:6934fe0768634bce98b2955754827845@cmake.org"
      type="cite">
      <pre wrap="">
The following issue has been ASSIGNED. 
====================================================================== 
<a class="moz-txt-link-freetext" href="https://cmake.org/Bug/view.php?id=15769">https://cmake.org/Bug/view.php?id=15769</a> 
====================================================================== 
Reported By:                Ruslan Baratov
Assigned To:                Brad King
====================================================================== 
Project:                    CMake
Issue ID:                   15769
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     resolved
Target Version:             CMake 3.5
Resolution:                 fixed
Fixed in Version:           CMake 3.5
====================================================================== 
Date Submitted:             2015-10-05 10:37 EDT
Last Modified:              2015-10-08 14:03 EDT
====================================================================== 
Summary:                    OS X: Filesystem timestamp checks use only 1s
resolution
Description: 
`cmake --build` command doesn't trigger reconfiguration of the project on OS X
when CMakeLists.txt changed.

Example:

add_executable(foo foo.cpp) # file foo.cpp exists

cmake -H. -B_builds
cmake --build _builds
# OK

change:
add_executable(foo foo.cpp boo.cpp) # file boo.cpp not exists
cmake --build _builds
# expected error, but no error reported

Ready-to-run example can be found:
<a class="moz-txt-link-freetext" href="https://github.com/forexample/cmake-osx-no-reconfigure-bug">https://github.com/forexample/cmake-osx-no-reconfigure-bug</a>

Log from OS X machine:
* <a class="moz-txt-link-freetext" href="https://travis-ci.org/forexample/cmake-osx-no-reconfigure-bug/builds/83701171">https://travis-ci.org/forexample/cmake-osx-no-reconfigure-bug/builds/83701171</a>

Log for similar test on Linux machine:
* <a class="moz-txt-link-freetext" href="https://travis-ci.org/forexample/cmake-osx-no-reconfigure-bug/builds/83702953">https://travis-ci.org/forexample/cmake-osx-no-reconfigure-bug/builds/83702953</a>

CMake on Linux machine run reconfigure command and report an error:
  cmake -H. -B_builds --check-build-system CMakeFiles/Makefile.cmake 0
  -- Configuring done
  CMake Error at CMakeLists.txt:4 (add_executable):
    Cannot find source file:
      boo.cpp

same error expected on OS X machine
====================================================================== 

---------------------------------------------------------------------- 
 (0039511) Brad King (manager) - 2015-10-05 14:45
 <a class="moz-txt-link-freetext" href="https://cmake.org/Bug/view.php?id=15769#c39511">https://cmake.org/Bug/view.php?id=15769#c39511</a> 
---------------------------------------------------------------------- 
I can reproduce this when running 'make' directly without 'cmake --build':

 -cmake --build _builds
 +(cd _builds; make)

The problem is that the filesystem and/or make tool seem to have 1s timestamp
resolution.  If I change the script to do "sleep 1" before the last "cp
CMakeBad.txt CMakeLists.txt" then it works. 

---------------------------------------------------------------------- 
 (0039512) Brad King (manager) - 2015-10-05 14:52
 <a class="moz-txt-link-freetext" href="https://cmake.org/Bug/view.php?id=15769#c39512">https://cmake.org/Bug/view.php?id=15769#c39512</a> 
---------------------------------------------------------------------- 
The issue may be where CMake decides whether it needs to re-run:

 <a class="moz-txt-link-freetext" href="https://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmFileTimeComparison.cxx;hb=v3.3.2#l147">https://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmFileTimeComparison.cxx;hb=v3.3.2#l147</a>

The STAT_HAS_ST_MTIM code path may not be taken on this platform. 

---------------------------------------------------------------------- 
 (0039513) Brad King (manager) - 2015-10-05 14:54
 <a class="moz-txt-link-freetext" href="https://cmake.org/Bug/view.php?id=15769#c39513">https://cmake.org/Bug/view.php?id=15769#c39513</a> 
---------------------------------------------------------------------- 
Indeed, on OS X "struct stat" has:

 struct timespec st_mtimespec;

instead of

 struct timespec st_mtim; 

---------------------------------------------------------------------- 
 (0039518) Brad King (manager) - 2015-10-06 13:27
 <a class="moz-txt-link-freetext" href="https://cmake.org/Bug/view.php?id=15769#c39518">https://cmake.org/Bug/view.php?id=15769#c39518</a> 
---------------------------------------------------------------------- 
For reference, I've started a fix for this on the KWSys side here:

 <a class="moz-txt-link-freetext" href="http://review.source.kitware.com/20258/">http://review.source.kitware.com/20258/</a> 

---------------------------------------------------------------------- 
 (0039519) Brad King (manager) - 2015-10-06 14:04
 <a class="moz-txt-link-freetext" href="https://cmake.org/Bug/view.php?id=15769#c39519">https://cmake.org/Bug/view.php?id=15769#c39519</a> 
---------------------------------------------------------------------- 
It looks like the underlying HFS filesystem only has 1s resolution:

 <a class="moz-txt-link-freetext" href="https://en.wikipedia.org/wiki/HFS_Plus">https://en.wikipedia.org/wiki/HFS_Plus</a>

This may not be possible to fix without a "sleep 1" in the test script. 

---------------------------------------------------------------------- 
 (0039548) Brad King (manager) - 2015-10-08 14:01
 <a class="moz-txt-link-freetext" href="https://cmake.org/Bug/view.php?id=15769#c39548">https://cmake.org/Bug/view.php?id=15769#c39548</a> 
---------------------------------------------------------------------- 
After the KWSys side learned to use st_mtimespec I've updated CMake too:

 cmFileTimeComparison: Port to OS X nanosecond times
 <a class="moz-txt-link-freetext" href="https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8d27b407">https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8d27b407</a> 

---------------------------------------------------------------------- 
 (0039549) Brad King (manager) - 2015-10-08 14:03
 <a class="moz-txt-link-freetext" href="https://cmake.org/Bug/view.php?id=15769#c39549">https://cmake.org/Bug/view.php?id=15769#c39549</a> 
---------------------------------------------------------------------- 
Marking as resolved because the proper API for ns resolution is now used. 
However in practice the underlying filesystem may limit the resolution anyway.
 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-10-05 10:37 Ruslan Baratov New Issue                                    
2015-10-05 14:45 Brad King      Note Added: 0039511                          
2015-10-05 14:52 Brad King      Note Added: 0039512                          
2015-10-05 14:53 Brad King      Summary                  Change of
CMakeLists.txt doesn't trigger reconfigure => OS X: Filesystem timestamp checks
use only 1s resolution
2015-10-05 14:54 Brad King      Note Added: 0039513                          
2015-10-06 13:27 Brad King      Note Added: 0039518                          
2015-10-06 14:04 Brad King      Note Added: 0039519                          
2015-10-08 14:01 Brad King      Note Added: 0039548                          
2015-10-08 14:03 Brad King      Note Added: 0039549                          
2015-10-08 14:03 Brad King      Assigned To               => Brad King       
2015-10-08 14:03 Brad King      Status                   new => resolved     
2015-10-08 14:03 Brad King      Resolution               open => fixed       
2015-10-08 14:03 Brad King      Fixed in Version          => CMake 3.5       
2015-10-08 14:03 Brad King      Target Version            => CMake 3.5       
======================================================================

</pre>
    </blockquote>
    Hi,<br>
    <br>
    While viewing changes you've made I found an "interesting" behaviour
    of CMake's install procedure. Since it's not about this bug exactly
    I'm moving it to 'cmake-developers' list. Function
    cmFileTimeComparisonInternal::TimesDiffer use only limited number of
    digits of timestamp and used in install step. This may lead to the
    similar bugs.<br>
    <br>
    Here is the result of my white-box testing skills:<br>
    script:
<a class="moz-txt-link-freetext" href="https://github.com/forexample/cmake-header-install-bug/blob/master/run-test.sh">https://github.com/forexample/cmake-header-install-bug/blob/master/run-test.sh</a><br>
    log:
<a class="moz-txt-link-freetext" href="https://travis-ci.org/forexample/cmake-header-install-bug/builds/84592318">https://travis-ci.org/forexample/cmake-header-install-bug/builds/84592318</a><br>
    <blockquote><span id="1-193"></span><span id="1-194"></span>--
      Up-to-date:
/Users/travis/build/forexample/cmake-header-install-bug/_install/include/foo.hpp<br>
      1c1<br>
      < Bad<br>
      ---<br>
      > Good<br>
      Error: file not installed!<br>
    </blockquote>
    So installed foo.hpp file is not updated. This may be quite
    surprising in automated tools like git-bisect. Also I've found
    `CMAKE_INSTALL_ALWAYS` environment variable but it's not documented.<br>
    <br>
    Thanks, Ruslo<br>
  </body>
</html>