0

I want to conditionally use a library (with alternatives) for targets. I don't want to add conditions such as <usefoo>yes:<library>foo everywhere but prefer to create a propagated feature. However, b2 generates errors for the following jam.

import feature ;

feature.feature usefoo : yes : propagated composite optional ;
feature.compose <usefoo>yes : <library>foo ;

lib foo : : : : <include>foo <define>USE_FOO ;
lib foo : : <toolset>gcc-10 : : <include>foo_gcc10 <define>USE_FOO ;

lib bar ;
# Undesirable because there may be lots of bars.
# lib bar : : <usefoo>yes:<library>foo ;

exe test1 : test.cc : <library>bar ;
exe test2 : test.cc : <usefoo>yes <library>bar ;
error: Recursion in main target references
error: the following target are being built currently:
error: ./test2 ./bar ./foo ./foo

I cannot put requirements of foo in <usefoo>yes, either. It seems that feature.compose does not accept conditional requirements. What is the correct way to do this?

0 Answers0