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

# Public headers.
#
pub = [dir_path] ../include/

include $pub

pub_hdrs = $($pub/ pub_hdrs)

lib{metal-cpp}: $pub/{$pub_hdrs}

# Private headers and sources as well as dependencies.
#
lib{metal-cpp}: {hxx}{**} $impl_libs $intf_libs
lib{metal-cpp}: cxx{**}: include = $config.libmetal_cpp.implementation

# Build options.
#
out_pfx_inc = [dir_path] $out_root/include/
src_pfx_inc = [dir_path] $src_root/include/
out_pfx_src = [dir_path] $out_root/src/
src_pfx_src = [dir_path] $src_root/src/

cxx.poptions =+ "-I$out_pfx_src" "-I$src_pfx_src" \
                "-I$out_pfx_inc" "-I$src_pfx_inc"

#obja{*}: cxx.poptions += -DMETAL_STATIC_BUILD
#objs{*}: cxx.poptions += -DMETAL_SHARED_BUILD

# Export options.
#
lib{metal-cpp}:
{
  cxx.export.poptions = "-I$out_pfx_inc" "-I$src_pfx_inc"
  cxx.export.libs = $intf_libs

  export.metadata = 1 libmetal_cpp
  libmetal_cpp.implementation = [bool] $config.libmetal_cpp.implementation
}

# Apple frameworks required by the implementation TU and public headers.
#
if ($cxx.target.class == 'macos')
{
  # Note: no -lobjc. Pulled in via Foundation. An explicit -lobjc also
  # breaks static consumers on older build2 (now treated as system:
  # https://github.com/build2/build2/commit/43a77886456d2eb5936445921b3b7682bfe8e26b).
  #
  apple_libs = -framework Foundation \
               -framework Metal \
               -framework QuartzCore \
               -framework MetalFX

  cxx.libs += $apple_libs

  lib{metal-cpp}: cxx.export.libs += $apple_libs
}

#liba{metal-cpp}: cxx.export.poptions += -DMETAL_STATIC
#libs{metal-cpp}: cxx.export.poptions += -DMETAL_SHARED

# 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{metal-cpp}: bin.lib.version = "-$version.project_id"
else
  lib{metal-cpp}: bin.lib.version = "-$version.major.$version.minor"

# Don't install private headers.
#
hxx{*}: install = false
