Qt6 with cmake and Visual Studio 17 2022 generator
-
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?
-
@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 😊 -
@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 😊@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.