if (PR_DOWNLOAD_BOOST)
    if (WIN32)
        set(BOOST_URL "https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.zip")
        set(BOOST_URL_HASH "0fd43bb53580ca54afc7221683dfe8c6e3855b351cd6dce53b1a24a7d7fbeedd")
        set(BOOST_BOOTSTRAP_COMMAND "bootstrap.bat")
        set(BOOST_B2_COMMAND "b2.exe")
        set(BOOST_B2_FLAGS "")
    elseif (UNIX)
        set(BOOST_URL "https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz")
        set(BOOST_URL_HASH "7bd7ddceec1a1dfdcbdb3e609b60d01739c38390a5f956385a12f3122049f0ca")
        set(BOOST_BOOTSTRAP_COMMAND "./bootstrap.sh")
        set(BOOST_B2_COMMAND "./b2")
        set(BOOST_B2_FLAGS "")
    endif()

    include(FetchContent)
    FetchContent_Declare(
        boost
        URL ${BOOST_URL}
        URL_HASH SHA256=${BOOST_URL_HASH}
    )

    FetchContent_GetProperties(boost)
    if(NOT boost_POPULATED)
        FetchContent_Populate(boost)
    endif()

    if (NOT PR_BUILT_BOOST)
        execute_process(
            COMMAND ${BOOST_BOOTSTRAP_COMMAND} --prefix=${boost_BINARY_DIR} --with-libraries=filesystem,random
            WORKING_DIRECTORY ${boost_SOURCE_DIR}
        )
        if (UNIX)
            execute_process(
                COMMAND ${BOOST_B2_COMMAND} cxxflags=-fPIC cflags=-fPIC link=static install
                WORKING_DIRECTORY ${boost_SOURCE_DIR}
            )
        else()
            execute_process(
                COMMAND ${BOOST_B2_COMMAND} install
                WORKING_DIRECTORY ${boost_SOURCE_DIR}
            )
        endif()
        set(PR_BUILT_BOOST ON CACHE INTERNAL "")
    endif()

    set(BOOST_ROOT ${boost_BINARY_DIR})
    set(Boost_NO_SYSTEM_PATHS ON)
    find_package(Boost 1.76 REQUIRED COMPONENTS filesystem random)
else()
    find_package(Boost 1.70 REQUIRED)
endif()