Reputation: 478
Let I have two projects A & B. A has a structure: src, tests, vendor(3d party libs). I want to put the project B with the same structure into A's src. A and B are dependent (A uses files from B; B uses files from A and from A's vendor). I want to be able to run tests for A and B separately. Is there a way to do it with CMake?
Upvotes: 3
Views: 189
Reputation: 2251
As mentioned by ComicSansMS in the comments, you want to split this into three projects: A, B and C. Thew new project C contains the stuff that is used by both A and B. Without knowing more specifics, it's hard to suggest the particular action you should take to split up the projects.
As far as CMake building the resulting three-part project, yes, it's fairly simple:
add_library(C c.cpp c2.cpp)
add_library(A a.cpp a1.cpp)
target_link_libraries(A C)
add_library(B b.cpp b2.cpp)
target_link_libraries(B C)
add_executable(test test.cpp)
target_link_libraries(test A B)
Upvotes: 1