add_library(boost_all INTERFACE)
add_library(Boost::boost ALIAS boost_all)

add_library(boost_headers INTERFACE)
add_library(Boost::headers ALIAS boost_headers)

macro(MAKE_BOOST_TARGET libname header_only)
    string(REPLACE "/" "_" BOOST_LIBNAME "${libname}")
    if(${header_only})
        add_library(boost_${BOOST_LIBNAME} INTERFACE)
        target_include_directories(boost_${BOOST_LIBNAME} INTERFACE "${projname_SOURCE_DIR}/third_party/boost/libs/${libname}/include")

        target_include_directories(boost_headers INTERFACE "${projname_SOURCE_DIR}/third_party/boost/libs/${libname}/include")
    else()
        add_library(boost_${BOOST_LIBNAME} ${BOOST_SOURCES})
        target_include_directories(boost_${BOOST_LIBNAME} PUBLIC "${projname_SOURCE_DIR}/third_party/boost/libs/${libname}/include")
        target_link_libraries(boost_${BOOST_LIBNAME} PUBLIC Boost::headers)
    endif()
    add_library(Boost::${BOOST_LIBNAME} ALIAS boost_${BOOST_LIBNAME})
    target_link_libraries(boost_all INTERFACE Boost::${BOOST_LIBNAME})

endmacro()


# Header-only libraries
MAKE_BOOST_TARGET(algorithm YES)
MAKE_BOOST_TARGET(array YES)
MAKE_BOOST_TARGET(assert YES)
MAKE_BOOST_TARGET(bind YES)
MAKE_BOOST_TARGET(concept_check YES)
MAKE_BOOST_TARGET(config YES)
MAKE_BOOST_TARGET(container_hash YES)
MAKE_BOOST_TARGET(core YES)
MAKE_BOOST_TARGET(detail YES)
MAKE_BOOST_TARGET(endian YES)
MAKE_BOOST_TARGET(foreach YES)
MAKE_BOOST_TARGET(function YES)
MAKE_BOOST_TARGET(function_types YES)
MAKE_BOOST_TARGET(fusion YES)
MAKE_BOOST_TARGET(integer YES)
MAKE_BOOST_TARGET(io YES)
MAKE_BOOST_TARGET(iterator YES)
MAKE_BOOST_TARGET(math YES)
MAKE_BOOST_TARGET(move YES)
MAKE_BOOST_TARGET(mp11 YES)
MAKE_BOOST_TARGET(mpl YES)
MAKE_BOOST_TARGET("numeric/conversion" YES)
MAKE_BOOST_TARGET(optional YES)
MAKE_BOOST_TARGET(phoenix YES)
MAKE_BOOST_TARGET(predef YES)
MAKE_BOOST_TARGET(proto YES)
MAKE_BOOST_TARGET(preprocessor YES)
MAKE_BOOST_TARGET(range YES)
MAKE_BOOST_TARGET(smart_ptr YES)
MAKE_BOOST_TARGET(spirit YES)
MAKE_BOOST_TARGET(static_assert YES)
MAKE_BOOST_TARGET(system YES)
MAKE_BOOST_TARGET(throw_exception YES)
MAKE_BOOST_TARGET(type_index YES)
MAKE_BOOST_TARGET(typeof YES)
MAKE_BOOST_TARGET(type_traits YES)
MAKE_BOOST_TARGET(utility YES)
MAKE_BOOST_TARGET(variant YES)

# Compiled libraries
file(GLOB BOOST_SOURCES "${projname_SOURCE_DIR}/third_party/boost/libs/regex/src/*.cpp")
MAKE_BOOST_TARGET(regex NO)

set(BOOST_SOURCES "${projname_SOURCE_DIR}/third_party/boost/libs/iostreams/src/file_descriptor.cpp")
list(APPEND BOOST_SOURCES "${projname_SOURCE_DIR}/third_party/boost/libs/iostreams/src/mapped_file.cpp")
MAKE_BOOST_TARGET(iostreams NO)
