问题
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: FALSEGRAPHVIZ_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