[CMake] Build Dependencies problem

Eric Noulard eric.noulard at gmail.com
Tue Jul 14 15:05:42 EDT 2009


2009/7/14 Eric Tellefsen <eric.tellefsen at db.com>:
>
> Hi,
>
> I'm new to the list and relatively new to CMake.  I'm currently in the
> process of attempting to migrate an existing project to CMake (from plain
> Unix makefiles)
>
> The source files for each library are in a series of subdirectories as
> illustrated in the simple diagrams at the bottom of the mail.
>
> What I'm currently doing is creating CMakeLists.txt for each individual
> library.  I am also trying to represent the inter-library dependencies by
> adding add_subdirectory() and add_dependencies() to each library project
> (which almost all do).
>
> However, when I try to do this, it does not work as in the case where lib3
> is dependent on lib & headers within lib2.  When I run 'cmake .' to build
> the files, I get a message telling me that lib2 is not a subdirectory of
> lib3 and  the makefile is not created.

With CMake sibbling directories does not know each other.

> Would someone be able to point me in the right direction?

I do not cross such dependency case (with this particular directory layout)
but does it work if your specify dependencies/target_link
in the upper level CMakeLists.txt; i.e. the one in Libs.

Libs/CMakeLists.txt:

add_subdirectory(lib1)
add_subdirectory(lib2)
add_subdirectory(lib3)
target_link_libraries(lib3 lib2)

LIbs/lib1/CMakeLists.txt
    add_library(lib1 <sources>)

LIbs/lib2/CMakeLists.txt
    add_library(lib2 <sources>)

LIbs/lib3/CMakeLists.txt
    add_library(lib3 <sources>)


> This communication may contain confidential and/or privileged information.
> If you are not the intended recipient (or have received this communication
> in error) please notify the sender immediately and destroy this
> communication. Any unauthorized copying, disclosure or distribution of the
> material in this communication is strictly forbidden.

You should not post to a public and archived ML with this footer message :-(

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list