Mach-O rpath editing should check before performing its actions
I've stumbled upon a small issue when trying to build, install, re-build and re-install a project using CMake.
Configuration: OSX 10.11.5, XCode 7.3.1, CMake 3.5.2
If it happens that a dylib library is built and installed very fast one after another, the installed(copied) library modification timestamp is going to be equal to the modification timestamp of the library in the build folder. Which means that subsequently calling make install, will skip copying the library, because the modification timestamps are the same.
This is due to the fact that the comparison is done on 1-second granularity (relevant CMake code can be found in
cmFileTimeComparisonInternal::TimesDiffer and also the install time check in
cmake/Source/cmFileCommand.cxx, beginning of function
This leads to warnings when running make install again and the target library's rpaths are going to be removed at the install step (executed in
cmake_install.cmake file, search for "
delete_rpath" in the file).
I've attached a small reproducible project, and the output log of the build, install, and re-install. Extract the archive, and run the commands as below:
$ cd test $ cmake . $ make && make install && make install [ 25%] Building CXX object CMakeFiles/lib1.dir/test.cpp.o [ 50%] Linking CXX shared library liblib1.dylib [ 50%] Built target lib1 [ 75%] Building CXX object CMakeFiles/lib2.dir/test2.cpp.o [100%] Linking CXX shared library liblib2.dylib [100%] Built target lib2 [ 50%] Built target lib1 [100%] Built target lib2 Install the project... -- Install configuration: "" [ 50%] Built target lib1 [100%] Built target lib2 Install the project... -- Install configuration: "" error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: no LC_RPATH load command with path: /Users/user/Dev/test found in: /Users/user/Dev/test/liblib2.dylib (for architecture x86_64), required for specified option "-delete_rpath /Users/user/Dev/test"