c++modules: Persist CMAKE_CXX_STDLIB_MODULES_JSON

And change checks to look for a value rather than definition. This fix
keeps the same set of test cases in `RunCMake.CXXModules` selected as
before.

Fixes: #27589
4 files changed