Boost logo

Boost-Build :

From: Motonari Ito (motonari_at_[hidden])
Date: 2005-10-11 01:36:07

Hi Elifant,

>When I build project, executable files are placed in some subdirectory
>of 'bin'. The problem is that test uses some file which is placed next
>to the source. How can I copy this file to the same directory with the
>executable, so test can find it?

I also want to know how!

I had the same situation and solved by the following hack.

In my case, the test files are located at $(TOP)/asset, where $(TOP) is
defined in Jamroot:

path-constant TOP : . ;

The basic idea is to pass the location of the test file by preprocessor
definition ( <define> property).

Here is the Jamfile for the unit test.

# $(TOP) may use '\' as a path separeter, which we cannot pass
# as <define> value. So, modify it to use '/' instead of '\'.
local path_tokens = [ regex.split $(TOP)/asset "[/\\]" ] ;
local normalized_path = [ path.join $(path_tokens) ] ;

unit-test test :
: <define>PATH_TEST_FOOTAGE=$(normalized_path)

In the test.cpp, we can refer the value of PATH_TEST_FOOTAGE by:

#define STRING(s) # s
#define XSTRING(s) STRING(s)

string testFilename = XSTRING(PATH_TEST_FOOTAGE) "/test.dat";

Hope it helps.

Motonari Ito


Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at