Version 3 (modified by 15 years ago) ( diff ) | ,
---|
Configuring and Building Boost with CMake
This page describes how to configure and build Boost with CMake. By following these instructions, you should be able to get CMake, configure a Boost build tree to your liking with CMake, and then build, install, and package Boost libraries.
- Download CMake: There are precompiled binaries for CMake on several different platforms. The installation of these pre-compiled binaries is mostly self-explanatory. If you need to build your own copy of CMake, please see the CMake installation instructions. In these instructions, we will assume that the Boost source tree, with CMake build files, is available in the directory
$BOOST_ROOT
.
- Download Boost with CMake: At present, the CMake build system is developed externally from Boost itself. To get a copy of Boost 1.34.0 with the CMake build system, retrieve it from the Boost Subversion repository with the URL http://svn.boost.org/svn/boost/sandbox-branches/boost-cmake/boost_1_34_0].
- Configure the Boost source tree with CMake's configuration tool. This step differs depending on whether you are using CMake's GUI on Microsoft Windows or whether you are using the command-line tools provided on Unix.
- On Windows: Run CMake by selecting it from the Start menu.
- Use the
Browse...
button to point CMake at the Boost source code in$BOOST_ROOT
. - Use the second
Browse...
button to select the directory where Boost will build binaries. - CMake will ask you what kind of project files or make files to build. If you're using Microsoft Visual Studio, select the appropriate version to generate project files. Otherwise, you can use Borland's make files, generate NMake files, etc.
- Click "Configure" to configure Boost, which will search for various libraries on your system and prepare the build.
- If you want, you can edit various options in the CMake GUI. These options will affect what libraries are built and how. Each time you finish editing options, click "Configure".
- When you are done, click "OK" to generate project files.
- Use the
- On Unix:
- Create a new directory that will hold the binaries that CMake builds. This document will assume you have created used the directory name
boost-bin
for these binaries, and that this directory is not inside $BOOST_ROOT:mkdir boost-bin
- Change into the binary directory you have just created:
cd boost-bin
- Run the CMake configuration program, providing it with the Boost source directory:
ccmake $BOOST_ROOT
- Press
c
(for (c)onfigure) to perform the preliminary configuration of the CMake build system. - If you want, you can edit various options in the CMake interface. These options will affect what libraries are built and how. Each time you finish editing options, press
c
to reconfigure. Mac OS X users: to build universal binaries, change the value ofCMAKE_OSX_ARCHITECTURES
toppc;i386
in the CMake configuration. - When the options you have selected have stabilized, CMake will give you the (g)enerate option. If you do not see this option, press
c
again to reconfigure. Finally, pressg
to generate makefiles and exit.
- Create a new directory that will hold the binaries that CMake builds. This document will assume you have created used the directory name
- On Windows: Run CMake by selecting it from the Start menu.
That's it! You've now configured your source tree and are ready to start building Boost.
- Build Boost: Like configuration, the way in which one builds Boost with CMake differs from one platform to another, depending on your platform and how you configured CMake. Either way, you'll be using the tools provided to you by your compiler or operating system vendor.
- Microsoft Visual Studio: If you have generated project files for Microsoft Visual Studio, you will need to start up Visual Studio to build Boost. Once Visual Studio has loaded, load the solution or project
Boost
from the Boost binary directory you set in the CMake configuration earlier. Then, just click "Build" to build all of Boost. - On Unix (and when using makefile variants on Microsoft Windows): If you are on Unix, you will build Boost using standard "make" tools. Change into the binary directory we created and configured earlier, than run
make
:make
- Microsoft Visual Studio: If you have generated project files for Microsoft Visual Studio, you will need to start up Visual Studio to build Boost. Once Visual Studio has loaded, load the solution or project
- That's it! Once the build completes (which make take a while, if you are building all of the Boost libraries), the Boost libraries will be available in the
lib
subdirectory of your binary directory, ready to be used, installed, or packaged.
Installing Boost
The installation of Boost's headers and compiled libraries uses the same tools as building the library. With Microsoft Visual Studio, just load the Boost solution or project and build the 'INSTALL' target to perform the installation. Unix and makefile users will change into the Boost binary directory and use the install
make target, e.g.,
make install
Packaging Boost
CMake can easily build binary packages for a variety of platforms. On Windows and Mac OS X, CMake builds graphical installation programs. For other Unix operating systems, CMake currently builds tarballs and self-installing shell scripts. This CMake functionality, providing by the CPack program that is part of CMake, is used to create all of the CMake's binary installers.
Building binary installation packages with CMake is similar to installing Boost. On Windows, one must first download and install the Nullsoft Scriptable Install System (NSIS). Then, using Microsoft Visual Studio, one loads the Boost project/solution and build the PACKAGE
target to generate the graphical installer. On Mac OS X, other Unix platforms, and on Windows when using a makefile generator, change into the Boost binary directory and use the package
make target, e.g.,
make package
Once this process completes, you will have several binary installers for you platform.