set(Boost_VERSION 108300)
set(Boost_VERSION_STRING "1.83.0")
set(Boost_INCLUDE_DIRS "${BOOST_WASM_ROOT}/include")
set(Boost_INCLUDE_DIR "${Boost_INCLUDE_DIRS}")
set(Boost_LIBRARIES "")

foreach(component IN LISTS Boost_FIND_COMPONENTS)
  string(TOLOWER "${component}" component_lower)
  set(archive "${BOOST_WASM_ROOT}/lib/libboost_${component_lower}.a")
  if(NOT EXISTS "${archive}")
    set(Boost_${component}_FOUND FALSE)
    set(Boost_FOUND FALSE)
    if(Boost_FIND_REQUIRED_${component})
      message(FATAL_ERROR "Missing Boost wasm component ${component}: ${archive}")
    endif()
    continue()
  endif()
  if(NOT TARGET Boost::${component})
    add_library(Boost::${component} STATIC IMPORTED)
    set_target_properties(Boost::${component} PROPERTIES
      IMPORTED_LOCATION "${archive}"
      INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}"
    )
    if(component_lower STREQUAL "thread")
      set_property(TARGET Boost::${component} APPEND PROPERTY INTERFACE_LINK_LIBRARIES
        "${BOOST_WASM_ROOT}/lib/libboost_atomic.a")
    endif()
  endif()
  set(Boost_${component}_FOUND TRUE)
  list(APPEND Boost_LIBRARIES Boost::${component})
endforeach()

set(Boost_FOUND TRUE)
