In cmake, how to specify dependencies of subdirectories in a scalable way?
问题 Suppose the source tree is in this structure: / |- lib1 | |- src.cpp | |- lib1.h | |- CMakeLists.txt | |- lib2 | |- src.cpp | |- lib2.h | |- CMakeLists.txt | |- lib3 | |- src.cpp | |- lib3.h | |- CMakeLists.txt | |- app | |- src.cpp | |- CMakeLists.txt | |- CMakeLists.txt Suppose: lib1 has function f(); lib2 has function g() which uses f(); app/src.cpp uses function g(); Nobody uses lib3. I want: in app/CMakeLists.txt, it only link to lib2. The logic here is, app/src.cpp only uses g(), so