Boost logo

Boost :

Subject: [boost] Follow-up to the CMake follow-up
From: Peter Dimov (lists_at_[hidden])
Date: 2017-06-30 23:22:09

Due to the strong interest in my previous follow-up, I'm following it up
with a more complete implementation of the support required for CMake
scenario #1, installing configuration files during "b2 install" such that
subsequent "find_package" calls work (assuming a suitably set

You can find it in branch "feature/install-cmake-config" in the superproject

In other words,

git clone --recursive --depth 64 -b feature/install-cmake-config
b2 headers
b2 install cmake//install variant=debug,release link=static,shared

This doesn't yet support installation with more than one toolset, and I'm
sure that some libraries don't work, but a simple test using Filesystem and
ProgramOptions does.

/// CMakeLists.txt: ///

cmake_minimum_required(VERSION 3.5)

project(cmake_demo CXX)


find_package(boost_filesystem 1.63.0)
find_package(boost_program_options 1.63.0)

# disable autolink globally
# could also do it per-target


# sample program

add_executable(cmake_demo cmake_demo.cpp)
target_link_libraries(cmake_demo boost::filesystem boost::program_options)

/// cmake_demo.cpp: ///

#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>
#include <cerrno>
#include <iostream>

namespace fs = boost::filesystem;
namespace po = boost::program_options;

int main( int argc, char const* argv[] )
    po::options_description desc( "Allowed options" );

        ( "help,h", "produce help message" )
        ( "path,p", po::value<std::string>(), "set initial path" )

    po::variables_map vm;

        po::store( po::parse_command_line( argc, argv, desc ), vm );
        po::notify( vm );
    catch( std::exception const & x )
        std::cerr << "Error: " << x.what() << std::endl;
        return 1;

    if( vm.count( "help" ) )
        std::cout << desc << std::endl;
        return 1;

    fs::path p = fs::current_path();

    if( vm.count( "path" ) )
        p = vm[ "path" ].as<std::string>();

    std::cout << p << std::endl;

Boost list run by bdawes at, gregod at, cpdaniel at, john at