doh. Makefile set up, first test converted, setup seems to work. googletest
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Mon, 26 Aug 2019 10:49:51 +0200
branchgoogletest
changeset 4012beb70e301d31
parent 4011 e8b3f8663f65
child 4013 5f0d261aa755
doh. Makefile set up, first test converted, setup seems to work.
gtest/Makefile
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gtest/Makefile	Mon Aug 26 10:49:51 2019 +0200
     1.3 @@ -0,0 +1,117 @@
     1.4 +# Copyright 2019, pEp Foundation
     1.5 +# This file is part of pEpEngine
     1.6 +# This file may be used under the terms of the GNU General Public License version 3
     1.7 +# see LICENSE.txt
     1.8 +
     1.9 +HERE:=$(CURDIR)
    1.10 +
    1.11 +include ../Makefile.conf
    1.12 +
    1.13 +GTEST_DIR:=googletest/googletest
    1.14 +SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
    1.15 +OBJS:=$(addsuffix .o,$(basename $(SRCS)))
    1.16 +DEPS:=$(OBJS:.o=.d)
    1.17 +
    1.18 +LDFLAGS+= -L../asn.1 -L../src $(ETPAN_LIB) $(CPPUNIT_LIB)
    1.19 +
    1.20 +TARGET:=EngineTests 
    1.21 +
    1.22 +ifeq ($(OPENPGP),GPG)
    1.23 +    LDFLAGS+= $(GPGME_LIB)
    1.24 +else ifeq ($(OPENPGP),NETPGP)
    1.25 +    LDFLAGS+= $(NETGPG_LIB)
    1.26 +endif
    1.27 +
    1.28 +LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
    1.29 +
    1.30 +ifeq ($(BUILD_FOR),Linux)
    1.31 +    LDLIBS+= -luuid
    1.32 +endif
    1.33 +
    1.34 +ifeq ($(OPENPGP),SEQUOIA)
    1.35 +    LDFLAGS+= $(SEQUOIA_LDFLAGS)
    1.36 +    LDLIBS+= $(SEQUOIA_LIB)
    1.37 +    CXXFLAGS+= $(SEQUOIA_CFLAGS) -DUSE_SEQUOIA
    1.38 +    INC_FLAGS+= $(SEQUOIA_INC)
    1.39 +endif
    1.40 +
    1.41 +ifdef SQLITE3_FROM_OS
    1.42 +    LDLIBS+= -lsqlite3
    1.43 +endif
    1.44 +
    1.45 +ifeq ($(OPENPGP),GPG)
    1.46 +    #LDLIBS+= -lgpgme
    1.47 +else ifeq ($(OPENPGP),NETPGP)
    1.48 +    LDLIBS+= -lnetpgp
    1.49 +    ifeq ($(BUILD_FOR),Linux)
    1.50 +        LDLIBS+= -ltre
    1.51 +    endif
    1.52 +endif
    1.53 +
    1.54 +CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
    1.55 +
    1.56 +# FIXME Possibly missing incdirs: ASN1C_INC
    1.57 +CXXFLAGS+= -I./include -I../sync $(CPPUNIT_INC) $(INC_FLAGS) -Wno-deprecated
    1.58 +
    1.59 +ifeq ($(OPENPGP),GPG)
    1.60 +    CXXFLAGS+= -DUSE_GPG $(GPGME_INC)
    1.61 +else ifeq ($(OPENPGP),NETPGP)
    1.62 +    CXXFLAGS+= -DUSE_NETPGP $(NETPGP_INC)
    1.63 +endif
    1.64 +
    1.65 +EXTRA_LIB_PATHS=.:../src:
    1.66 +ifdef ETPAN_LIB
    1.67 +    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
    1.68 +endif
    1.69 +ifdef GPGME_LIB
    1.70 +    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
    1.71 +endif
    1.72 +ifdef NETPGP_LIB
    1.73 +    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
    1.74 +endif
    1.75 +ifdef CPPUNIT_LIB
    1.76 +    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(CPPUNIT_LIB)):
    1.77 +endif
    1.78 +
    1.79 +# Remove trailing ':'
    1.80 +EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
    1.81 +
    1.82 +ifeq ($(BUILD_FOR),Darwin)
    1.83 +    LIBPATH=DYLD_LIBRARY_PATH
    1.84 +else
    1.85 +    LIBPATH=LD_LIBRARY_PATH
    1.86 +endif
    1.87 +
    1.88 +# FIXME: this forces a path on execution which overrides system paths for
    1.89 +#        libraries like iconv and causes runtime errors.
    1.90 +#TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS)
    1.91 +TEST_CMD_PFX=
    1.92 +
    1.93 +.PHONY: all clean test
    1.94 +
    1.95 +all:
    1.96 +	make $(TARGET)
    1.97 +
    1.98 +%.d: %.cc
    1.99 +	$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
   1.100 +
   1.101 +$(TARGET): $(OBJS) gtest-all.o gtest_main.o
   1.102 +#	$(LINK.cc) $(OBJS) $(LOADLIBES) $(LDLIBS) -o $@
   1.103 +	${CXX} ${LDFLAGS} -L${PREFIX}/lib -o $@ $^ -lpEpEngine $(LDLIBS)
   1.104 +
   1.105 +gtest-all.o: $(GTEST_DIR)/src/gtest-all.cc
   1.106 +	${CXX} ${CXXFLAGS} $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -isystem $(GTEST_DIR)/include -o $@ -c $<
   1.107 +
   1.108 +gtest_main.o: $(GTEST_DIR)/src/gtest_main.cc
   1.109 +	${CXX} ${CXXFLAGS} $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -isystem $(GTEST_DIR)/include -o $@ -c $<
   1.110 +
   1.111 +test: all
   1.112 +	$(TEST_CMD_PFX) $(TEST_DEBUGGER) ./$(TARGET)
   1.113 +
   1.114 +clean:
   1.115 +	$(RM) $(TARGET) $(TARGET).o $(TARGET).d $(OBJS) $(notdir $(basename $(OBJS))) $(DEPS)
   1.116 +
   1.117 +# If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
   1.118 +ifneq ($(MAKECMDGOALS),clean)
   1.119 +    -include $(DEPS)
   1.120 +endif