From 7aff0d37b55084e4e0cb10bde7773a62459179ae Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 3 Sep 2025 13:00:52 -0400 Subject: [PATCH] cmSourceFile: add accessors for PCH source files `cmLocalGenerator::GetObjectFileNameWithoutTarget` used a heuristic to detect PCH sources. Use the new special source types to detect them reliably instead. --- Source/cmLocalGenerator.cxx | 2 +- Source/cmSourceFile.cxx | 10 ++++++++++ Source/cmSourceFile.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3e4a13ed56..c504b39c2e 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -4258,7 +4258,7 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( objectName = cmSystemTools::GetFilenameName(source.GetFullPath()); } } - bool const isPchObject = objectName.find("cmake_pch") != std::string::npos; + bool const isPchObject = source.IsPchHeader() || source.IsPchSource(); // Short object path policy selected, use as little info as necessary to // select an object name diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 67ba171487..430f9c5fe5 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -34,6 +34,16 @@ void cmSourceFile::SetSpecialSourceType(cmSourceFile::SpecialSourceType type) this->SpecialSource = type; } +bool cmSourceFile::IsPchHeader() const +{ + return this->SpecialSource == SpecialSourceType::PchHeader; +} + +bool cmSourceFile::IsPchSource() const +{ + return this->SpecialSource == SpecialSourceType::PchSource; +} + std::string const& cmSourceFile::GetExtension() const { return this->Extension; diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 633a4866e7..fcd5fd6d19 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -67,6 +67,8 @@ public: QtAutogenSource, }; void SetSpecialSourceType(SpecialSourceType type); + bool IsPchHeader() const; + bool IsPchSource() const; //! Set/Get a property of this source file void SetProperty(std::string const& prop, cmValue value);