Skip to content
Snippets Groups Projects
Makefile 1.04 KiB
Newer Older
# A Makefile for miscmaths unit tests.
include ${FSLCONFDIR}/default.mk

PROJNAME    = test-miscmaths
TESTXFILES  = test-miscmaths
USRINCFLAGS = -DMISCMATHS_TEST_DIRECTORY=\"$(realpath .)\"
LIBS        = -lfsl-miscmaths -lfsl-NewNifti -lfsl-cprob

# The test program can be run against
# an in-source checkout, or against
# an installed version of the
# libfsl-miscmaths.so library.
#
# If the former, the miscmaths 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

all: ${TESTXFILES}

OBJS := $(wildcard test_*.cc)
OBJS := $(OBJS:%.cc=%.o)

# We add -I.., -L.., -Wl,-rpath so that
# in-source builds take precedence over
# $FSLDEVDIR/$FSLDIR
%.o: %.cc
	$(CXX) -I.. ${CXXFLAGS} -c -o $@ $<

test-miscmaths: ${OBJS}
	$(CXX) ${CXXFLAGS} -o $@ $^ -L.. ${RPATH} ${LDFLAGS}