Search code examples
bjam

How to change include path using bjam


I have the following directory structure:

  • APPDIR/
  • APPDIR/APPHDRS (has *.h)
  • APPDIR/APPLIBSRCS (has *.cpp need to make a library, say libtest.a)
  • APPDIR/APPMAIN (has main.cpp that will compile if g++ gets args -I $HOME/APPINSTALLDIR and -L $HOME/APPINSTALLDIR/LIB)

I got headers to be installed by adding in APPDIR/Jamroot:

local headers = [ path.glob-tree $HOME/APPDIR : *.h ] ;

install headers                   
    : $(headers)
    : <location>$HOME/APPINSTALLDIR <install-source-root>$HOME/APPDIR
;

Could someone please assist me in the Jamfiles for the libtest.a and main.cpp?


Solution

  • My current solution : APPDIR/Jamroot.jam :

    path-constant PROJECT_ROOT : . ;
    path-constant BOOST_INCLUDE_BASE : /apps/boost/include ;
    path-constant BOOST_LIB_BASE : /apps/boost/lib ;
    
    local headers = [ path.glob-tree $(PROJECT_ROOT) : *.hpp ] ;
    
    
    install headers
        : $(headers)
        : <location>$(PROJECT_ROOT)_install <install-source-root>$(PROJECT_ROOT)
        ;
    
    project basetrade
        : requirements <include>$(PROJECT_ROOT)_install
                       <include>$(BOOST_INCLUDE_BASE)
          <variant>release:<cxxflags>-O2
          <variant>debug:<inlining>off
          <variant>debug:<debug-symbols>on
          <variant>debug:<optimization>off
          <variant>debug:<warnings>on
        ;
    
    build-project APPLIBSRCS ;
    build-project APPMAIN ;
    

    APPLIBSRCS/Jamfile.jam:

    project : usage-requirements <include>$(PROJECT_ROOT)_install ;
    lib Utils : [ glob *.cpp ] : <link>static ;
    install libUtils
      : Utils
      : <install-type>LIB
        <variant>release:<location>"$(PROJECT_ROOT)_install/lib"
        <variant>debug:<location>"$(PROJECT_ROOT)_install/libdebug"
      : release debug
      ;
    

    APPMAIN/Jamfile.jam:

    project : usage-requirements <include>$(PROJECT_ROOT)_install ;
    use-project /PLIBSRCS : ../APPLIBSRCS ;
    
    exe tradeexec 
        : main.cpp
          /PLIBSRCS//libUtils 
        :
        : <variant>debug <variant>release 
        ;
    
    install install-bin 
        : tradeexec 
        : <variant>release:<location>"$(PROJECT_ROOT)_install/bin"
          <variant>debug:<location>"$(PROJECT_ROOT)_install/bindebug"
        : release debug
        ;