[build] set _FORTIFY_SOURCE=2 for -O* builds only
Summary:
currently building with -DCMAKE_BUILD_TYPE=Debug floods the cli
with warnings about how _FORTIFY_SOURCE=2 requires optimization.
Our Debug build compiles with -O0 because apparently -Og drops some
symbols, so this flag should only be set for Release, RelWithDebInfo
and RelMinSize
h/t @Fabien for help with the CMake generator expressions
Test Plan:
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug ninja
see no warnings that _FORTIFY_SOURCE requires compiling with
optimization
cmake .. -GNinja -DCMAKE_BUILD_TYPE=[the other three] ninja -nv
see the correct flags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 set
in the dry run output
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D6237