Backport of core PR15461.
This PR is known to cause 2 issues:
- The build (native) on ARM might be broken:
- The error messages are not helpful:
None of these issues are critical.
I kept (adapted) the patch to work around the first issue. It doesn't
provide a very solid guarantee but it can't hurt.
The second issue will be fixed in a future backport.
Note that due to boost cmake update, it is now required to set
Boost_USE_STATIC_RUNTIME to ON.