# A Makefile for newimage unit tests.
include ${FSLCONFDIR}/default.mk

PROJNAME   = test-newimage
TESTXFILES = test-newimage

all: ${TESTXFILES}

LIBS = -lfsl-newimage -lfsl-miscmaths -lfsl-NewNifti \
       -lfsl-cprob -lfsl-utils -lfsl-znz -lboost_unit_test_framework -lpthread

# The test program can be run against
# an in-source checkout, or against
# an installed version of the
# libfsl-newimage.so library.
#
# If the former, the newimage library
# must have been compiled before the
# test can be compiled.

# The test program uses the Boost unit
# testing framework, which needs librt
# on linux.
SYSTYPE := $(shell uname -s)
ifeq ($(SYSTYPE), Linux)
LIBS  += -lrt
RPATH := -Wl,-rpath,'$$ORIGIN/..'
endif
ifeq ($(SYSTYPE), Darwin)
RPATH := -Wl,-rpath,'@executable_path/..'
endif

# Need this flag to enable std::execution
# policies in clang
ifeq ($(SYSTYPE), Darwin)
USRCXXFLAGS += -fexperimental-library
endif

SRCS := $(wildcard test_*.cc)

test-newimage: ${SRCS}
	$(CXX) -I.. ${CXXFLAGS} -o $@ $^ -L.. ${RPATH} ${LDFLAGS}
