Is there a way to check available CMake generators? Some argument to query it from CMake? I cannot find a way to do this. I mean generators that are actually available and will successfully configure projects. For example I’d like to get true for Visual Studio 15 2017 only if VS2017 is installed.
I tried to workaround by just calling cmake -G <generator_name> and parsing output to find “CMake Error: Could not create named generator” message. This works fine on Linux. I don’t even have to create CMakeLists.txt, the response is pretty fast. The problem with this approach is on Windows. For some reason I have to create CMakeLists.txt, otherwise it won’t check the availability of generator. And generating project files take a really long time - about 3 seconds. Too long for checking that many generators.
I tried cmake -E capabilities, but it doesn’t provide information of what’s actually available on current system. Only general metadata.
On the current platform, meaning OS but not on the current machine. I have VS2019 installed and no other version. It should give me true for VS2019 and false for VS2017. A portion of generators array: