# Check available generators

**URL:** https://discourse.cmake.org/t/check-available-generators/9391
**Category:** Usage
**Created:** [November 8, 2023, 3:07pm UTC](https://discourse.cmake.org/t/check-available-generators/9391 "2023-11-08T15:07:07Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mdziuban](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/e36b37/32.png) [@mdziuban](https://discourse.cmake.org/u/mdziuban)
#### Post date: [November 8, 2023, 3:07pm UTC](https://discourse.cmake.org/t/check-available-generators/9391/1 "2023-11-08T15:07:07Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [November 8, 2023, 3:44pm UTC](https://discourse.cmake.org/t/check-available-generators/9391/2 "2023-11-08T15:44:27Z")

</div>

In contrary, `cmake -E capabilities` gives you the supported generators on the current platform. See `"generators"` array.

---

<div class="post-metadata">

### Author: ![mdziuban](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/e36b37/32.png) [@mdziuban](https://discourse.cmake.org/u/mdziuban)
#### Post date: [November 8, 2023, 3:49pm UTC](https://discourse.cmake.org/t/check-available-generators/9391/3 "2023-11-08T15:49:07Z")

</div>

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:

```auto
    {
      "extraGenerators": [],
      "name": "Visual Studio 16 2019",
      "platformSupport": true,
      "supportedPlatforms": [
        "x64",
        "Win32",
        "ARM",
        "ARM64",
        "ARM64EC"
      ],
      "toolsetSupport": true
    },
    {
      "extraGenerators": [],
      "name": "Visual Studio 15 2017 Win64",
      "platformSupport": true,
      "supportedPlatforms": [
        "x64",
        "Win32",
        "ARM",
        "ARM64"
      ],
      "toolsetSupport": true
    },

```

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [November 8, 2023, 3:59pm UTC](https://discourse.cmake.org/t/check-available-generators/9391/4 "2023-11-08T15:59:39Z")

</div>

For that purpose, you can use [vswhere](https://github.com/microsoft/vswhere).

---

<div class="post-metadata">

### Author: ![mdziuban](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/e36b37/32.png) [@mdziuban](https://discourse.cmake.org/u/mdziuban)
#### Post date: [November 10, 2023, 12:59am UTC](https://discourse.cmake.org/t/check-available-generators/9391/5 "2023-11-10T00:59:29Z")

</div>

Thanks, but this is not just about VS. I’m looking for a generic solution for all generators.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [November 18, 2023, 8:08pm UTC](https://discourse.cmake.org/t/check-available-generators/9391/6 "2023-11-18T20:08:16Z")

</div>

@brad.king ?

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [November 20, 2023, 1:34pm UTC](https://discourse.cmake.org/t/check-available-generators/9391/7 "2023-11-20T13:34:00Z")

</div>

This is also discussed in [CMake Issue 25397](https://gitlab.kitware.com/cmake/cmake/-/issues/25397). In general it is not possible to know ahead of time whether a given generator will work.
