From: Gereon Kremer Date: Thu, 21 Oct 2021 12:10:20 +0000 (-0700) Subject: Add setup to generate graphs for cmake target dependencies (#7383) X-Git-Tag: cvc5-1.0.0~1022 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=35792ea9345e792aa9ae4748aced5213f4bbfa76;p=cvc5.git Add setup to generate graphs for cmake target dependencies (#7383) This adds the target `target-graphs` that generated graphs of cmake dependencies based on `cmake --graphviz`. It is a nice to tool to debug the cmake setup in some cases. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d173c845..2f6fa434e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -488,6 +488,8 @@ endif() add_subdirectory(test) +include(target-graphs) + #-----------------------------------------------------------------------------# # Package configuration # diff --git a/cmake/CMakeGraphVizOptions.cmake.in b/cmake/CMakeGraphVizOptions.cmake.in new file mode 100644 index 000000000..d3be598b3 --- /dev/null +++ b/cmake/CMakeGraphVizOptions.cmake.in @@ -0,0 +1,28 @@ +############################################################################### +# Top contributors (to current version): +# Gereon Kremer +# +# This file is part of the cvc5 project. +# +# Copyright (c) 2009-2021 by the authors listed in the file AUTHORS +# in the top-level source directory and their institutional affiliations. +# All rights reserved. See the file COPYING in the top-level source +# directory for licensing information. +# ############################################################################# +# Configuration file for the generation of cmake dependency graphs of cmake +# targets. +## + +set(CTX "@CMAKE_BINARY_DIR@/src/context/CMakeFiles/cvc5base.dir/") +set(BASE "@CMAKE_BINARY_DIR@/src/base/CMakeFiles/cvc5base.dir/") + +# ignore targets that do not actually help the understanding or are (usually) +# not interesting: tests and object files. +set(GRAPHVIZ_IGNORE_TARGETS + main-test + @APITESTS@ + ${CTX}context.cpp.o ${CTX}context_mm.cpp.o + ${BASE}check.cpp.o ${BASE}configuration.cpp.o ${BASE}exception.cpp.o + ${BASE}git_versioninfo.cpp.o ${BASE}listener.cpp.o ${BASE}output.cpp.o +) +set(GRAPHVIZ_GENERATE_DEPENDERS FALSE) \ No newline at end of file diff --git a/cmake/target-graphs.cmake b/cmake/target-graphs.cmake new file mode 100644 index 000000000..ad1023cd7 --- /dev/null +++ b/cmake/target-graphs.cmake @@ -0,0 +1,32 @@ +############################################################################### +# Top contributors (to current version): +# Gereon Kremer +# +# This file is part of the cvc5 project. +# +# Copyright (c) 2009-2021 by the authors listed in the file AUTHORS +# in the top-level source directory and their institutional affiliations. +# All rights reserved. See the file COPYING in the top-level source +# directory for licensing information. +# ############################################################################# +# Provides cmake target target-graphs with generates (png) dependency graphs +# to visualize the interdependencies of all cmake targets. +## + +get_target_property(APITESTS build-apitests MANUALLY_ADDED_DEPENDENCIES) +string(REPLACE ";" " " APITESTS "${APITESTS}") + +configure_file( + cmake/CMakeGraphVizOptions.cmake.in + ${CMAKE_BINARY_DIR}/CMakeGraphVizOptions.cmake + @ONLY +) + +add_custom_target(target-graphs + COMMAND + ${CMAKE_COMMAND} --graphviz=target-graphs/graph.dot ${CMAKE_SOURCE_DIR} + COMMAND + find target-graphs/ -iname "graph.dot*" -and \! -iname "*.png" + -exec dot -Tpng -O {} + + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +)