dependenciescmaketarget

In cmake, how can I make a target depend on another target?


For example, I have library target A, and library target B depends on A.

Instead of adding A's source files to B's source file list, I just want B to depend on target A.


Solution

  • If you need just the dependency (ordering), you can use add_dependencies(B A).

    However, your question suggests you actually want to link B against A. In that case, do target_link_libraries(B A).