intf_libs = # Interface dependencies.
#import xxxx_libs += libhello%lib{hello}

lib{rapidjson}: hxx{**} $intf_libs

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

lib{rapidjson}:
{
  cxx.export.poptions = "-I$out_pfx" "-I$src_pfx"
  cxx.export.libs = $intf_libs
}

# Propagate optional features as the upstream preprocessor macros. These
# must be export options: the library is header-only so they apply to the
# consumer's translation units.
#
if $config.librapidjson.stdstring
  lib{rapidjson}: cxx.export.poptions += -DRAPIDJSON_HAS_STDSTRING=1

if $config.librapidjson.membersmap
  lib{rapidjson}: cxx.export.poptions += -DRAPIDJSON_USE_MEMBERSMAP=1

# SSE4.2 takes precedence over SSE2, matching upstream.
#
if $config.librapidjson.sse42
  lib{rapidjson}: cxx.export.poptions += -DRAPIDJSON_SSE42
elif $config.librapidjson.sse2
  lib{rapidjson}: cxx.export.poptions += -DRAPIDJSON_SSE2

if $config.librapidjson.neon
  lib{rapidjson}: cxx.export.poptions += -DRAPIDJSON_NEON

if ($config.librapidjson.namespace != [null])
  lib{rapidjson}: cxx.export.poptions += \
    "-DRAPIDJSON_NAMESPACE=$config.librapidjson.namespace"

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