Skip to content

FetchBoostContent_Declare

Boost modules

FetchBoostContent_Declare is the Boost analogous of FetchContent_Declare. The function also accepts the same arguments as FetchContent_Declare.

FetchBoostContent_Declare(
        boost_beast
        GIT_REPOSITORY https://github.com/boostorg/beast
        GIT_TAG        master
)

Note

The module name always needs to start with "boost_"

The declare function stores details about the Boost module and calls the regular FetchContent_Declare function for the module. These properties need to be later retrieved by other functions. The implementation ensures only the first declaration is used when populating the library.

Note that FetchContent is often used in conjunction with find_package, where the library is declared and fetched only when not available in the system:

find_package(Boost COMPONENTS container)
if (NOT Boost_FOUND)
    include(cmake/FetchBoostContent.cmake)

    # Example fetching Boost.Beast
    FetchBoostContent_Declare(
            boost_beast
            GIT_REPOSITORY https://github.com/boostorg/beast
            GIT_TAG        master
    )
    # fetch library...