How to fix Cmake The PLATFORM environment variable (x64) doesn't match the generator platform (win32)

asked 2020-08-04 11:54:58 +0000

Eddy gravatar image

updated 2020-08-04 12:32:26 +0000

Building in Windows Sandbox with

choco install -y winflexbison3 cmake activeperl python3 asciidoctorj xsltproc docbook-bundle visualstudio2019community visualstudio2019-workload-nativedesktop

Command prompt is titled "Administator: x64 Native Tools Command Prompt for VS 2019" and opens claiming to be "Visual Studio 2019 Developer Command Prompt v16.6.5".

WIRESHARK_BASE_DIR and QT5_BASE_DIR are set

cmake -G "Visual Studio 16 2019" -A x64 ..\wireshark-3.2.5

quits with:

CMake Error at CMakeLists.txt:91 (message):
  The PLATFORM environment variable (x64) doesn't match the generator
  platform (win32)

Also set WIRESHARK_TARGET_PLATFORM=win64 does not fix this. Any ideas how to persuade this to work?

Set reports:

Platform=x64
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
edit retag flag offensive close merge delete

Comments

After opening the prompt, the banner should look like this:

**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.6.5
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

and the last line indicates the target.

What does set VSCMD_ARG_TGT_ARCH report?

grahamb gravatar imagegrahamb ( 2020-08-04 12:12:35 +0000 )edit

And you should be setting QT5_BASE_DIR.

Another thought, are you using a build directory that you've previously configured CMake for an x86 build? If so, create a new build dir, the x64 and x86 builds MUST be kept separate.

grahamb gravatar imagegrahamb ( 2020-08-04 12:17:00 +0000 )edit

** Visual Studio 2019 Developer Command Prompt v16.6.5
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>set VSCMD_ARG_TGT_ARCH
VSCMD_ARG_TGT_ARCH=x64

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>cd \Users\WDAGUtilityAccount\Desktop\wireshark\wsbuild64

C:\Users\WDAGUtilityAccount\Desktop\wireshark\wsbuild64>dir
 Volume in drive C has no label.
 Volume Serial Number is C436-650E

 Directory of C:\Users\WDAGUtilityAccount\Desktop\wireshark\wsbuild64

08/04/2020  12:57 PM    <DIR>          .
08/04/2020  12:57 PM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  80,356,634,624 bytes free

C:\Users\WDAGUtilityAccount\Desktop\wireshark\wsbuild64>set WIRESHARK_BASE_DIR=C:\Users\WDAGUtilityAccount\Desktop\wireshark

C:\Users\WDAGUtilityAccount\Desktop\wireshark\wsbuild64>set QT5_BASE_DIR=C:\Qt\Qt5.12.1\5.12.1\msvc2017_64

C:\Users\WDAGUtilityAccount\Desktop\wireshark\wsbuild64>cmake -G "Visual Studio 16 2019" -A x64 ..\wireshark-3.2.5
Eddy gravatar imageEddy ( 2020-08-04 12:33:36 +0000 )edit

More output:

-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI ...
(more)
Eddy gravatar imageEddy ( 2020-08-04 12:58:50 +0000 )edit

This bit of output is odd, not sure what that means:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown

It should be something like:

-- The C compiler identification is MSVC 19.26.28806.0
-- The CXX compiler identification is MSVC 19.26.28806.0

The check in CMakeList.txt is failing because the WIRESHARK_TARGET_PLATFORM variable is incorrect ("win32").

That is set by the block:

if(CMAKE_CL_64 OR CMAKE_GENERATOR MATCHES "Win64")
    set(WIRESHARK_TARGET_PLATFORM win64)
elseif(CMAKE_GENERATOR MATCHES "Visual Studio")
    set(WIRESHARK_TARGET_PLATFORM win32)
else()
    set(WIRESHARK_TARGET_PLATFORM $ENV{WIRESHARK_TARGET_PLATFORM})
endif()



So I would assume that the first conditional evaluates to false and the second to true. Can you add some debugging message(STATUS "...") items to dump out the value of {CMAKE_CL_64} and {CMAKE_GENERATOR}, e.g.

message(STATUS "CMAKE_CL_64: ${CMAKE_CL_64}, CMAKE_GENERATOR:${CMAKE_GENERATOR}")

add it just in front of the above block.

grahamb gravatar imagegrahamb ( 2020-08-04 13:56:56 +0000 )edit