CMake dependency graph for custom targets

℡╲_俬逩灬. 提交于 2021-02-08 13:45:48

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/35013394/cmake-dependency-graph-for-custom-targets

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!