wiki:CMakeAddingALibrary

Adding a Boost Library with CMake

This page describes how to introduce a new Boost library into the CMake-based build system. Any Boost library that provides a library binary (e.g., boost_signals.dll) or has regression tests (hopefully, every Boost library!) will need to be part of the build system.

To introduce a new library, which resides in the subdirectory libs/libname, follow these steps:

  1. Create a new file libs/libname/CMakeLists.txt with your favorite text editor. This file will contain an invocation of the boost_library_project macro, which identifies each Boost library to the build system. The invocation of the boost_library_project will look like this:
    boost_library_project(
      Libname
      SRCDIRS src
      TESTDIRS test
      )
    

where Libname is the properly-capitalization library name, e.g., Signals or Smart_ptr. The SRCDIRS src line should only be present if your Boost library actually needs to compile a library binary; header-only libraries can skip this step. The TESTDIRS test line indicates that the subdirectory test contains regression tests for your library. Every Boost library should have these.

  1. Re-run CMake to reconfigure the source tree, causing CMake to find the new Boost library. CMake can be re-run either from the command line (by invoking cmake /path/to/boost or ccmake /path/to/boost) or, on Windows, using the CMake GUI. Once you have reconfigured and generated new makefiles or project files, CMake knows about your library.
  1. If your library has compiled sources (i.e., it is not a header-only library), follow the instructions on adding a compiled library to get CMake building and installing your library.
  1. If your library has regression tests (it does have regression tests, right?), follow the instructions on adding regression tests to get CMake to build and run regression tests for your library.
Last modified 15 years ago Last modified on Jun 12, 2007, 3:28:05 AM
Note: See TracWiki for help on using the wiki.