A C++11 library to easily handle code paths for Debug and Release at compile time.
// C++11 version should be easily handled by basically every serious compiler
if (BuildMode::isRelease)
{
// COMPILER SHOULD STRIP WHEN NOT IN RELEASE
...
}
if (BuildMode::isDebug)
{
// COMPILER SHOULD STRIP WHEN NOT IN DEBUG
...
}
// C++17 version guarantees compile-time evaluation
if constexpr (BuildMode::isRelease)
{
// CODE STRIPPED WHEN NOT IN RELEASE
...
}
if constexpr (BuildMode::isDebug)
{
// CODE STRIPPED WHEN NOT IN DEBUG
...
}
Add these lines to your CMakeLists.txt:
ADD_SUBDIRECTORY (relative_path_to/buildmode)
TARGET_LINK_LIBRARIES (your_target_name buildmode)
If you wish to test the library on your machine, just launch:
./tests/setup.sh
./tests/build.sh
./tests/run.sh
Note that this library's CMakeLists.txt won't compile testing sources unless BUILD_TESTING=ON
: use this feature to choose when to spend time building tests and when not.
This library is available to anybody free of charge, under the terms of MIT License (see LICENSE).