[CMake] How to link the third party libraries into the project?

Ram Mulage themulage at gmail.com
Thu Jan 22 05:08:58 EST 2009


Thank you all for the inputs. Shall try all the suggested methods and then
get back to you.

Meanwhile I have another quick question. I am trying to build a
library(.lib) and the directory strcture is as mentioned below.

|-Lib_a
|   -lib1
|   -lib2
|   -lib3
|-Lib_b

Lib_a has three sub-directories and each directory creates a .lib file. The
requirement is to create a library(.lib) in Lib_b, which uses all the 3
libraries created in Lib_a. How should my CMakeLists.txt in Lib_b should
look for this requirement?

Many thanks,
-Ram

On Wed, Jan 21, 2009 at 8:44 PM, Adam Weiss
<cseadam+cmake at gmail.com<cseadam%2Bcmake at gmail.com>
> wrote:

> On Wed, Jan 21, 2009 at 3:27 PM, Michael Jackson
> <mike.jackson at bluequartz.net> wrote:
> >
> > On Jan 21, 2009, at 3:19 PM, Alexander Neundorf wrote:
> >
> >> On Wednesday 21 January 2009, Ram Mulage wrote:
> >>>
> >>> Hi All,
> >>>
> >>> I am using boost library in my project and I want to link the boost
> >>> static
> >>> libraries into my project. How do i do this?
> >>>
> >>> My project  directory looks as below and each of the directories has
> the
> >>> CMakeLists.txt file.
> >>>
> >>> Project
> >>>
> >>>  |-Lib1
> >>>  |-Lib2
> >>>  |-Application
> >>>
> >>> I am using the some of the boost libraries in the 'Application'
> directory
> >>> apart from the Lib1 and Lib2 and the exe is built in Application
> >>> directory
> >>> itself. The boost librariess and the boost headers are present
> >>> 'C:/Users/Admin/Boost/lib/windows' and 'C:/Users/Admin/Boost/boost'.
> >>> Could
> >>> you please tell how my CMakeList.txt for 'Application' directory should
> >>> look?
> >>>
> >>> I would appreciate any help in this regard.
> >>
> >> Please have a look at the FindBoost.cmake module documentation, you
> >> probably
> >> want to use it.
> >> I haven't used Boost with cmake yet, but it should be more or less the
> >> same as
> >> for other packages:
> >>
> >> # make cmake search for the package:
> >> find_package(Foo REQUIRED)
> >>
> >> # add the include directories:
> >> include_directories(${FOO_INCLUDE_DIRS})
> >>
> >> # add targets etc.
> >> add_executable(hello main.cpp)
> >>
> >> # link to the necessary libraries
> >> target_link_libraries(hello ${FOO_LIBRARIES})
> >>
> >> Alex
> >>
> >
> > I have a gut feeling just looking at where his install is located and the
> > include directory that the standard Find_Package(Boost) is NOT going to
> > work.. but give it a try and let's see what happens.
> >
> > Mike
> >
> > _______________________________________________
> > CMake mailing list
> > CMake at cmake.org
> > http://www.cmake.org/mailman/listinfo/cmake
> >
>
>
> As the module says:
>
> # Variables used by this module, they can change the default behaviour
> and need to be set
> # before calling find_package:
> #  Boost_USE_MULTITHREAD         Can be set to OFF to use the
> non-multithreaded
> #                                boost libraries. Defaults to ON.
> #  Boost_USE_STATIC_LIBS         Can be set to ON to force the use of the
> static
> #                                boost libraries. Defaults to OFF.
> #  Boost_ADDITIONAL_VERSIONS     A list of version numbers to use for
> searching
> #                                the boost include directory. The default
> list
> #                                of version numbers is:
> #                                1.33, 1.33.0, 1.33.1, 1.34, 1.34.0,
> 1.34.1,
> #                                1.35, 1.35.0, 1.35.1, 1.36.0, 1.36.1
> #                                If you want to look for an older or newer
> #                                version set this variable to a list of
> #                                strings, where each string contains a
> number, i.e.
> #                                SET(Boost_ADDITIONAL_VERSIONS
> "0.99.0" "1.35.0")
> #  BOOST_ROOT                    Preferred installation prefix for
> searching for Boost,
> #                                set this if the module has problems
> finding the proper Boost installation
> #  BOOST_INCLUDEDIR              Set this to the include directory of
> Boost, if the
> #                                module has problems finding the
> proper Boost installation
> #  BOOST_LIBRARYDIR              Set this to the lib directory of Boost, if
> the
> #                                module has problems finding the
> proper Boost installation
> #
> #  The last three variables are available also as environment variables
>
>
> Following this, there should be no problem getting Find_Package(Boost) to
> work.
>
> -Adam
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090122/9d243ba9/attachment.htm>


More information about the CMake mailing list