diff options
author | Brad King <brad.king@kitware.com> | 2020-02-27 13:48:41 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-02-27 13:48:49 (GMT) |
commit | 2b0c6c69c979be304fa340f3374a50a52fac2825 (patch) | |
tree | dad9b1b68dbb6f3e40d7502c7ea6300401f758fc /Source/cmGeneratorTarget.cxx | |
parent | e04fce4705c73b8a760afce1ab16d9e5cf70e599 (diff) | |
parent | 7e9b9fe918cde6d0769ade833b2086c1d89c45ff (diff) | |
download | CMake-2b0c6c69c979be304fa340f3374a50a52fac2825.zip CMake-2b0c6c69c979be304fa340f3374a50a52fac2825.tar.gz CMake-2b0c6c69c979be304fa340f3374a50a52fac2825.tar.bz2 |
Merge topic 'pch-file-time'
7e9b9fe918 PCH: Copy the timestamp from an absolute header file
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4400
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 5ef882c..ba2e314 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -25,6 +25,7 @@ #include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" #include "cmCustomCommandLines.h" +#include "cmFileTimes.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionContext.h" @@ -3427,6 +3428,7 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, auto pchPrologue = this->Makefile->GetDefinition("CMAKE_PCH_PROLOGUE"); auto pchEpilogue = this->Makefile->GetDefinition("CMAKE_PCH_EPILOGUE"); + std::string firstHeaderOnDisk; { cmGeneratedFileStream file( filename_tmp, false, @@ -3450,6 +3452,11 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, } else { file << "#include \"" << header_bt.Value << "\"\n"; } + + if (cmSystemTools::FileExists(header_bt.Value) && + firstHeaderOnDisk.empty()) { + firstHeaderOnDisk = header_bt.Value; + } } if (language == "CXX") { file << "#endif // __cplusplus\n"; @@ -3461,6 +3468,11 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, file << pchEpilogue << "\n"; } } + + if (!firstHeaderOnDisk.empty()) { + cmFileTimes::Copy(firstHeaderOnDisk, filename_tmp); + } + cmSystemTools::MoveFileIfDifferent(filename_tmp, filename); } } @@ -3519,6 +3531,7 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config, cmGeneratedFileStream file(filename_tmp); file << "/* generated by CMake */\n"; } + cmFileTimes::Copy(pchHeader, filename_tmp); cmSystemTools::MoveFileIfDifferent(filename_tmp, filename); } } |