[build2] Execute a test of a library with a macro enabled

artur.brzozowski artur.brzozowski at protonmail.com
Fri Nov 22 00:18:36 UTC 2024


Hi,

I am trying out build2 and I have to say the first impression is that of a very
elegant tool.

In my test project, I put a small header-only library that I store in a
directory with the canonical library project structure that I instantiated with

`bdep new`, roughly like this:
``` text
libsomething/
├── build/
├── libsomething/
│ ├── something.hxx
│ ├── export.hxx
│ ├── version.hxx.in
│ └── buildfile
├── tests/
│ ├── basics/
│ │ ├── driver.cxx
│ │ └── buildfile
│ └── ...
├── buildfile
└── ...
```

Libsomething has some conditional compilation done with a preprocessor macro
(say, `#ifdef TRACE`) in "something.hxx". I want to have TRACE defined for
libsomething when I run `b test`.

``` shell
$ cat libsomething/tests/basics/buildfile
import libs = libsomething%lib{something}

cxx.poptions += -DTRACE ## ADDED

exe{driver}: {hxx ixx txx cxx}{**} $libs
```

Simply adding the `cxx.poptions`, like above, does not seem to enable TRACE for

libsomething for testing.
I have been jumping all over the documentation for the past two hours with
little success. Any hints for what is the idiomatic build2 way to have a test
driver build/link a library in a case like mine?

Best regards,
Artur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.build2.org/archives/users/attachments/20241122/29a09d2c/attachment.html>


More information about the users mailing list