cmake: --build improve detection of no build dir

Fixes #24157
4 files changed