Browse Source

PCH: Do not mark PCH-header as generated

The PCH header file itself is written by CMake and is not generated by
part of the buildsystem.  Therefore the `GENERATED` property is not
appropriate to set because the file is always present before the build
starts.  We already do not mark the PCH source file as `GENERATED`
either.

This is a preparation for solving #18399, which will no longer allow to
unset the `GENERATED` property from a source-file once it was set.

Fixes: #21437
Signed-off-by: Deniz Bahadir <[email protected]>
Deniz Bahadir 5 years ago
parent
commit
7524501d89
1 changed files with 8 additions and 6 deletions
  1. 8 6
      Source/cmLocalGenerator.cxx

+ 8 - 6
Source/cmLocalGenerator.cxx

@@ -2607,14 +2607,16 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
           // Add pchHeader to source files, which will
           // be grouped as "Precompile Header File"
           auto pchHeader_sf = this->Makefile->GetOrCreateSource(
-            pchHeader, true, cmSourceFileLocationKind::Known);
+            pchHeader, false, cmSourceFileLocationKind::Known);
           std::string err;
           pchHeader_sf->ResolveFullPath(&err);
-
-          // The pch file is generated, but mark it as not generated
-          // so that a clean operation will not remove it from disk
-          pchHeader_sf->SetProperty("GENERATED", "0");
-
+          if (!err.empty()) {
+            std::ostringstream msg;
+            msg << "Unable to resolve full path of PCH-header '" << pchHeader
+                << "' assigned to target " << target->GetName()
+                << ", although its path is supposed to be known!";
+            this->IssueMessage(MessageType::FATAL_ERROR, msg.str());
+          }
           target->AddSource(pchHeader);
         }
       }