开发者

Share files with unit tests using autotools

开发者 https://www.devze.com 2023-01-24 13:42 出处:网络
I have a project using autoconf and automake with following structure: / src/ class.h class.cpp test/ class_unittest.cpp

I have a project using autoconf and automake with following structure:

  • /
    • src/
      • class.h
      • class.cpp
    • test/
      • class_unittest.cpp

In class_unittest.cpp I include class.h in the source file and on compile also the class.cpp file. In automake config for test I add ../src as a new include path in AM_CPPFLAGS = -I../src/ definition and refer to the class.cpp relatively in SOURCES definition.

It works great when I'm building the software from the root directory, but if I try to do a VPATH build by creating a dir foo in root and in the dir call ../config开发者_开发问答ure && make I will get missing header class.h errors when trying to compile class_unittest.cpp.

So how do I share the header for testing to avoid this problem?


You can use the srcdir variable to refer to the equivalent source directory in a VPATH build.

AM_CPPFLAGS = -I$(srcdir)/../src
0

精彩评论

暂无评论...
验证码 换一张
取 消