cmGeneratorTarget: detect colliding target directories

Some projects might get unlucky and have targets which collide in the
sha3-512 hash (truncated to 4) in a directory which also collides in the
same way (easily done by sharing it). Note such problems as potentially
colliding and offer potential remedies.

Also add a test which generates the error.

Closes: #27465
This commit is contained in:
Ben Boeckel
2026-02-05 12:33:56 -05:00
parent 53ae242d55
commit bc7fac6ad3
12 changed files with 112 additions and 2 deletions
+11
View File
@@ -609,6 +609,7 @@ public:
bool BuildInterfaceIncludesAppended;
bool PerConfig;
bool IsSymbolic;
bool IsForTryCompile{ false };
cmTarget::Visibility TargetVisibility;
std::set<BT<std::pair<std::string, bool>>> Utilities;
std::set<std::string> CodegenDependencies;
@@ -2906,6 +2907,16 @@ bool cmTarget::CanCompileSources() const
return false;
}
void cmTarget::SetIsForTryCompile()
{
this->impl->IsForTryCompile = true;
}
bool cmTarget::IsForTryCompile() const
{
return this->impl->IsForTryCompile;
}
char const* cmTarget::GetSuffixVariableInternal(
cmStateEnums::ArtifactType artifact) const
{