# Copyright (c) 2025-2026, IB-Robot Group & openEuler Embedded SIG & openharmony-robot sig_RoboFrame.
# All rights reserved.

include(FetchContent)

message(STATUS "get boost...")

set(boost_DOWNLOAD_URL
    "https://github.com/boostorg/boost/releases/download/boost-1.82.0/boost-1.82.0.tar.xz"
    CACHE STRING "")

if(boost_LOCAL_SOURCE)
  FetchContent_Declare(
    boost
    SOURCE_DIR ${boost_LOCAL_SOURCE}
    OVERRIDE_FIND_PACKAGE)
else()
  FetchContent_Declare(
    boost
    URL ${boost_DOWNLOAD_URL}
    DOWNLOAD_EXTRACT_TIMESTAMP ON
    OVERRIDE_FIND_PACKAGE)
endif()

# Wrap it in a function to restrict the scope of the variables
function(get_boost)
  FetchContent_GetProperties(boost)
  if(NOT boost_POPULATED)
    set(BOOST_INCLUDE_LIBRARIES asio beast)

    set(Boost_USE_STATIC_LIBS ON)

    FetchContent_MakeAvailable(boost)
  endif()
endfunction()

get_boost()