Domanda

I have a C++ project that employs unit testing via CppUnit and has the following directory structure:

.
|-- bin
|   `-- tests
|-- src
|   `-- include
`-- test
    `-- include

In the top-level directory resides my Makefile.am file. I would like to use a non-recursive Makefile. I have been able to build the executable of my project in the bin folder and the tests for make check in the bin/tests folder.

The problem is the following: When make check runs the tests, the current working directory is still the top-level directory (i.e., the directory from which I ran make check). Is it possible to change the working directory specifically for the test suites?

The relevant piece in my Makefile.am file is the following:

$(TESTDIR)=./bin/tests
check_PROGRAMS = $(TESTS)
TESTS = $(TESTDIR)clocktest

__TESTDIR_clocktest_SOURCES = test/clocktest.cpp test/unittest.cpp src/clock.cpp
__TESTDIR_clocktest_CPPFLAGS = $(AM_CPPFLAGS) $(CPPUNIT_CFLAGS) $(TESTCPPFLAGS)
__TESTDIR_clocktest_LDADD = $(CPPUNIT_LIBS)
È stato utile?

Soluzione

From make --help:

-C DIRECTORY, --directory=DIRECTORY
                            Change to DIRECTORY before doing anything.

I think that should do what you're looking for.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top