1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

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.
This commit is contained in:
Ben Boeckel
2025-09-03 13:00:52 -04:00
parent bbdc2fd908
commit 7aff0d37b5
3 changed files with 13 additions and 1 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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);