浏览代码

Merge topic 'touch-after-ranlib'

f83e4359f2 Apple: Preserve high resolution mtime for static libraries

Acked-by: Kitware Robot <[email protected]>
Merge-request: !3283
Brad King 6 年之前
父节点
当前提交
1628e4677a
共有 1 个文件被更改,包括 14 次插入0 次删除
  1. 14 0
      Source/cmNinjaNormalTargetGenerator.cxx

+ 14 - 0
Source/cmNinjaNormalTargetGenerator.cxx

@@ -535,6 +535,20 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd()
         std::string const& linkCmd = mf->GetRequiredDefinition(linkCmdVar);
         cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
       }
+#ifdef __APPLE__
+      // On macOS ranlib truncates the fractional part of the static archive
+      // file modification time.  If the archive and at least one contained
+      // object file were created within the same second this will make look
+      // the archive older than the object file. On subsequent ninja runs this
+      // leads to re-achiving and updating dependent targets.
+      // As a work-around we touch the archive after ranlib (see #19222).
+      {
+        std::string cmakeCommand =
+          this->GetLocalGenerator()->ConvertToOutputFormat(
+            cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
+        linkCmds.push_back(cmakeCommand + " -E touch $TARGET_FILE");
+      }
+#endif
       return linkCmds;
     }
     case cmStateEnums::SHARED_LIBRARY: