intf_libs = # Interface dependencies.
import intf_libs += libcpp-base64%lib{cpp-base64} \
                    librapidjson%lib{rapidjson} \
                    librapidxml%lib{rapidxml}

# h{} covers RapidJSON proxy headers (.h).
#
# base64.hpp is a thin shim delegating to the libcpp-base64 dependency's
# ::base64_encode/::base64_decode (unmodified upstream cpp-base64, by Rene
# Nyffenegger), namespaced as cereal::base64::encode/decode to match what
# archives/xml.hpp and archives/json.hpp expect. It is no longer vendored
# now that a build2 package for cpp-base64 exists.
#
lib{cereal}: {hxx h ixx txx}{**} $intf_libs

# Build options.
#
out_pfx = [dir_path] $out_root/include/
src_pfx = [dir_path] $src_root/include/

cxx.poptions =+ "-I$out_pfx" "-I$src_pfx"

if $config.libcereal.thread_safe
{
  cxx.poptions += -DCEREAL_THREAD_SAFE=1
  if ($cxx.target.system != 'win32-msvc')
    cxx.libs += -pthread
}

# Export options.
#
lib{cereal}:
{
  cxx.export.poptions = "-I$out_pfx" "-I$src_pfx"
  cxx.export.libs = $intf_libs
}

if $config.libcereal.thread_safe
{
  lib{cereal}: cxx.export.poptions += -DCEREAL_THREAD_SAFE=1

  if ($cxx.target.system != 'win32-msvc')
    lib{cereal}: cxx.export.libs += -pthread
}


# Install recreating subdirectories.
#
{hxx h ixx txx}{*}:
{
  install         = include/
  install.subdirs = true
}
