Search code examples
cmakec++17cmake-modulescmake-formatcmake-js

Cannot generate 32 bit configuration for Visual Studio 2019 with host=x86 or -A Win32


I am trying to configure cmake to build for 32bit and 64bit separately...

So far 64bit is easy as I just need to add -A x64

cmake -G "Visual Studio 16 2019" -A x64

But I am not able to set 32bit arch. Official documentation suggest -A Win32 or -T host=x86
https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2016%202019.html
Even with them I am not able to set x86 host

What I have tried:

cmake -G "Visual Studio 16 2019" -DCMAKE_GENERATOR_PLATFORM=x86

cmake -G "Visual Studio 16 2019" -A Win32

cmake -G "Visual Studio 16 2019" -A Win32 -T host=x86

cmake -G "Visual Studio 16 2019" -A Win32 host=x86

Nothing is working, Here is log I am getting all the time...

-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.25.28612.0
-- The CXX compiler identification is MSVC 19.25.28612.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe

Solution

  • It was related to node-js...
    I just wrote generator with Win32 and passed arch in node-js part of package.json

    npm config set cmake_js_arch ia32 && cmake-js compile cmake -G \"Visual Studio 16 2019\" -A Win32
    

    I am using cmake to build c++ code DLL for a node project, So it is necessary to run it from command line.

    cmake-js is a node package for Cmake and that command is telling cmake-js to set arch ia32