CMakeToolsTargetDependencies

This module generates UML component diagrams of a project’s targets and their dependencies. To use this module, just include it and call the function:

include(CMakeToolsTargetDependencies)
cmake_tools_make_target_dependency_graphs()

Commands

cmake_tools_make_target_dependency_graphs
cmake_tools_make_target_dependency_graphs(
  [NAMESPACE <namespace>]
  [TARGET_EXCLUDES regex [regex ...]]
  [DEPENDENCY_EXCLUDES regex [regex ...]]
  [VERBOSE]
  [SOURCE_DIRECTORY path]
  [OUTPUT_DIRECTORY path]
)
NAMESPACE

The namespace to use for grouping project targets into a UML frame. This should be the namespace used when you create alias targets or export your targets.

TARGET_EXCLUDES

A list of regular expressions of project targets to exclude from the graphs.

DEPENDENCY_EXCLUDES

A list of regular expressions of target dependencies to exclude from the graphs.

Warning

Remember CMake’s rules for regular expressions and strings. For example, to exclude the stdc++fs library, the expression in CMake must be "stdc\\+\\+fs". The expression needs to treat the “+” characters literally, and to escape them for that purpose, the string needs “\\” instead of “\”.

VERBOSE

Print extra status messages.

SOURCE_DIRECTORY

The root path to recursively search for build targets. The default is ${CMAKE_SOURCE_DIR}.

OUTPUT_DIRECTORY

The directory in which to write the PlantUML files and the diagrams. The default is ${CMAKE_BINARY_DIR}/dependency_graphs.

NO_PLANTUML

By default, this function runs PlantUML after it writes the PlantUML files. Use this option to skip the PlantUML step.

PLANTUML_ARGS

See PLANTUML_ARGS for run_plantuml().

Examples

Diagram everything except unit tests. All the unit test targets end with “_test”.

cmake_tools_make_target_dependency_graphs(TARGET_EXCLUDES ".+_test")

Create SVG images.

cmake_tools_make_target_dependency_graphs(PLANTUML_ARGS -tsvg)

Post-process the PlantUML files before rendering the images.

cmake_tools_make_target_dependency_graphs(NO_PLANTUML)
# Do your post processing.
run_plantuml("${CMAKE_BINARY_DIR}/dependency_graphs")