depends: CMake invocation cleanup
Summary:
This is a backport of core#19685, core#20046 and core#25046
(with a contribution from https://github.com/bitcoin/bitcoin/pull/18677/commits/603fd6a2e708c04ef6c9880f89d0a4cbaa6fc7c5#diff-04ed828869a0888df31a01e355417d994dcf2f3a0b3a35b82c7510ebcd294943)
Note the use of ninja (introduced in some mk files in D865 and D13222)
Test Plan: CI builds (gitian)
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D13506