|
Boost Users : |
From: KSpam (keesling_spam_at_[hidden])
Date: 2007-05-24 14:32:05
Chris,
The best way for me to answer your question is with an example. I cleaned out
my project-specific stuff and put together an example of my CMake setup (see
attached zip file). I was able to test it on Linux, but I did not have time
to test it on Windows (it should work).
There is a configuration variable "USE_BOOST_RC". If this is set to "ON", it
will download, unbundle, and build the boost_1_34_0 libraries. By default,
it will download, unbundle, and build the boost_1_33_1 libraries. Of course,
my script only builds a small subset of the Boost libraries, but I'm sure you
get the idea.
A directory named "external" will be created where the boost packages will be
unbundled. The boost packages will be downloaded to "external/packages".
CMake calls two python scripts to do the work of downloading and unbundling
the boost packages. These Python scripts expect "unzip" and "wget" to exist
on your path. If you do not want to deal with the wget, and unzip
dependencies, simply place the boost package in external/packages manually,
and unzip it in the external directory.
FWIW, I really like CMake. I used to use SCons. SCons has more raw
capability, but CMake is significantly faster. I don't like the hack I used
of running an external Python script from CMake, but I was not able to get
the desired result without the hack (CMake would automatically remove some of
the Boost sources during the clean). Maybe a better CMake hacker can show me
the error of my ways :-)
In order to use one of the local boost libraries in your CMake project, you
must do the following three things in your project's CMakeLists.txt:
1) Add BOOST_INCLUDE_DIR to include_directories
2) Add the library to target_link_libraries
3) Add boost-headers as a dependency
Example (Using boost-thread):
project(my-cool-project-using-boost-thread)
include_directories(${BOOST_INCLUDE_DIR}) # Step 1
target_link_libraries(${targetName} boost-thread) # Step 2
add_executable(${targetName} ${sourceFiles})
add_dependencies(${targetName} boost-headers) # Step 3
Adding "boost-headers" as a dependency ensures that Boost is downloaded and
unbundled prior to building the target.
Thanks,
Justin
On Thursday 24 May 2007 09:44, Chris Thachuk wrote:
> >I just plumb the Boost source files directly into my
> > build system.
>
> This does make the most sense for my situation. Do you just
> add a "boost" subproject in your top level directory?
>
> > In my case, I use CMake as a build tool, and my applications compile on
> > both Windows and Linux (32 and 64 bit) without having to distribute any
> > binaries.
>
> I've now realized that as I've added more library dependencies (three in
> addition to boost), my simple makefile approach is becoming very tedious.
> I am very interested in using a build system like CMake, or boost.build.
>
> CMake looks very easy to use, but how do you avoid using bjam to build the
> boost libraries?
>
> Have you created a 'CMakeLists.txt' file for each boost library to replace
> the jam files (if so was this complicated)?
>
> Or is there a simpler approach for this?
>
> > I hope that this helps.
> >...
> >
> > Justin
>
> This has already helped a lot. Thank you.
>
> Chris
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net