#define in Boost Jamfiles
Asked Answered
L

2

9

This is my project structure:

MainFolder
  - Jamroot.jam
  - AnotherFolder
      - libFolder
          - Jamfile.jam
          - cpp files

I have an #ifdef in one of the cpp files. Example:

#ifdef SOMEVALUE
  Code
#endif

I need to compile the cpp files with #define in Jamfile. Since, I am having two types of executables (one with #define and one without) I need to do this in Jamfile itself and not cpp code.

I have tried the following, which does not work (unable to find definitions inside #ifdef #endif block):

lib libname : [ glob *.cpp ] : <link>static : <define>SOMEVALUE ;
Logotype answered 3/10, 2016 at 7:56 Comment(0)
I
6

Adding a preprocessor definition uses the "define" feature as you've seen given your example. But the feature needs to be specified as a requirement of the target definition. The requirements are specified as the third argument of the target definition not the fourth as in your use case. Hence instead of:

lib
  libname # main-target-name
  : [ glob *.cpp ] # sources
  : <link>static # requirements
  : <define>SOMEVALUE # default-build
  ;

You need to move the "<define>" from the usage requirements to the target requirements:

lib
  libname # main-target-name
  : [ glob *.cpp ] # sources
  : <link>static <define>SOMEVALUE # requirements
  : # default-build
  : # usage-requirements
  ;

You can find what all the arguments to the target definition are here.

Icy answered 6/10, 2016 at 1:32 Comment(0)
S
0

In mine earlier project we use to have different compilation for debug mode - which apart from adding debug symbols use to print many usefull values during run time. The way it was done

#ifdef DEBUG
/* Piece of code here*/
#endif

and while compilation via GCC with the -DDEBUG

Samellasameness answered 5/10, 2016 at 10:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.