CMake error with msvc in CLion
-
I am trying to run cmake on CLion and I get the following error
CMake Error at CMakeLists.txt:36 (find_package): Could not find a configuration file for package "QT" that is compatible with requested version "". The following configuration files were considered but not accepted: C:/Qt/6.0.0/msvc2019_64/lib/cmake/Qt6/Qt6Config.cmake, version: 6.0.0 (64bit)
This is working fine on macOS though. I tried setting
QT_DIR
andQt6_DIR
but I still get that same error.CMakeList.txt:
cmake_minimum_required(VERSION 3.5) set(VERSION 0.0.1) project(CSVExplorer VERSION ${VERSION} LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) if ($ENV{CLION_IDE}) set(QT_VERSION_MAJOR 6) if (APPLE) set(CMAKE_PREFIX_PATH $ENV{HOME}/Qt/6.0.0/clang_64) elseif (WIN32) set(CMAKE_PREFIX_PATH C:\\Qt\\6.0.0\\msvc2019_64) # set(QT_DIR C:\\Qt\\6.0.0\\msvc2019_64\\lib\\cmake\\Qt6) # set(Qt6_DIR C:\\Qt\\6.0.0\\msvc2019_64\\lib\\cmake\\Qt6) endif () endif () if (APPLE) set(MACOSX_BUNDLE_ICON_FILE csvexplorer.icns) # And the following tells CMake where to find and install the file itself. set(app_icon_macos "resources/images/csvexplorer.icns") set_source_files_properties(${app_icon_macos} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") endif () find_package(QT NAMES Qt6 COMPONENTS Widgets REQUIRED) find_package(QT NAMES Qt6 COMPONENTS Sql REQUIRED) find_package(QT NAMES Qt6 COMPONENTS Core REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Sql REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) add_executable(CSVExplorer MACOSX_BUNDLE main.cpp welsomescreen.cpp welsomescreen.h welcomescreen.ui aboutwindow.cpp aboutwindow.h aboutwindow.ui resources.qrc style.qrc migrations.qrc ${app_icon_macos} file.cpp file.h) target_link_libraries(CSVExplorer PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Sql Qt${QT_VERSION_MAJOR}::Core)
-
@akshaybabloo File->Settings->Build,Execution,Deployment->Toolchains
Select "Visual Studio", and you can see “Architecture" configuration.
My CLion is version 2020.3.1.
-
Hi,
Your CMAKE_PREFIX_PATH should point to the "Qt/6.0.0/clang_64/lib/cmake" subdir.
-
What do you get if you use a simple:
find_package(Qt6 COMPONENTS Widgets)
?
-
Does it work with Qt Creator ?
-
I found CLion by default uses x86 as the Architecture for VS in the toolchains setting.
I changed it to amd64, it works on my machine.
You can try it.
-
@zhangyiant How would you change that?
-
@akshaybabloo File->Settings->Build,Execution,Deployment->Toolchains
Select "Visual Studio", and you can see “Architecture" configuration.
My CLion is version 2020.3.1.
-
@zhangyiant Thank you very much, I had such a problem too, it worked for me too.
-