[cmake] Check if boost::test require static or dynamic linking and act accordingly
Summary: Before, dynamic linking was just assumed, which is not always correct.
Test Plan: Do a cmake build with boost compiled as a static lib.
Reviewers: #bitcoin_abc, schancel
Reviewed By: #bitcoin_abc, schancel
Subscribers: teamcity
Differential Revision: https://reviews.bitcoinabc.org/D1310