如何在autotools C++中添加boost单元测试框架
How to add boost unit test framework in autotools C++
我有一个 C++ 项目,我正在尝试弄清楚如何让 autotools 在构建过程中动态包含 -lboost_unit_test_framework
标志。如果我添加它并使用它构建的 g++
手动编译,它只是在使用 autotools 设置 makefile 时缺少标志。
此外,当 运行 ./configure
它 returns:
./configure: line 3113: AX_BOOST_UNIT_TEST_FRAMEWORK: command not found
我的configure.ac:
AC_PREREQ([2.69])
AC_INIT([project], [0.1.0], [example@example.com])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CXX
# Checks for libraries.
AX_BOOST_UNIT_TEST_FRAMEWORK
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([Makefile
src/Makefile
test/Makefile])
AC_OUTPUT
我明白了,宏是未定义的,除非您从 autoconf-archive 下载它。我把它放在我的项目中 project/m4
.
另外,你必须告诉configure.ac
在哪里可以找到它们:
...
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4]) # << Add this line
# Checks for programs.
AC_PROG_CXX
...
更新:
一旦我开始工作,为了让 make check
执行测试,我必须:
将此添加到 project/test/Makefile.am
:
check_PROGRAMS = program_tests
program_tests_CPPFLAGS = -I../src/ ${BOOST_CPPFLAGS}
program_tests_LDFLAGS = ${BOOST_LDFLAGS}
program_wallet_tests_LDADD = ${BOOST_UNIT_TEST_FRAMEWORK_LIB}
program_wallet_tests_SOURCES = runner.cpp main_tests.cpp
将此行添加到主project/Makefile.am
:
TESTS = test/program_tests
我有一个 C++ 项目,我正在尝试弄清楚如何让 autotools 在构建过程中动态包含 -lboost_unit_test_framework
标志。如果我添加它并使用它构建的 g++
手动编译,它只是在使用 autotools 设置 makefile 时缺少标志。
此外,当 运行 ./configure
它 returns:
./configure: line 3113: AX_BOOST_UNIT_TEST_FRAMEWORK: command not found
我的configure.ac:
AC_PREREQ([2.69])
AC_INIT([project], [0.1.0], [example@example.com])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CXX
# Checks for libraries.
AX_BOOST_UNIT_TEST_FRAMEWORK
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([Makefile
src/Makefile
test/Makefile])
AC_OUTPUT
我明白了,宏是未定义的,除非您从 autoconf-archive 下载它。我把它放在我的项目中 project/m4
.
另外,你必须告诉configure.ac
在哪里可以找到它们:
...
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4]) # << Add this line
# Checks for programs.
AC_PROG_CXX
...
更新:
一旦我开始工作,为了让 make check
执行测试,我必须:
将此添加到
project/test/Makefile.am
:check_PROGRAMS = program_tests program_tests_CPPFLAGS = -I../src/ ${BOOST_CPPFLAGS} program_tests_LDFLAGS = ${BOOST_LDFLAGS} program_wallet_tests_LDADD = ${BOOST_UNIT_TEST_FRAMEWORK_LIB} program_wallet_tests_SOURCES = runner.cpp main_tests.cpp
将此行添加到主
project/Makefile.am
:TESTS = test/program_tests