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
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Fabien created this revision.Mar 5 2019, 16:40
Herald added a reviewer: Restricted Project. · View Herald TranscriptMar 5 2019, 16:40
Herald added a subscriber: schancel. · View Herald Transcript
Fabien updated this revision to Diff 7603.Mar 5 2019, 16:57

Avoid parsing CMAKE_C/CXX_FLAGS_BUILD_TYPE if build type is not set

Fabien updated this revision to Diff 7604.Mar 5 2019, 17:07

Move some orphaned comment

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