Skip to content

A C++11 library to easily handle code paths for Debug and Release at compile time.

License

Notifications You must be signed in to change notification settings

MuAlphaOmegaEpsilon/buildmode

Repository files navigation

BuildMode

A C++11 library to easily handle code paths for Debug and Release at compile time.

Travis CI MIT GitHub GitHub repo size in bytes

SonarCloud

Quality Gate Status Maintainability Rating Security Rating Reliability Rating Coverage Bugs Code Smells Vulnerabilities Technical Debt Lines of Code

How to use

// 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
	...
}

CMake integration

Add these lines to your CMakeLists.txt:

ADD_SUBDIRECTORY (relative_path_to/buildmode)
TARGET_LINK_LIBRARIES (your_target_name buildmode)

Library testing

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.

License

This library is available to anybody free of charge, under the terms of MIT License (see LICENSE).