I have some troubles in cmake target_link_libraries function. In my case,there are three projects like this,which means A depends on B,B depends on C
A(exec) --> B(static library) --> C(static library alias C::C)
I write a CMakeLists.txt for B like this:
find_package(C REUQIRED)
add_library(B ...)
target_link_libraries(B PRIVATE C::C)
And it works well ,complie successfully. A's cmake file like this:
find_package(B REQUIRED)
add_exectuable(A ...)
target_link_libraries(A B)
It reports error when linking A,cmake set a linker flags "-lC::C",and then ld said C::C not exist. How it happend?I think C::C is a target and A should know it,but cmake think it is a library name.And I think A should not know B depends on C,it's a private library.
I don't want to write find_packge(C) in A's cmake,because C is a static library,I think B should handle all dependcies of C,that's right?
So anyone knows how to fix it ?