HomePhabricator

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

Description

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

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.

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: teamcity, schancel

Differential Revision: https://reviews.bitcoinabc.org/D2651

Details

Provenance
FabienAuthored on Mar 4 2019, 20:24
FabienPushed on Mar 6 2019, 07:49
Reviewer
Restricted Project
Differential Revision
D2651: [CMAKE] Remove the -DNDEBUG flag from the release build configurations
Parents
rABC3f0dc5337ceb: Fix FreeBSD build by including utilstrencodings.h
Branches
Unknown
Tags
Unknown