|
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
CMAKE_PREFIX_PATH).
You can find it in branch "feature/install-cmake-config" in the superproject
(boostorg/boost).
In other words,
git clone --recursive --depth 64 -b feature/install-cmake-config
https://githib.com/boostorg/boost
bootstrap
b2 headers
b2 install cmake//install variant=debug,release link=static,shared
runtime-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)
list(APPEND CMAKE_PREFIX_PATH C:/Boost)
find_package(boost_filesystem 1.63.0)
find_package(boost_program_options 1.63.0)
# disable autolink globally
# could also do it per-target
add_definitions(-DBOOST_ALL_NO_LIB=1)
# 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" );
desc.add_options()
( "help,h", "produce help message" )
( "path,p", po::value<std::string>(), "set initial path" )
;
po::variables_map vm;
try
{
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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk