How can I get the list of dependencies of cmake target?

cmake

Solution

You can use CMake's "dependency graphs generator". Please read this link for details

cmake --graphviz=test.dot . ...

Problem

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

Original source

Related problems