VPATH

58 views
Skip to first unread message

Ryan Hartlage

unread,
May 9, 2013, 8:08:40 AM5/9/13
to cppu...@googlegroups.com
I'm having a small issue with CppUTest on a project I'm working on.  The directories in my project are laid out sort of like this:

/root
   /src
      /src1
      /src2
/Testing
   /mocks
   /objs
   /tests
   Makefile

Object files for my sources under test get dumped in weird places (ie: not objs) because the src directories are 'above' the makefile.  This isn't a huge problem, but it is a wart I'd like to remove.  I dug through MakefileWorker.mk and saw that enabling VPATH is designed for just this situation.  The issue is that when I enable VPATH with CPPUTEST_USE_VPATH = Y the make fails right away.  The actual make output is:

make: *** No rule to make target `objs/applcommon/DataSource_Mock.o', needed by `tests/applcommon_tests'.  Stop.

It seems to fail immediately on building the first *.o but I haven't been able to parse the makefile to figure out exactly why (over my head).

My source/test/include directories are configured as follows:

SRC_DIRS = \
   ../DataStructures/DataSource/ \
   ../DataStructures/PubSubDataSource/ \
   ../DataStructures/LinkedList/ \
   ../Utilities/

TEST_SRC_DIRS = \
   mocks/ \
   doubles/ \
   utils/ \
   tests/ \
   tests/DataStructures/DataSource/ \
   tests/LinkedList/ \
   tests/DataStructures/PubSubDataSource/

INCLUDE_DIRS = \
   $(CPPUTEST_HOME)/include/ \
   $(SRC_DIRS) \
   ../Utilities/ \
   mocks/ \
   doubles/ \
   utils/

FYI I'm using OS X with Apple's GCC toolchain and command line tools.

Does anyone see any red flags here?  Am I misunderstanding the use of the VPATH flag?  Is there any other information that you need?  Any help you can provide is greatly appreciated.

Thanks in advance!

Bas Vodde

unread,
May 10, 2013, 6:20:07 AM5/10/13
to cppu...@googlegroups.com

Hi Ryan,

It is probably best to switch to either autotools or cmake.

If you use autotools, you can build in the following way (get the latest zip).

- mkdir my_build
- cd my_build
- ../configure
- make

It will put all the object files under my_build, not cluttering your directories anymore.

If you use cmake, it is similar:

- mkdir my_build
- cd my_build
- cmake ..
- make

Both should work.

Does that help?

Thanks!

Bas
> --
> You received this message because you are subscribed to the Google Groups "cpputest" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to cpputest+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Ryan Hartlage

unread,
May 10, 2013, 8:05:16 AM5/10/13
to cppu...@googlegroups.com
Thanks for your prompt response, Bas.  I will try that out today.

Ryan

ferdi....@gmail.com

unread,
May 16, 2013, 2:31:57 AM5/16/13
to cppu...@googlegroups.com
Hi Ryan

I have a similar problem, and a simple solution that works for me. My layout is similar to yours:
|-- src
|-- testCppUTest
|   |-- AllTests.cpp
|   |-- Makefile

|   |-- objs
|   |-- test_doubles

To get the generated objects to reside in the /objs, I have this in my Makefile:
CPPUTEST_OBJS_DIR = objs/testCppUTest

Now (assuming you use a relative path ../src to your sources) your CUT objects are placed in obs/testCppUTest/../src, which is equivalent to:
obs/src

Ferdi

Ryan Hartlage

unread,
May 16, 2013, 3:23:25 PM5/16/13
to cppu...@googlegroups.com
Thanks Ferdi!
Reply all
Reply to author
Forward
0 new messages