Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake dependency graph for custom targets

Tags:

cmake

Is the --graphviz option of CMake supposed to get the dependency on custom targets?

Sample CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8)
add_executable(target0 test.cpp)
add_dependencies(target0 target1)
add_custom_target(target1 ALL
  COMMAND echo hello
)

The output file of "cmake --graphviz=test.dot ." would be:

digraph GG {
node [
  fontsize = "12"
];
    "node3" [ label="target0" shape="house"];
}

There isn't any trace of target1.

like image 937
Demetrius Avatar asked Jan 26 '16 12:01

Demetrius


2 Answers

The CMake manual clearly states:

--graphviz=[file]

Generate a graphviz input file that will contain all the library and executable dependencies in the project. See the documentation for CMakeGraphVizOptions.cmake for more details.

So, as far as I know, your custom target is neither - nor library, nor executable to be included into the resulting graph.

like image 104
Kamiccolo Avatar answered Nov 15 '22 20:11

Kamiccolo


As some might stumble over this question.

With CMake 3.17 custom targets can now be included
https://cmake.org/cmake/help/v3.17/module/CMakeGraphVizOptions.html (related issue 17960)

GRAPHVIZ_CUSTOM_TARGETS

    Set to TRUE to include custom targets in the generated graphs.
        Mandatory: NO
        Default: FALSE

GRAPHVIZ_IGNORE_TARGETS

    A list of regular expressions for names of targets to exclude from the generated graphs.
        Mandatory: NO
        Default: empty

like image 33
SubOptimal Avatar answered Nov 15 '22 21:11

SubOptimal