[Cmake] Linking libraries to make a library...

Nick Ton nton at photon . com
Thu, 24 Jul 2003 12:27:53 -0400


Sorry, answered my own questions. It turns I explicitly specified the
library name (liblib_1.a)
in the TARGET_LINK_LIBRARIES command. So cmake throw an error. You have to
just
reference the name given in the ADD_LIBRARY command of each lib's.

Brad Thanks Again.

Nick

-----Original Message-----
From: Nick Ton [mailto:nton at photon . com]
Sent: Thursday, July 24, 2003 12:20 PM
To: 'cmake at www . cmake . org'
Subject: Re: [Cmake] Linking libraries to make a library...




-----Original Message-----
From: Nick Ton 
Sent: Thursday, July 24, 2003 12:16 PM
To: 'Brad King'
Subject: RE: [Cmake] Linking libraries to make a library...



Hi Brad,

Thanks for the quick response. I tried your suggestion, and I got
the following CMake Error: Attempt to add link libraries to non-existant
target: libmyproject.a for lib lib_1.a

So I have created my individual CMakeLists.txt for each lib's, where lib_2
has
ADD_LIBRARY(lib_2 lib2.cxx)
TARGET_LINK_LIBRARIES(lib_2 lib_1)

and so on. But think cmake gets confused as to where lib_1 really exist.
Since,
I have a "master" CMakeLists.txt file that referenced lib_1, lib_2, and
lib_3\
as SUBDIR items, I am not sure how to specify where to put lib_1, lib_2,
lib_3.
Basically, I want to control the build of lib_1, lib_2, and lib_3 from a
master
CMakeLists.txt file at the root directory.

Nick 

-----Original Message-----
From: Brad King [mailto:brad . king at kitware . com]
Sent: Thursday, July 24, 2003 11:44 AM
To: Nick Ton
Cc: cmake at www . cmake . org
Subject: Re: [Cmake] Linking libraries to make a library...


Nick,

> What command should I use to make a static library from several other
> individual libraries.

This is a windows thing, and cannot be done by most unix linkers.
However, there is probably another way to achieve your goal. You can
organize your CMakeLists.txt files like this:

> -->/lib_1
ADD_LIBRARY(lib1 lib1.cxx)

> -->/lib_2
ADD_LIBRARY(lib2 lib2.cxx)
TARGET_LINK_LIBRARIES(lib2 lib1)

> -->/lib_3
ADD_LIBRARY(lib3 lib3.cxx)
TARGET_LINK_LIBRARIES(lib3 lib2)

> -->/app_src
ADD_EXECUTABLE(app app.cxx)
TARGET_LINK_LIBRARIES(app lib3)

Any program that links to lib3 will automatically link to lib2 and lib1.
These dependencies are managed by cmake and invisible to the user.  If you
want to install one big library for use by outside projects, then you can
configure a cmake package for your library that will forward the
dependencies into any outside cmake project.

-Brad
_______________________________________________
Cmake mailing list
Cmake at www . cmake . org
http://www . cmake . org/mailman/listinfo/cmake