diff options
author | Brad King <brad.king@kitware.com> | 2018-10-29 13:56:18 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-10-29 13:56:25 (GMT) |
commit | bcd61da3503be85d247657827e5fb08db3ecf07d (patch) | |
tree | 2973f2163d0bf63a4e038cf62bbfbe547fb9bd44 | |
parent | f0a9094d809a80ef754642b13d7b66a90b61cee7 (diff) | |
parent | 50c4dec07267c8678302b0c4cf0c89a5a02b1d6b (diff) | |
download | CMake-bcd61da3503be85d247657827e5fb08db3ecf07d.zip CMake-bcd61da3503be85d247657827e5fb08db3ecf07d.tar.gz CMake-bcd61da3503be85d247657827e5fb08db3ecf07d.tar.bz2 |
Merge topic 'graphviz-fix-alias'
50c4dec072 graphviz: dereference ALIAS targets
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2521
-rw-r--r-- | Source/cmGraphVizWriter.cxx | 33 | ||||
-rw-r--r-- | Source/cmGraphVizWriter.h | 4 | ||||
-rw-r--r-- | Source/cmake.cxx | 2 |
3 files changed, 31 insertions, 8 deletions
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index fcdf03f..754fa7d 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -68,7 +68,7 @@ const char* getShapeForTarget(const cmGeneratorTarget* target) } std::map<std::string, LinkLibraryScopeType> getScopedLinkLibrariesFromTarget( - cmTarget* Target) + cmTarget* Target, const cmGlobalGenerator* globalGenerator) { char sep = ';'; std::map<std::string, LinkLibraryScopeType> tokens; @@ -95,6 +95,13 @@ std::map<std::string, LinkLibraryScopeType> getScopedLinkLibrariesFromTarget( } std::string element = interfaceLinkLibraries.substr(start, end - start); + if (globalGenerator->IsAlias(element)) { + const auto tgt = globalGenerator->FindTarget(element); + if (tgt) { + element = tgt->GetName(); + } + } + if (std::string::npos == element.find("$<LINK_ONLY:", 0)) { // we assume first, that this library is an interface library. // if we find it again in the linklibraries property, we promote it to an @@ -116,6 +123,12 @@ std::map<std::string, LinkLibraryScopeType> getScopedLinkLibrariesFromTarget( } std::string element = linkLibraries.substr(start, end - start); + if (globalGenerator->IsAlias(element)) { + const auto tgt = globalGenerator->FindTarget(element); + if (tgt) { + element = tgt->GetName(); + } + } if (tokens.find(element) == tokens.end()) { // this library is not found in interfaceLinkLibraries but in @@ -137,13 +150,13 @@ std::map<std::string, LinkLibraryScopeType> getScopedLinkLibrariesFromTarget( } } -cmGraphVizWriter::cmGraphVizWriter( - const std::vector<cmLocalGenerator*>& localGenerators) +cmGraphVizWriter::cmGraphVizWriter(const cmGlobalGenerator* globalGenerator) : GraphType("digraph") , GraphName("GG") , GraphHeader("node [\n fontsize = \"12\"\n];") , GraphNodePrefix("node") - , LocalGenerators(localGenerators) + , GlobalGenerator(globalGenerator) + , LocalGenerators(globalGenerator->GetLocalGenerators()) , GenerateForExecutables(true) , GenerateForStaticLibs(true) , GenerateForSharedLibs(true) @@ -374,7 +387,8 @@ void cmGraphVizWriter::WriteConnections( std::string myNodeName = this->TargetNamesNodes.find(targetName)->second; std::map<std::string, LinkLibraryScopeType> ll = - getScopedLinkLibrariesFromTarget(targetPtrIt->second->Target); + getScopedLinkLibrariesFromTarget(targetPtrIt->second->Target, + GlobalGenerator); for (auto const& llit : ll) { const char* libName = llit.first.c_str(); @@ -439,7 +453,7 @@ void cmGraphVizWriter::WriteDependerConnections( // Now we have a target, check whether it links against targetName. // If so, draw a connection, and then continue with dependers on that one. std::map<std::string, LinkLibraryScopeType> ll = - getScopedLinkLibrariesFromTarget(tptr.second->Target); + getScopedLinkLibrariesFromTarget(tptr.second->Target, GlobalGenerator); for (auto const& llit : ll) { if (llit.first == targetName) { @@ -540,6 +554,13 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) continue; } + if (GlobalGenerator->IsAlias(libName)) { + const auto tgt = GlobalGenerator->FindTarget(libName); + if (tgt) { + libName = tgt->GetName().c_str(); + } + } + std::map<std::string, const cmGeneratorTarget*>::const_iterator tarIt = this->TargetPtrs.find(libName); if (tarIt == this->TargetPtrs.end()) { diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index ac20da9..ed242f0 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -16,13 +16,14 @@ class cmGeneratedFileStream; class cmGeneratorTarget; class cmLocalGenerator; +class cmGlobalGenerator; /** This class implements writing files for graphviz (dot) for graphs * representing the dependencies between the targets in the project. */ class cmGraphVizWriter { public: - cmGraphVizWriter(const std::vector<cmLocalGenerator*>& localGenerators); + cmGraphVizWriter(const cmGlobalGenerator* globalGenerator); void ReadSettings(const char* settingsFileName, const char* fallbackSettingsFileName); @@ -69,6 +70,7 @@ protected: std::vector<cmsys::RegularExpression> TargetsToIgnoreRegex; + const cmGlobalGenerator* GlobalGenerator; const std::vector<cmLocalGenerator*>& LocalGenerators; std::map<std::string, const cmGeneratorTarget*> TargetPtrs; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1aff5eb..79af3e7 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2143,7 +2143,7 @@ void cmake::MarkCliAsUsed(const std::string& variable) void cmake::GenerateGraphViz(const char* fileName) const { #ifdef CMAKE_BUILD_WITH_CMAKE - cmGraphVizWriter gvWriter(this->GetGlobalGenerator()->GetLocalGenerators()); + cmGraphVizWriter gvWriter(this->GetGlobalGenerator()); std::string settingsFile = this->GetHomeOutputDirectory(); settingsFile += "/CMakeGraphVizOptions.cmake"; |