repository (https://github.com/google/googletest) and refers to that if you
have any problem to install it. Follow the steps below:
-* Install: cmake
-* Clone google test project from: //github.com/rodrigosiqueira/logbook.git and
+* Install: cmake and pthread
+* Clone google test project from: https://github.com/google/googletest and
enter in the project directory
* Inside project directory, type:
@$(MAKE) -C $(UNITESTPATH) CXX="$(CXX)" CPPFLAGS="$(CPPFLAGS)" \
CXXFLAGS="$(CXXFLAGS)" LDLIBS="$(LDLIBS)" ROOTPATH="$(CURDIR)"
-run-all-unitest:
- @$(MAKE) -C $(UNITESTPATH) run-tests
-
clean-unit-test:
@$(MAKE) -C $(UNITESTPATH) clean
RPATH := -Wl,-rpath
EXTRAFLAGS := -lyosys
-ALLTESTFILE := $(wildcard ./**/*Test.cc)
OBJTEST := objtest
BINTEST := bintest
-all: prepare $(ALLTESTFILE:%Test.cc=%Test.o)
+ALLTESTFILE := $(shell find -name '*Test.cc' -printf '%P ')
+TESTDIRS := $(sort $(dir $(ALLTESTFILE)))
+TESTS := $(addprefix $(BINTEST)/, $(basename $(ALLTESTFILE:%Test.cc=%Test.o)))
-%Test.o: %Test.cc
- $(CXX) -o $(OBJTEST)/$(notdir $@) -c -I$(ROOTPATH) $(CPPFLAGS) $(CXXFLAGS) $<
- $(CXX) -L$(ROOTPATH) $(RPATH)=$(ROOTPATH) -o \
- $(BINTEST)/$(basename $(notdir $@)) $(OBJTEST)/$(notdir $@) $(LDLIBS) \
+# Prevent make from removing our .o files
+.SECONDARY:
+
+all: prepare $(TESTS) run-tests
+
+$(BINTEST)/%: $(OBJTEST)/%.o
+ $(CXX) -L$(ROOTPATH) $(RPATH)=$(ROOTPATH) -o $@ $^ $(LDLIBS) \
$(GTESTFLAG) $(EXTRAFLAGS)
-
+
+$(OBJTEST)/%.o: $(basename $(subst $(OBJTEST),.,%)).cc
+ $(CXX) -o $@ -c -I$(ROOTPATH) $(CPPFLAGS) $(CXXFLAGS) $^
+
.PHONY: prepare run-tests clean
-run-tests:
- $(CURDIR)/$(BINTEST)/*
+run-tests: $(TESTS)
+ $(subst Test ,Test; ,$^)
prepare:
- mkdir -p $(OBJTEST)
- mkdir -p $(BINTEST)
+ mkdir -p $(addprefix $(BINTEST)/,$(TESTDIRS))
+ mkdir -p $(addprefix $(OBJTEST)/,$(TESTDIRS))
clean:
rm -rf $(OBJTEST)