Fix building with cmake 4 by backporting two commits: - b354c009a6 - 51ae8e922b
b354c009a6
51ae8e922b