[CMAKE] Improve link flag compiler support detection
Summary:
The add_linker_flag method is able to prevent from introducing link
time errors, but not warnings. This may cause some noise with clang,
which will issue a -Wunused-command-line-argument warning when an
unknown linker flag is set (then ignore it).
This diff promotes the warning to error so the unused link flag will not
be set.
Test Plan:
mkdir buildcmake_osx && cd buildcmake_osx cmake -GNinja .. -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/OSX.cmake ninja
Check the following warning disappeared with this patch:
clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Differential Revision: https://reviews.bitcoinabc.org/D3792