diff options
author | Gregor Jasny <gjasny@googlemail.com> | 2019-05-02 19:37:04 (GMT) |
---|---|---|
committer | Gregor Jasny <gjasny@googlemail.com> | 2019-05-05 14:14:28 (GMT) |
commit | f83e4359f20034f750729e5a4123de8f54265dd9 (patch) | |
tree | d191d4125ee77b598c035d9d24ff3e3c049a3ac0 /Source | |
parent | a6bf68141faca9af22624c8d0e1603653a73fce4 (diff) | |
download | CMake-f83e4359f20034f750729e5a4123de8f54265dd9.zip CMake-f83e4359f20034f750729e5a4123de8f54265dd9.tar.gz CMake-f83e4359f20034f750729e5a4123de8f54265dd9.tar.bz2 |
Apple: Preserve high resolution mtime for static libraries
On macOS ranlib truncates the fractional part of the static achive
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.
Closes: #19222
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index cbc0103..becc424 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -537,6 +537,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: |