diff options
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); } } |