[CMake] Dependency on library in a separate branch

Klaim - Joël Lamotte mjklaim at gmail.com
Sun Jun 26 14:50:34 EDT 2011


Hi,

I'm having trouble understanding how I should solve this case correctly in
CMake :

I want my project A to include+link my project B. I already made it with
project C but it don't work with A.
I think the problems comes from the directory structure :

/myrepo/tools/A (exe/Qt)
/myrepo/tools/B (shared library)
/myrepo/tools/B/C (exe)

Each of those folders have a CMakeFiles.txt file that add_subdirectory(
the_sub_directories ).

B uses include_directories() and C use target_link_libraries( C B )
So C does include and compile+link with code using B code.

A code runs fine alone, but now I need it to use B.
I've added

target_link_libraries( A ${QT_LIBRARIES} B )

to make sure it does uses B but the generated projects don't have the B
include  directory.

I know that I could use an advanced variable to get the include file, but I
don't find it consistent with the fact that
C executable does implicitely use the include file from B. A being
configured the same, it should work too... no?

I think it's related to the projects CMakeFiles.txt positions in the
directory hierarchy but I'm still often wrestling with CMake so I'm not
sure.

What would be the idiomatic CMake way of making A include+link B?

The real code is open source so I can show you exactly what is my current
setup if it helps (but I guess it's a noob question...)


Klaim - Joël Lamotte
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110626/6b343de7/attachment.htm>


More information about the CMake mailing list