Pārlūkot izejas kodu

Merge topic 'FixGraphvizAliasTargets'

f7dd74e4ef Graphviz: Fix bug that shows duplicated alias targets

Acked-by: Kitware Robot <[email protected]>
Merge-request: !5134
Brad King 5 gadi atpakaļ
vecāks
revīzija
31b057182e
19 mainītis faili ar 33 papildinājumiem un 3 dzēšanām
  1. 11 3
      Source/cmGraphVizWriter.cxx
  2. 2 0
      Tests/RunCMake/Graphviz/GraphvizTestProject.cmake
  3. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_custom_targets.dot
  4. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_default_options.dot
  5. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_dependers_files.dot
  6. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_external_libs.dot
  7. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_graphic_libs.dot
  8. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_interface_libs.dot
  9. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_module_libs.dot
  10. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_object_libs.dot
  11. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_per_target_files.dot
  12. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_shared_libs.dot
  13. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_static_libs.dot
  14. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_unknown_libs.dot
  15. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_header.dot
  16. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_name.dot
  17. 1 0
      Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_node_prefix.dot
  18. 1 0
      Tests/RunCMake/Graphviz/sub_directory_target/CMakeLists.txt
  19. 4 0
      Tests/RunCMake/Graphviz/sub_directory_target/test.c

+ 11 - 3
Source/cmGraphVizWriter.cxx

@@ -2,6 +2,7 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmGraphVizWriter.h"
 
+#include <algorithm>
 #include <cctype>
 #include <iostream>
 #include <memory>
@@ -552,16 +553,23 @@ bool cmGraphVizWriter::TargetTypeEnabled(
 std::string cmGraphVizWriter::ItemNameWithAliases(
   std::string const& itemName) const
 {
-  auto nameWithAliases = itemName;
-
+  std::vector<std::string> items;
   for (auto const& lg : this->GlobalGenerator->GetLocalGenerators()) {
     for (auto const& aliasTargets : lg->GetMakefile()->GetAliasTargets()) {
       if (aliasTargets.second == itemName) {
-        nameWithAliases += "\\n(" + aliasTargets.first + ")";
+        items.push_back(aliasTargets.first);
       }
     }
   }
 
+  std::sort(items.begin(), items.end());
+  items.erase(std::unique(items.begin(), items.end()), items.end());
+
+  auto nameWithAliases = itemName;
+  for(auto const& item : items) {
+    nameWithAliases += "\\n(" + item + ")";
+  }
+
   return nameWithAliases;
 }
 

+ 2 - 0
Tests/RunCMake/Graphviz/GraphvizTestProject.cmake

@@ -64,3 +64,5 @@ target_link_libraries(ConsoleApplication CryptoCurrencyMiningLibrary)
 
 add_custom_target(GenerateManPage COMMAND ${CMAKE_COMMAND} --version)
 add_dependencies(ConsoleApplication GenerateManPage)
+
+add_subdirectory(sub_directory_target)

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_custom_targets.dot

@@ -52,4 +52,5 @@ subgraph clusterLegend {
     "node12" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
     "node12" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags
     "node12" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary
+    "node13" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_default_options.dot

@@ -50,4 +50,5 @@ subgraph clusterLegend {
     "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
     "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags
     "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary
+    "node12" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_dependers_files.dot

@@ -50,4 +50,5 @@ subgraph clusterLegend {
     "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
     "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags
     "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary
+    "node12" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_external_libs.dot

@@ -46,4 +46,5 @@ subgraph clusterLegend {
     "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
     "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags
     "node9" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary
+    "node10" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_graphic_libs.dot

@@ -35,4 +35,5 @@ subgraph clusterLegend {
     "node5" [ label = "CryptoCurrencyMiningLibrary", shape = septagon ];
     "node1" -> "node5" [ style = dotted ] // ConsoleApplication -> CryptoCurrencyMiningLibrary
     "node6" [ label = "\"-lm\"", shape = septagon ];
+    "node7" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_interface_libs.dot

@@ -43,4 +43,5 @@ subgraph clusterLegend {
     "node8" -> "node1" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary
     "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
     "node9" -> "node1" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary
+    "node10" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_module_libs.dot

@@ -44,4 +44,5 @@ subgraph clusterLegend {
     "node9" [ label = "GraphicLibraryObjects", shape = hexagon ];
     "node7" -> "node9" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects
     "node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary
+    "node10" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_object_libs.dot

@@ -48,4 +48,5 @@ subgraph clusterLegend {
     "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
     "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags
     "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary
+    "node11" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_per_target_files.dot

@@ -50,4 +50,5 @@ subgraph clusterLegend {
     "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
     "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags
     "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary
+    "node12" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_shared_libs.dot

@@ -44,4 +44,5 @@ subgraph clusterLegend {
     "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
     "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags
     "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary
+    "node11" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_static_libs.dot

@@ -39,4 +39,5 @@ subgraph clusterLegend {
     "node8" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags
     "node9" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
     "node9" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags
+    "node10" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_no_unknown_libs.dot

@@ -48,4 +48,5 @@ subgraph clusterLegend {
     "node10" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
     "node10" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags
     "node10" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary
+    "node11" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_header.dot

@@ -50,4 +50,5 @@ subgraph clusterLegend {
     "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
     "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags
     "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary
+    "node12" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_graph_name.dot

@@ -50,4 +50,5 @@ subgraph clusterLegend {
     "node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
     "node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags
     "node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary
+    "node12" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/expected_outputs/dependency_graph_set_node_prefix.dot

@@ -50,4 +50,5 @@ subgraph clusterLegend {
     "point11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
     "point11" -> "point0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags
     "point11" -> "point2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary
+    "point12" [ label = "SubDirectoryTarget", shape = egg ];
 }

+ 1 - 0
Tests/RunCMake/Graphviz/sub_directory_target/CMakeLists.txt

@@ -0,0 +1 @@
+add_executable(SubDirectoryTarget test.c)

+ 4 - 0
Tests/RunCMake/Graphviz/sub_directory_target/test.c

@@ -0,0 +1,4 @@
+int main(int argc, char** argv)
+{
+  return 0;
+}