Page MenuHomePhabricator

[CMAKE] Remove the -DNDEBUG flag from the release build configurations
ClosedPublic

Authored by Fabien on Mar 5 2019, 16:40.

Details

Summary

This removes the -DNDEBUG flag from the CFLAGS and CXXFLAGS even when
this flag is set as part of a selected build type.

For instance the RelWithDebInfo build type CXXFLAGS default to `-g -O2
-DNDEBUG`. This diffs removes the NDEBUG leading to -g -O2 being set
instead.

It completes the remove_compiler_flag macro to achieve this, and fixes
some edge cases where the macro would have fail:

  • if the flag to remove is located at the end (no trailing space)
  • if any of the *_FLAGS variable is empty or unset
Test Plan
mkdir buildcmake && cd buildcmake
cmake -GNinja .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
ninja -v

Check that the -g -O2 flags are set in the compile commands for both
CC and CXX compile lines. Ensure that the -DNDEBUG flag is never set.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Avoid parsing CMAKE_C/CXX_FLAGS_BUILD_TYPE if build type is not set

Move some orphaned comment

This revision is now accepted and ready to land.Mar 5 2019, 21:36
This revision was automatically updated to reflect the committed changes.