From fd62a7cac44ba95468767dd0f9b000da6d664b8d Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 24 Aug 2009 09:54:27 -0400 Subject: [PATCH] Create GLOBAL_DEPENDS_NO_CYCLES property This global property disallows cycles in the inter-target dependency graph even among STATIC libraries. See issue #9444. --- Source/cmComputeTargetDepends.cxx | 20 ++++++++++++++++++-- Source/cmComputeTargetDepends.h | 1 + Source/cmake.cxx | 10 ++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 7a6e81ffa..12d56968a 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -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()); } diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index e3e15e190..da29aa160 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -54,6 +54,7 @@ private: cmGlobalGenerator* GlobalGenerator; bool DebugMode; + bool NoCycles; // Collect all targets. std::vector Targets; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index ea36c0b07..dcc3d5035 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -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.",