Your Location is: Home > Github

Cmake actions build for Windows x86

From: Luxembourg View: 3468 quotschmacher 


I have a Cmake/wxWidgets project that builds fine on my pc. I compile wxWidgets using nmake /f BUILD=release TARGET_CPU=X86 and generate the CMake project using cmake .. -G "Visual Studio 16 2019" -A Win32 -DCMAKE_CONFIGURATION_TYPES=Release.

Like I wrote, this compiles fine on my pc. When I want to build it using a github action on Windows 2019 Image I first pull wxWidgets, compile it using the above statement, generate wxWidgets using the aboce statement and trigger the build using a cmd-script containing "%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" ".\build\NaCl-Configurator.sln" /p:Configuration=Release /p:Platform=Win32 /p:PlatformTarget=x86

But when doing this I always get the following error:

  wxmsw31u_core.lib(corelib_wincmn.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86' [D:\a\abc\abc\build\abc.vcxproj]

If I switch everything to x64 it compiles fine, but I need a x86 build. Is there any system setting I'm missing?

Best answer

This is not an answer, this is a recommendation.

But after spending hours looking into your issue, I am seriously pulling my hair at the Microsoft documentation for MSBuild.

Just use Ninja. This is what we use to build our x64/x86 binaries.

You might need to learn a little bit about cmake toolchains, but at least you don't have to deal with this msbuild nonsense.

Ninja is faster, works much better with cmake, is a very tiny executable, etc.

Seriously using msbuild/visual-studio on your servers isn't worth it.

Again I apologize this isn't a direct answer to your question, if you do continue down this path I'm curious to see the answer.


What I found out though:

I will say I'm very confused about the difference between PlatformTarget and Platform. Because all the visual studio solutions I generate don't even have PlatformTarget as a property anywhere. I scanned the generated solution files and didn't see this anywhere. Granted I'm using vs2019 so maybe it's deprecated I dunno.

Prefer to expand the /p -> /property that's just good practice for your build server scripts.

Perhaps try using the platform property "x86" instead. I literally couldn't find concrete information on which was preferred/correct. Win32/x86.

And as a final guess please start printing out your compiler, and toolchain information from cmake.


How do I specify the platform for MSBuild?

Me looking at the msbuild command line, and looking at my generated visual studio solutions.

Another answer

I was using another github action to access nmake to build wxWidgets. Within this action I had to specify the architecture. So using

      - name: Preparing nmake    
        uses: ilammy/[email protected]
          arch: x86
      - name: start building wx widgtes
        run: |
          cd ${{ env.WXWIN }}${{ env.wxMSW_VER }}\build\msw
          nmake /f BUILD=release TARGET_CPU=X86

and then going on did the trick. It was only the with: arch: x86 that was missing