[cmake] Improve EVP_MD_CTX_new detection
Summary:
The CMAKE_REQUIRED_LIBRARIES accept imported targets, so use that instead
of the old way using variables.
This has the benefit of pulling all the transitive libraries as well
which fixes the detection with Openssl 1.1.1.
Test Plan:
With Openssl 1.1.1 in the depends:
cmake -GNinja .. -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/Linux64.cmake
Detection failed before the patch, and works after.
Reviewers: #bitcoin_abc, PiRK
Reviewed By: #bitcoin_abc, PiRK
Subscribers: PiRK
Differential Revision: https://reviews.bitcoinabc.org/D13864