# How do I determine the default bit architecture that cmake selects in windows

**URL:** https://discourse.cmake.org/t/how-do-i-determine-the-default-bit-architecture-that-cmake-selects-in-windows/6324
**Category:** Usage
**Tags:** os:windows
**Created:** [August 23, 2022, 7:25pm UTC](https://discourse.cmake.org/t/how-do-i-determine-the-default-bit-architecture-that-cmake-selects-in-windows/6324 "2022-08-23T19:25:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![JRR](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@JRR](https://discourse.cmake.org/u/JRR)
#### Post date: [August 23, 2022, 7:25pm UTC](https://discourse.cmake.org/t/how-do-i-determine-the-default-bit-architecture-that-cmake-selects-in-windows/6324/1 "2022-08-23T19:25:34Z")

</div>

How do I determine the default bit architecture that cmake selects in windows?

I thought I could check the `CMAKE_GENERATOR` and/or `CMAKE_GENERATOR_PLATFORM` but this information doesn’t seem to be consistent.

For example:

If I invoke

```auto
cmake . -Bfoo -A Win32
...
-- CMAKE_GENERATOR="Visual Studio 17 2022"
-- CMAKE_GENERATOR_PLATFORM="Win32"
...
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x86/cl.exe - skipped

```

This works as I expected, generating a 32B solution file and prduct.

* * *

If I invoke

```auto
cmake . -Bfoo -A Win64
...
-- CMAKE_GENERATOR="Visual Studio 17 2022"
-- CMAKE_GENERATOR_PLATFORM="x64"
...
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped

```

this also wroks as expected, giving me a 64B solution.

* * *

However, if I do not specify a -A value the information is unexpected/inconsistatn

```auto
cmake . -Bfoo
-- CMAKE_GENERATOR="Visual Studio 17 2022"
-- CMAKE_GENERATOR_PLATFORM=""
...
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped

```

The `CMAKE_GENERATOR_PLATFORM` is unset so it’s unclear if this is 32B or 64B, but then the working C compiler check shows it’s 64B.

And I don’t see a way for my CMake file to be able to detemine what my bit architecture is in this scenario.

* * *

For my environment I have:

- cmake version 3.23.1
- visual studio 2015
- visual studio 2017
- visual studio 2019
- visual studio 2022

Yes, 4 versions of visual studio installed.

* * *

To add more to this riddle if I run on a machine with _ **only** _ VS2017 installed it seems to default to a 32B compilation

```auto
cmake . -Bfoo
...
-- CMAKE_GENERATOR="Visual Studio 15 2017"
-- CMAKE_GENERATOR_PLATFORM=""
...
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe - skipped

```

---

<div class="post-metadata">

### Author: ![McMartin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mcmartin/32/150_2.png) [@McMartin](https://discourse.cmake.org/u/McMartin)
#### Post date: [August 23, 2022, 8:05pm UTC](https://discourse.cmake.org/t/how-do-i-determine-the-default-bit-architecture-that-cmake-selects-in-windows/6324/2 "2022-08-23T20:05:06Z")

</div>

In [GitHub - McMartin/FRUT: Building JUCE projects using CMake made easy](https://github.com/McMartin/FRUT), I use

```auto
    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
      set(is_x64 TRUE)
    else()
      set(is_x64 FALSE)
    endif()

```
