[CMAKE] Refactor the AddCompilerFlags facilities
Summary:
This adds a bit of code factorization by adding a pair of functions to
add and remove flags to target variable.
There is no behavior change.
Test Plan:
mkdir buildcmake && cd buildcmake cmake -GNinja .. ninja check
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Differential Revision: https://reviews.bitcoinabc.org/D3802