[CMAKE] Add a check_linker_flag function
Summary:
Separate the check of the flag from its addition. This has the
beneficial side-effect to discard the need for removing the Werror
flag from CMAKE_REQUIRED_FLAGS, since its scope is now reduced.
There is no change in behavior.
Test Plan:
ninja check
Run the Gitian builds
Reviewers: #bitcoin_abc, deadalnix, jasonbcox
Reviewed By: #bitcoin_abc, deadalnix, jasonbcox
Subscribers: jasonbcox
Differential Revision: https://reviews.bitcoinabc.org/D4961