A CMake module that does this could be developed independently. If that works out well, upstreaming it could be considered.