I use Google Test in my C++ project. I build the target either for my i386 virtual machine or for the real ARMEL target. What I would like to do is have my Makefile link in the correct google test .a file for the right architecture, depending on the host system. E.g. if I am running the test target from my i386 VM, I'd like to link in the i386 built libgtest.a, and ditto when building on my ARMEL system. How do I do that? I do not cross compile the ARM build, I build it on the ARM target hardware itself. I don't really want to build libtest.a from scratch as it's pretty slow to build.
My Makefile is:
CC = g++-4.7
CXX := $(CC)
SVNDEV := -D'SVN_REV="$(shell svnversion -n .)"'
CFLAGS += -Os -Wall -Wno-write-strings $(SVNDEV) -Iinclude -I/usr/include/c++/4.7 -Llib
CXXFLAGS += --std=c++11 -D_GLIBCXX_USE_NANOSLEEP $(CFLAGS)
TARGET = connectionmanager
LIBS = -lzmq -ljansson -lpthread
objects = systeminterface.o linuxsysteminterface.o connectionmanagerutils.o connectionmanagerexception.o logger.o jsoninterface.o configuration.o diagnosticslogger.o serial.o \
modemstrategy.o lisac200modemstrategy.o maestrom1003gmodemstrategy.o
test_objects = mocksysteminterface.o mockmodemstrategy.o test/connectionmanagertest.o test/connectionmanagerutiltest.o test/jsoninterfacetest.o test/gtest_main.o
$(TARGET): connectionmanager.o $(objects) $(LIBS)
.PHONY: clean all test
all: $(TARGET)
cmmain.o: connectionmanager.cpp
$(CXX) -DUNIT_TESTING $(CPPFLAGS) $(CXXFLAGS) -c connectionmanager.cpp -o cmmain.o
connectionmanagertest : cmmain.o $(objects) $(test_objects) lib/libgtest.a $(LIBS)
$(CXX) -DUNIT_TESTING $(CPPFLAGS) $(CXXFLAGS) $(LIBS) lib/libgtest.a $^ -o $@
test: connectionmanagertest
./connectionmanagertest
clean:
rm -f $(TARGET)
rm -f $(objects)
rm -f $(test_objects)
rm -f connectionmanager.o
rm -f cmmain.o
rm -f $(test_objects)