#! /bin/bash

function eecho()
{
	echo "$@" 1>&2
}

verbose=${JAS_TEST_WRAPPER_VERBOSE:-0}

abs_source_dir="@CMAKE_SOURCE_DIR@"
abs_build_dir="@CMAKE_BINARY_DIR@"
command="$1"
shift 1

export JAS_ABS_TOP_BUILDDIR="$abs_build_dir"
export JAS_TOP_BUILDDIR="$abs_build_dir"
export JAS_ABS_TOP_SRCDIR="$abs_source_dir"
export JAS_TOP_SRCDIR="$abs_source_dir"

export JAS_CMAKE_SOURCE_DIR="@CMAKE_SOURCE_DIR@"
export JAS_CMAKE_BINARY_DIR="@CMAKE_BINARY_DIR@"
export JAS_CMAKE_INSTALL_PREFIX="@CMAKE_INSTALL_PREFIX@"

if [ "$verbose" -gt 0 ]; then
	printenv | fgrep JAS_ 1>&2
	eecho "Running command $command"
fi
"$command" "$@"
