0

I created a default build2 executable,

bdep new -t exe -l c++,cpp hello

edited the hello.cpp,

#include <iostream>

int main (int argc, char* argv[]) {
  using namespace std;

#ifdef NDEBUG
  cout << "Debug: off\n";
#else
  cout << "Debug: on\n";
#endif
}

created two configs (debug and release),

cd hello/
bdep config create ../hello-debug @debug cc config.cxx=g++ config.cxx.coptions=-g
bdep config create ../hello-release @releasecc config.cxx=g++ config.cxx.coptions=-O3

and initialized both.

bdep init @debug @release

I then run

bdep update @debug

and when I run the program I get Debug: on.

But now I want to build the executable in release mode

bdep update @release

but I still get the Debug: on output.

How do I switch configurations in build2

Symlink
  • 383
  • 2
  • 12

1 Answers1

1

NDEBUG is a standardized preprocessor flag which you are not adding to 'release' configuration.

This can be done by adding config.cxx.poptions=-DNDEBUG to your configuration.

bdep config create ../hello-release config.cxx.poptions=-DNDEBUG ..

See more info here https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml