[CMake] CMake, including internal libraries with subdirs

Yuri V. Timenkov ytimenkov at parallels.com
Fri Aug 1 11:51:37 EDT 2008


On Friday 01 August 2008 17:18:05 Julien Michel wrote:
> Dear CMake users,
>
> Let assume that I have two libraries, A and B. These two libraries are
> built with CMake. A is the library I am developping, and it relies on B.
> Of course I use FIND_PACKAGE(B) to tell CMake to look for B when building
> A.
>
> Now, I would like my users to have less libraries to compile before
> compiling A. So I decide to put B in the A source tree, in Utilities/B/
> for instance. And of course I use the cmake instruction SUBDIRS(B) to
> tell cmake to look in that directory.
>
> Is that sufficient to include B in A building process ? 
After this, using find_library is a bit excessive. You should just linkt to B 
without full path. In this case, CMake will set proper dependencies between 
libraries.

> Will all the B
> cmake options be reported in the cmake GUI when configuring A ? 
If B's CMakeLists.txt doesn't override them.

> Is there
>   anything else to add in A CMakeLists.txt to ensure proper installation
> and usability of A ?
May be it is worth removing some top-level file stuff from B's CMakeLists.txt 
like include(CPack), cmake_minimum_required, enable_testing and project().

>
> Currently we did something like that but we had to move some options
> from B CMakeLists.txt to A CmakeLists.txt, and to modify some of A and B
> files like IncludeDirectories.cmake also. I think we might have missed
> something, I would have expected CMake to be able to build and install
> recursively libraries.
I don't get the problem. Of course, if you merge two different builds, you 
should make some changes. But for CMake these changes are minimal.

>
> Thanks a lot for this great tool, and for any answer,
>
> Julien Michel



More information about the CMake mailing list