This is probably something that everyone already knows, but it took me a few hours to figure out...
I'm currently working on a project that uses CMake to build several libraries and executables all in the same project. Everything worked fine on OS-X, but when I tried to build on Linux I kept getting linker errors when compiling executable using functions and objects from interdependent libraries that I thought were being linked correctly via the target_link_libraries() command. Each library was compiled by CMake using the add_subdirectory() command.
I found out that the issue is that you need to specify dependencies between the libraries themselves, not just between executables and libraries. This was a bit of a surprise, but just adding the target_link_libraries() command to the CMakeLists.txt file for each library and listing the dependencies fixed the problem.
- ▼ 2013 (28)
- ► 2012 (46)