Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt6 with cmake and Visual Studio 17 2022 generator
Qt 6.11 is out! See what's new in the release blog

Qt6 with cmake and Visual Studio 17 2022 generator

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 3.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tobxon
    wrote on last edited by
    #1

    Re: Could not find a configuration file for package "Qt6" that is compatible with requested version "".

    I think I am having the same problem as in the above topic.

    I am trying to build a cmake project using Qt6 with the Visual Studio 17 2022 generator. I get the same error message:

    1> [CMake]   Could not find a configuration file for package "Qt6" that is compatible
    1> [CMake]   with requested version "".
    1> [CMake] 
    1> [CMake]   The following configuration files were considered but not accepted:
    1> [CMake] 
    1> [CMake]     E:/Dev/3rdParty/Qt/Qt6.4.2/6.4.2/msvc2019_64/lib/cmake/Qt6/Qt6Config.cmake, version: 6.4.2 (64bit)
    

    When I use Ninja it works.
    But I can't use ninja as a generator on my project due to other restrictions.

    Here I can offer a reduced example that shows the same behaviour (buildable with Ninja, but not with Visual Studio):

    cmake_minimum_required(VERSION 3.23)
    
    project(MY_PROJECT LANGUAGES CXX)
    
    #QT
    find_package(Qt6 REQUIRED 
        COMPONENTS Widgets Gui Core
    )
    
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTOUIC ON)
    
    qt_add_executable(MY_PROJECT_GUI MACOSX_BUNDLE WIN32
        "main.cpp"
    )
    target_sources(MY_PROJECT_GUI
        PRIVATE
            "MainWindow.cpp"
    		"MainWindow.h"
            "MainWindow.ui"
    )
    
    target_link_libraries(MY_PROJECT_GUI 
        PRIVATE	
            Qt::Widgets Qt::Gui Qt::Core
    )
    

    Is there anything I can do to make it work or does Qt6 basically not support Visual Studio generators?

    1 Reply Last reply
    0
    • cristian-adamC Offline
      cristian-adamC Offline
      cristian-adam
      wrote on last edited by
      #2

      @Tobxon said in Qt6 with cmake and Visual Studio 17 2022 generator:

      (64bit)

      That's the clue. You are trying to configure a x86 project with a Visual Studio 17 2022 generator.

      You forgot to pass the -A Win64 argument on command line. Or was it -A x64? One of these two works 😊

      T 1 Reply Last reply
      0
      • cristian-adamC cristian-adam

        @Tobxon said in Qt6 with cmake and Visual Studio 17 2022 generator:

        (64bit)

        That's the clue. You are trying to configure a x86 project with a Visual Studio 17 2022 generator.

        You forgot to pass the -A Win64 argument on command line. Or was it -A x64? One of these two works 😊

        T Offline
        T Offline
        Tobxon
        wrote on last edited by
        #3

        @cristian-adam Thanks a lot.
        The argument is set in my CMakeSettings file and I didn't recognize that Visual Studio 17 2022 implicitly means Win32. I set it to Win64 and it works.

        Sorry for thinking that this doesn't work in general. I thought I already made a boiled down example, but obviously missed that one.

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved