# FetchContent with Boost

**URL:** <https://discourse.cmake.org/t/fetchcontent-with-boost/6596>\
**Category:** Code\
**Tags:** os:windows\
**Created:** [October 4, 2022, 2:18pm UTC](https://discourse.cmake.org/t/fetchcontent-with-boost/6596 "2022-10-04T14:18:26Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [December 27, 2023, 8:02pm UTC](https://discourse.cmake.org/t/fetchcontent-with-boost/6596/21 "2023-12-27T20:02:52Z")

</div>

> [@craig.scott](#):
>
> In your case, you set the `<helpString>` to `NO`. It just so happens that when you omit the `<value>` it defaults to false anyway.

you are right, but this is not the problem!  
The `boost cmake system` is designed to use it **only standalone for boost developers**.

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [December 27, 2023, 9:02pm UTC](https://discourse.cmake.org/t/fetchcontent-with-boost/6596/22 "2023-12-27T21:02:54Z")

</div>

**It is possible, but hard, you will just end in installing the hole set of boost libraries:**

```cmake
list(TRANSFORM BOOST_INCLUDE_LIBRARIES PREPEND boost_ OUTPUT_VARIABLE BOOST_TARGETS)
install(TARGETS ${BOOST_TARGETS} EXPORT ${PROJECT_NAME}Targets)

```

```bash
-- Configuring done (0.9s)
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_asio" which requires target "boost_align" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_asio" which requires target "boost_assert" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_asio" which requires target "boost_config" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_asio" which requires target "boost_context" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_asio" which requires target "boost_coroutine" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_asio" which requires target "boost_date_time" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_asio" which requires target "boost_system" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_asio" which requires target "boost_throw_exception" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_filesystem" which requires target "boost_assert" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_filesystem" which requires target "boost_config" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_filesystem" which requires target "boost_container_hash" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_filesystem" which requires target "boost_core" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_filesystem" which requires target "boost_detail" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_filesystem" which requires target "boost_io" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_filesystem" which requires target "boost_iterator" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_filesystem" which requires target "boost_smart_ptr" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_filesystem" which requires target "boost_system" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_filesystem" which requires target "boost_type_traits" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_array" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_assert" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_config" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_core" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_detail" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_integer" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_io" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_iterator" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_move" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_mpl" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_optional" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_predef" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_preprocessor" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_smart_ptr" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_spirit" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_static_assert" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_type_traits" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_unordered" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_utility" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_serialization" which requires target "boost_variant" that is not in any export set.
CMake Error: install(EXPORT "tftpdTargets" ...) includes target "boost_filesystem" which requires target "boost_atomic" that is not in any export set.
-- Generating done (0.1s)
CMake Generate step failed. Build files cannot be regenerated correctly.

```

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [December 27, 2023, 9:58pm UTC](https://discourse.cmake.org/t/fetchcontent-with-boost/6596/23 "2023-12-27T21:58:54Z")

</div>

IMHO: this is much simpler to use and with cache the fastest way to build:

```cmake
option(BUILD_SHARED_LIBS "Build shared libraries" YES)
set(BOOST_INCLUDE_LIBRARIES filesystem asio headers)
CPMAddPackage("gh:ClausKlein/boost-cmake@1.81.0-rc2")

```

see [Bump to boost v1.81.0 by ClausKlein · Pull Request #6 · ClausKlein/boost-cmake · GitHub](https://github.com/ClausKlein/boost-cmake/pull/6)

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [December 30, 2023, 10:44pm UTC](https://discourse.cmake.org/t/fetchcontent-with-boost/6596/24 "2023-12-30T22:44:44Z")

</div>

see too [install(RUNTIME\_DEPENDENCY\_SET appDeps) does nothing install?](https://discourse.cmake.org/t/install-runtime-dependency-set-appdeps-does-nothing-install/9741)

---

<div class="post-metadata">

**Author:** ![Butanium](https://discourse.cmake.org/user_avatar/discourse.cmake.org/butanium/32/4418_2.png) [@Butanium](https://discourse.cmake.org/u/Butanium)\
**Post date:** [March 19, 2024, 12:56pm UTC](https://discourse.cmake.org/t/fetchcontent-with-boost/6596/25 "2024-03-19T12:56:49Z")

</div>

I’m unable to get the Boost::mpi package with this fetch content (serialization works though). I have the same issue using GIT\_REPOSITORY and GIT\_TAG

```cmake
        set(BOOST_INCLUDE_LIBRARIES serialization mpi)
        set(BOOST_ENABLE_CMAKE ON)
        FetchContent_Declare(
                Boost
                URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.7z
                USES_TERMINAL_DOWNLOAD TRUE
                DOWNLOAD_NO_EXTRACT FALSE
              )
        FetchContent_MakeAvailable(Boost)

```

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [March 20, 2024, 8:15am UTC](https://discourse.cmake.org/t/fetchcontent-with-boost/6596/26 "2024-03-20T08:15:39Z")

</div>

Dit you read the README from boost cmake?

```auto
bash-5.2$ head tools/cmake/README.md 
# Boost CMake support infrastructure

This repository hosts the `tools/cmake` Boost submodule, containing
the CMake support infrastructure for Boost.

Note that the officially supported way to build Boost remains
[with `b2`](https://www.boost.org/more/getting_started/index.html).

## Building Boost with CMake

bash-5.2$ 

```

---

<div class="post-metadata">

**Author:** ![Butanium](https://discourse.cmake.org/user_avatar/discourse.cmake.org/butanium/32/4418_2.png) [@Butanium](https://discourse.cmake.org/u/Butanium)\
**Post date:** [March 20, 2024, 9:40am UTC](https://discourse.cmake.org/t/fetchcontent-with-boost/6596/27 "2024-03-20T09:40:27Z")

</div>

Oops! Thanks for pointing it out

```auto
BOOST_ENABLE_MPI

Set to ON if Boost libraries depending on MPI should be built.

```

[Previous page](https://discourse.cmake.org/t/fetchcontent-with-boost/6596.md?page=1)
