Why `msvc_x86` toolset, in Visual Studio CMake Settings, passes `-A x64` to CMake instead of `-A Win32`?

Bassem Selim 1 Reputation point
2022-03-13T09:53:00.11+00:00

Hi,
I'm using Visual Studio 2022 to build a project using CMake.
It builds successfully for x86_64 architecture.

However, when I did the following:

  • Added CMake configuration x86-Release , from CMake Settings
  • Selected Release in Configuration Type
  • Left msvc_x86 selected as a Toolset
  • Selected Visual Studio 17 2022 Win64
  • Ran from the menu: Project -> Configure Cache

I got the configuration done for x86_64 instead of x86:

Command line: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Visual Studio 17 2022" -A x64 -DCMAKE_CONFIGURATION_TYPES:STRING="Release" -DCMAKE_INSTALL_PREFIX:PATH="F:\Work\conan\crono_pci_windows\tools\out\install\x86-Release" "F:\Work\conan\crono_pci_windows\tools" 2>&1"
1>

While I expected the command line to have -A Win32 instead.
Any idea how to set it to build for x86 (-A Win32)?
Thanks,
Bassem

Developer technologies | C++
{count} votes

1 answer

Sort by: Most helpful
  1. Bassem Selim 1 Reputation point
    2022-03-20T11:16:26.897+00:00

    I found a solution, it's by selecting a 32-bit CMake generator: from the list of available generators, e.g. Visual Studio 17 2022 instead of Visual Studio 17 2022 Win64.

    Selecting x86-Release doesn't seem to be enough.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.