cmakeqt6ninja

Cannot detect Visual Studio when configuring QPdf and QWebEngine


I cannot configure QPdf and QWebEngine because configure.bat thinks I do not have Visual Studio 2019 or higher, but I have Visual Studio 2022 installed.  I followed the instructions https://doc.qt.io/qt-6/windows-building.html and https://doc.qt.io/qt-6/qtwebengine-platform-notes.html.

Here is the exact error message:

WARNING: QtWebEngine won't be built. Build requires Visual Studio 2019 or higher.
WARNING: QtPdf won't be built. Build requires Visual Studio 2019 or higher.

I tried switching the generator from Ninja to Visual Studio 17 2022, but the problem still persisted. In fact, it made it worse by making other things fail in the configuration process.

I posted this to https://bugreports.qt.io/browse/QTBUG-114875. The comments there said I was not running the vcvarsall.bat, but I was in fact doing that because it was part of the process outlined in Qt's documentation.


Solution

  • Well, I think I found a solution to the problem.  I had two separate scripts:  1) pre-configure.bat to run the vcvarsall script and 2) run-configure.bat to call the configure.bat script.  I ran pre-configure.bat and then run-configure.bat.  That generates the following output

    PS C:\Qt\6.2.4\build> .\pre-configure.batC:\Qt\6.2.4\build>ECHO OFF
    Set up Microsoft Visual Studio 2022.
    Edit this script by providing the ARCH (x86, amd64, et cetera), the MSVS_VCVARS_SCRIPT_PATH (the path to the vcvarsall.bat), the QT_VERSION, and the QT_SOURCE_DIR (optional).
    **********************************************************************
    ** Visual Studio 2022 Developer Command Prompt v17.6.4
    ** Copyright (c) 2022 Microsoft Corporation
    **********************************************************************
    [vcvarsall.bat] Environment initialized for: 'x64'
    PS C:\Qt\6.2.4\build> .\run-configure.batC:\Qt\6.2.4\build>ECHO OFF
    Configuring build for Qt "6.2.4".
    Configuring Qt to build in -release configuration.
    Configuring Qt to deploy to "C:\Qt\6.2.4\release\bin".
    QT_LLVM_CLANG_DIR is "C:\Qt\llvm-develop-install\release".
    + cd qtbase
    + C:\Qt\6.2.4\source\qtbase\configure.bat -top-level -prefix "C:\Qt\6.2.4\release\bin" -release -feature-clang -feature-clangcpp -- -D LLVM_INSTALL_DIR="C:\Qt\llvm-develop-install\release"
    -- Windows 10 SDK version:
    'C:/Program Files/CMake/bin/cmake.exe' '-D' 'LLVM_INSTALL_DIR=C:\\Qt\\llvm-develop-install\\release' '-DCMAKE_INSTALL_PREFIX=C://Qt//6.2.4//release//bin' '-DCMAKE_BUILD_TYPE=Release' '-DINPUT_clang=yes' '-DINPUT_clangcpp=yes' '-G' 'Ninja' 'C:/Qt/6.2.4/source'
    -- The CXX compiler identification is GNU 8.3.0
    -- The C compiler identification is GNU 8.3.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/Strawberry/c/bin/gcc.exe
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: C:/Strawberry/c/bin/c++.exe - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: C:/Strawberry/c/bin/gcc.exe - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    

    Apparently, that did not work.  I called pre-configure.bat as part of the run-configure.bat script and it was able to detect MSVC as the compiler.  That generates the following output

    PS C:\Qt\6.2.4\build> .\run-configure.batC:\Qt\6.2.4\build>ECHO OFF
    Set up Microsoft Visual Studio 2022.
    Edit this script by providing the ARCH (x86, amd64, et cetera), the MSVS_VCVARS_SCRIPT_PATH (the path to the vcvarsall.bat), the QT_VERSION, and the QT_SOURCE_DIR (optional).
    **********************************************************************
    ** Visual Studio 2022 Developer Command Prompt v17.6.4
    ** Copyright (c) 2022 Microsoft Corporation
    **********************************************************************
    [vcvarsall.bat] Environment initialized for: 'x64'
    Configuring build for Qt "6.2.4".
    Configuring Qt to build in -release configuration.
    Configuring Qt to deploy to "C:\Qt\6.2.4\release\bin".
    QT_LLVM_CLANG_DIR is "C:\Qt\llvm-develop-install\release".
    + cd qtbase
    + C:\Qt\6.2.4\source\qtbase\configure.bat -top-level -prefix "C:\Qt\6.2.4\release\bin" -release -feature-clang -feature-clangcpp -- -D LLVM_INSTALL_DIR="C:\Qt\llvm-develop-install\release"
    -- Windows 10 SDK version: 10.0.22621.0
    'C:/Program Files/CMake/bin/cmake.exe' '-D' 'LLVM_INSTALL_DIR=C:\\Qt\\llvm-develop-install\\release' '-DCMAKE_INSTALL_PREFIX=C://Qt//6.2.4//release//bin' '-DCMAKE_BUILD_TYPE=Release' '-DINPUT_clang=yes' '-DINPUT_clangcpp=yes' '-G' 'Ninja' 'C:/Qt/6.2.4/source'
    -- The CXX compiler identification is MSVC 19.36.32535.0
    -- The C compiler identification is MSVC 19.36.32535.0
    -- The ASM compiler identification is MSVC
    -- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    

    I have no idea why the way I was doing it was not working.  My guess is something to do with the terminal environment.