我的目标是在未找到Boost库的情况下下载它,然后以默认方式构建它,即使用boostrap
和b2
工具。
我知道,我可以这样下载它:
include(FetchContent)
FetchContent_Declare(
Boost
PREFIX external_dependencies/boost
GIT_REPOSITORY https://github.com/boostorg/boost.git
GIT_SUBMODULES libs/system libs/serialization libs/random
libs/function libs/config libs/headers libs/assert libs/core libs/integer
libs/type_traits libs/mpl libs/throw_exception libs/preprocessor libs/utility
libs/static_assert libs/smart_ptr libs/predef libs/move libs/io libs/iterator
libs/detail libs/spirit libs/optional libs/type_index libs/container_hash
libs/array libs/bind
tools/build tools/boost_install
)
FetchContent_GetProperties(Boost)
FetchContent_Populate(Boost)
但是现在如何正确构建它?我想运行以下命令:
./bootstrap.sh
./b2 headers
./b2 -q cxxflags="-fPIC" --layout=system variant=${BUILD_TYPE} link=${LINK_TYPE} address-model=64 --with-system --with-serialization --with-random
我正在考虑使用add_custom_target()和add_custom_command()函数,但是不确定是否推荐这样做。