Create GLOBAL_DEPENDS_NO_CYCLES property

This global property disallows cycles in the inter-target dependency
graph even among STATIC libraries.  See issue #9444.
This commit is contained in:
Brad King 2009-08-24 09:54:27 -04:00
parent a9be85da2e
commit fd62a7cac4
3 changed files with 29 additions and 2 deletions

View File

@ -103,6 +103,7 @@ cmComputeTargetDepends::cmComputeTargetDepends(cmGlobalGenerator* gg)
this->GlobalGenerator = gg;
cmake* cm = this->GlobalGenerator->GetCMakeInstance();
this->DebugMode = cm->GetPropertyAsBool("GLOBAL_DEPENDS_DEBUG_MODE");
this->NoCycles = cm->GetPropertyAsBool("GLOBAL_DEPENDS_NO_CYCLES");
}
//----------------------------------------------------------------------------
@ -344,6 +345,13 @@ cmComputeTargetDepends
continue;
}
// Immediately complain if no cycles are allowed at all.
if(this->NoCycles)
{
this->ComplainAboutBadComponent(ccg, c);
return false;
}
// Make sure the component is all STATIC_LIBRARY targets.
for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
{
@ -391,8 +399,16 @@ cmComputeTargetDepends
}
}
}
e << "At least one of these targets is not a STATIC_LIBRARY. "
<< "Cyclic dependencies are allowed only among static libraries.";
if(this->NoCycles)
{
e << "The GLOBAL_DEPENDS_NO_CYCLES global property is enabled, so "
<< "cyclic dependencies are not allowed even among static libraries.";
}
else
{
e << "At least one of these targets is not a STATIC_LIBRARY. "
<< "Cyclic dependencies are allowed only among static libraries.";
}
cmSystemTools::Error(e.str().c_str());
}

View File

@ -54,6 +54,7 @@ private:
cmGlobalGenerator* GlobalGenerator;
bool DebugMode;
bool NoCycles;
// Collect all targets.
std::vector<cmTarget*> Targets;

View File

@ -3414,6 +3414,16 @@ void cmake::DefineProperties(cmake *cm)
"at the beginning of native build system generation. "
"This property causes it to display details of its analysis to stderr.");
cm->DefineProperty(
"GLOBAL_DEPENDS_NO_CYCLES", cmProperty::GLOBAL,
"Disallow global target dependency graph cycles.",
"CMake automatically analyzes the global inter-target dependency graph "
"at the beginning of native build system generation. "
"It reports an error if the dependency graph contains a cycle that "
"does not consist of all STATIC library targets. "
"This property tells CMake to disallow all cycles completely, even "
"among static libraries.");
cm->DefineProperty(
"ALLOW_DUPLICATE_CUSTOM_TARGETS", cmProperty::GLOBAL,
"Allow duplicate custom targets to be created.",