Reputation: 2272
For instance, how can I know if my executable target E depends on my library target L?
Let's image E depends on L1 and L2, but I don't know if they depend on L.
target_link_libraries(E L1 L2)
I'd like to get the list from CMake itself before calling target_link_libraries
, so that I can do some tricks if I detect that E depends on two libraries which are incompatible. I played a bit with GetPrerequisites
, but this finds out dependencies on existing libraries which are on disk, not on target which are being built.
thanks
Upvotes: 43
Views: 49462
Reputation: 41
I have a top level project, which contains several external sub-projects. In the CMakeLists.txt file, most of the targets are customized and not listed in the graph by default. Looking into the document at https://cmake.org/cmake/help/latest/module/CMakeGraphVizOptions.html, and it says,
GRAPHVIZ_CUSTOM_TARGETS Set to TRUE to include custom targets in the generated graphs.
Mandatory: NO
Default: FALSE
To turn it on, write a file CMakeGraphVizOptions.cmake, and put the following line in it,
SET(GRAPHVIZ_CUSTOM_TARGETS TRUE)
Wish this helps.
Upvotes: 4
Reputation: 335
While graphviz output likely is more intuitive, sufficiently equivalent functionality can be enabled via a simple
set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1)
GLOBAL_DEPENDS_DEBUG_MODE cmake.org help
Upvotes: 13
Reputation: 10195
You can use CMake's "dependency graphs generator". Please read this link for details
cmake --graphviz=test.dot . ...
Upvotes: 45