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 ;
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.