Compiling the Boost.Build conditional library for each project

I have a C ++ project that is created using Boost.Build. The project consists of 3 subprojects.

    . [root]
    \ - source
        \ - common
            \ - config
                \ - config.cpp
        \ - project_1
            \ - Jamfile.jam
        \ - project_2
            \ - Jamfile.jam
        \ - project_3
            \ - Jamfile.jam
    \ - Jamroot.jam

Jamroot.jam:

    project my_project 
        : requirements 
          multi 
          debug: DEBUG
        : default-build
          static
        : build-dir bin
        ;

    alias project_1: source / project_1;
    alias project_2: source / project_2;
    alias project_3: source / project_3;

    install dist: project_1 project_2 project_3
        : on exe
        ;

Each project has Jamfile.jam in accordance with this template:

    project project_N
      : requirements 
          CONFIG_DEFINE_1=
          CONFIG_DEFINE_2=
      ; 

    lib config : [ glob ../common/config/*.cpp ] ;

    exe project_N 
        : [ glob *.cpp ]  config
        :  
        ;

config.cpp CONFIG_DEFINE_1 CONFIG_DEFINE_2 ( ), config.

, config , , . , , - - project_N config. , ?

+3
1

, .

, boost build.or . cpp .

, , , config, ...

, , - , .

. LargeFunction.cpp

 #if CONFIG_DEFINE_1
     void VeryLargeFunction() {
        ...
     }
 #elif CONFIG_DEFINE_2
     void VeryLargeFunction() {
        ...
     }
 #endif

, VeryLargeFunction, DEFINE_1, , DEFINE_2, , .

 #if CONFIG_DEFINE_1
    #include "definitionFileFor1"
 #elif CONFIG_DEFINE_2
    #include "definitionFileFor2"
 #endif

, , "" , .

, i.s.o. .

, , , , .

+1

Source: https://habr.com/ru/post/1714628/


All Articles