Change lib's sources depending on conditional requirements in a factorized way using boost build/b2/bjam

55 views Asked by At

I have a lib target that needs different (additional) libraries on some OSes.

I would like to do something like:

lib MyLib : $(SOURCES) $(COMMON_LIBS) <target-os>windows:$(WINDOWS_LIBS) ;

but that returns error: properties found in the 'sources' parameter for ./MyLib I think it's because you cannot uses conditional properties there.

Or maybe using alternatives:

lib MyLib : $(SOURCES) $(COMMON_LIBS) ;

lib MyLib : $(SOURCES) $(COMMON_LIBS) $(WINDOWS_LIBS)
          : <target-os>windows
          ;

well that would works but with a lot of redundancy (and this example is not that complex) and I would like to factorize it.

How to factorize this ?

1

There are 1 answers

0
Gabriel Devillers On

Try to use alias:

alias os_libs : $(WINDOWS_LIBS) : requirements <target-os>windows ;
alias os_libs : ; # no additional libs for other OSes

lib MyLib : $(SOURCES) $(COMMON_LIBS) os_libs ;