如何为 CxxTest 编写 automake 文件?

How do I write an automake file for CxxTest?

CxxTest documentation 有一个生成和运行单元测试的 Makefile 示例。我如何为 automake (Makefile.am) 做同样的事情?

我通过在 tests 目录中创建此 Makefile.am 来完成此操作,其中所有测试代码为:

check_PROGRAMS = tests

EXTRA_tests_SOURCES  = test_example1.hpp
EXTRA_tests_SOURCES += test_example2.hpp

tests_SOURCES = runner-autogen.cpp

BUILT_SOURCES = runner-autogen.cpp
MAINTAINERCLEANFILES = runner-autogen.cpp

runner-autogen.cpp: $(EXTRA_tests_SOURCES)
    /path/to/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o $@ $<

它所做的是将 runner-autogen.cpp 编译成测试程序(称为 tests)并 运行 将其与 make check 相结合。如果列出的任何 .hpp 文件发生更改,它将 运行 cxxtestgen 重新创建 runner-autogen.cpp.

因为 runner-autogen.cpp 被列为源文件,它将被 make dist 包含在发布存档中,所以用户不需要 cxxtest 存在,除非他们修改其中一个 .hpp 个文件。