I have two libraries a and b. The last depends on functions defined in the other (a).
When I link a to b it has no effect.
MWE on wsl2 with g++9 and cmake 3.16:
[...]
add_library(a ${a_SRC})
target_link_libraries(a CONAN_PKG::<foo>)
add_library(b ${b_SRC})
target_link_libraries(b a CONAN_PKG::<bar>)
add_executable(main ${main_SRC})
target_link_libraries(main a b)
I get an undefined reference to error. When I check the size of libb.a it is the same no matter if I link to liba.a or not in target_link_libraries(b a CONAN_PKG::<bar>).
There is something I do not understand here!
I used an ugly workaround, where I include the source files of a in b:
[...]
add_library(a ${a_SRC})
target_link_libraries(a CONAN_PKG::<foo>)
add_library(b ${b_SRC} ${a_SRC})
target_link_libraries(b CONAN_PKG::<bar>)
add_executable(main ${main_SRC})
target_link_libraries(main a b)