Hei hei, we faced a build problem with transitive linking of separate projects where I can't find the right solution on my own. I hope someone can give me a hint. I prepared a test case with two libraries libfoo and libbar and an application baz. libfoo is on his own, libbar calls a function from libfoo and baz calls the function from libbar calling libfoo. So the dependencies are like this:
baz -> libbar -> libfoo baz doesn't need to know of libfoo because it just calls libbar, so I thought. Now the projects are separated and both libraries come with cmake package configuration files. For linking libfoo in libbar I do the following: find_package(FOO) target_link_libraries(BAR_SRC foo-shared) foo-shared is the target libfoo exports via cmake package configuration. This works and ldd shows libbar is correctly linked against libfoo. Now when compiling baz I more or less do the same: find_package(BAR) target_link_libraries(BAZ_SRC bar-shared) However building baz fails with the following error: % make [100%] Building C object src/CMakeFiles/baz.dir/baz.c.o Linking C executable baz /usr/bin/ld: cannot find -lfoo-shared collect2: ld returned 1 exit status make[2]: *** [src/baz] Fehler 1 make[1]: *** [src/CMakeFiles/baz.dir/all] Fehler 2 make: *** [all] Fehler 2 It seems like cmake tries to link against libfoo here but does not know anything about it. If I add find_package(FOO) to baz obviously the target is imported from libfoo cmake package files. The question is, if I know nothing about the requirements of libbar and want to avoid adding find_package statements for those requirements to baz, how would I do this? I put all the code on GitHub, so if someone maybe could have a look? https://github.com/LeSpocky/libfoo https://github.com/LeSpocky/libbar https://github.com/LeSpocky/baz Greets Alex -- »With the first link, the chain is forged. The first speech censured, the first thought forbidden, the first freedom denied, chains us all irrevocably.« (Jean-Luc Picard, quoting Judge Aaron Satie) *** GnuPG-FP: 02C8 A590 7FE5 CA5F 3601 D1D5 8FBA 7744 CC87 10D0 *** -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
