intf_libs = # Interface dependencies.
impl_libs = # Implementation dependencies.
import intf_libs += fmt%lib{fmt}

# fmt/bundled/ and bundled_fmtlib_format.cpp are upstream's bundled fmt
# fallback for builds without SPDLOG_FMT_EXTERNAL, which this package
# always defines, so none of it is ever included or compiled.
#
lib{spdlog}: {cxx hxx}{** -bundled_fmtlib_format -**/bundled/*} $impl_libs $intf_libs


if ($cxx.target.class != 'windows')
{
  cc.libs += -lpthread
  lib{spdlog} : cc.export.libs += -lpthread
}

# Note from Klaim: removed because spdlog already provides a version.h file.
# # Include the generated version header into the distribution (so that we don't
# # pick up an installed one) and don't remove it when cleaning in src (so that
# # clean results in a state identical to distributed).
# #
# hxx{version}: in{version} $src_root/manifest
# {
#   dist  = true
#   clean = ($src_root != $out_root)
# }

# Build options.
#
cxx.poptions =+ "-I$out_root" "-I$src_root" "-I$src_base/include"
cxx.poptions += -DSPDLOG_COMPILED_LIB
# fmt is a package dependency
cxx.poptions += -DSPDLOG_FMT_EXTERNAL

objs{*}: cxx.poptions += -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS

# Disable the dll-interface warnings for the shared library, as upstream does.
#
if ($cxx.id == 'msvc')
  objs{*}: cxx.coptions += /wd4251 /wd4275

if($cxx.target.class == 'windows')
{
  if($cxx.id == 'gcc')
  {
    cxx.libs += -ladvapi32
    lib{spdlog}: cxx.export.libs += -ladvapi32
  }
  else
  {
    cxx.libs += Advapi32.lib
    lib{spdlog}: cxx.export.libs += Advapi32.lib
  }
}

# Export options.
#
lib{spdlog}:
{
  cxx.export.poptions += "-I$out_root" "-I$src_root" "-I$src_base/include"
  cxx.export.poptions += -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL
  cxx.export.libs += $intf_libs
}

libs{spdlog}: cxx.export.poptions += -DSPDLOG_SHARED_LIB


# For pre-releases use the complete version to make sure they cannot be used
# in place of another pre-release or the final version. See the version module
# for details on the version.* variable values.
#
if $version.pre_release
  lib{spdlog}: bin.lib.version = @"-$version.project_id"
else
  lib{spdlog}: bin.lib.version = @"-$version.major.$version.minor"

# Install into the spdlog/ subdirectory of, say, /usr/include/
# recreating subdirectories.
#
{hxx ixx txx}{*}:
{
  install         = $install.root
  install.subdirs = true
}
