I would like to compute a tag so it would contain the current version of the library being built. The version is in a C++ header, so I thought I could:

i) build an executable that prints the version
ii) run it
iii) use the output to determine the tag

The following bjam file will print the version correctly the *second* time it is run. The first time it says "sh: tmp/showversion: No such file or directory", then proceeds to build and install tmp/showversion. What am I doing wrong please? Many thanks.

exe showversion : showversion.cpp : <include>$(BOOST_INCLUDE) ;

install tmp : showversion ;

DEPENDS version : tmp/showversion

rule version ( )
{
    return [ SHELL tmp/showversion ] ;
}

echo [ version ] ;