首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >CMake无法在Qt6安装中找到包

CMake无法在Qt6安装中找到包
EN

Stack Overflow用户
提问于 2022-02-11 20:55:56
回答 4查看 5.1K关注 0票数 4

我正在尝试通过CMake构建一个项目,并将环境变量Qt6_DIR设置为包含Qt6Config.cmake的目录。但是,构建似乎无法在Qt6安装中找到它需要的任何其他依赖项&我不确定下一步需要做什么。我看到了对其他可能的环境变量的引用,比如"Qt6CoreTools_DIR“,我想知道我是否真的需要独立地设置这些变量,或者是否有一个包含这些信息的工具链需要正确地链接到。

代码语言:javascript
运行
复制
-- GUI Frontend: Qt6
CMake Warning at C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
  By not providing "FindQt6CoreTools.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "Qt6CoreTools", but CMake did not find one.

  Could not find a package configuration file provided by "Qt6CoreTools"
  (requested version 6.2.3) with any of the following names:

    Qt6CoreToolsConfig.cmake
    qt6coretools-config.cmake

  Add the installation prefix of "Qt6CoreTools" to CMAKE_PREFIX_PATH or set
  "Qt6CoreTools_DIR" to a directory containing one of the above files.  If
  "Qt6CoreTools" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsDependencies.cmake:9 (find_dependency)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsConfig.cmake:34 (include)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Widgets/Qt6WidgetsDependencies.cmake:71 (find_package)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake:40 (include)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package)
  src/CMakeLists.txt:22 (find_package)


CMake Warning at C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Widgets/Qt6WidgetsDependencies.cmake:71 (find_package):
  Found package configuration file:

    C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsConfig.cmake

  but it set Qt6WidgetsTools_FOUND to FALSE so package "Qt6WidgetsTools" is
  considered to be NOT FOUND.  Reason given by package:

  Qt6WidgetsTools could not be found because dependency Qt6CoreTools could
  not be found.

Call Stack (most recent call first):
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake:40 (include)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package)
  src/CMakeLists.txt:22 (find_package)


CMake Warning at C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package):
  Found package configuration file:

    C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake

  but it set Qt6Widgets_FOUND to FALSE so package "Qt6Widgets" is considered
  to be NOT FOUND.  Reason given by package:

  Target "Qt6::Widgets" was not found.

Call Stack (most recent call first):
  src/CMakeLists.txt:22 (find_package)


-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
CMake Warning at C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
  Found package configuration file:

    C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake

  but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
  NOT FOUND.  Reason given by package:

  Target "Qt6::Core" was not found.

Call Stack (most recent call first):
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLDependencies.cmake:91 (_qt_internal_find_dependencies)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLConfig.cmake:40 (include)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package)
  src/CMakeLists.txt:22 (find_package)


CMake Warning at C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package):
  Found package configuration file:

    C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLConfig.cmake

  but it set Qt6OpenGL_FOUND to FALSE so package "Qt6OpenGL" is considered to
  be NOT FOUND.  Reason given by package:

  Qt6OpenGL could not be found because dependency Qt6Core could not be found.

Call Stack (most recent call first):
  src/CMakeLists.txt:22 (find_package)


-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
CMake Warning at C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
  Found package configuration file:

    C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake

  but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
  NOT FOUND.  Reason given by package:

  Target "Qt6::Core" was not found.

Call Stack (most recent call first):
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLDependencies.cmake:91 (_qt_internal_find_dependencies)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLConfig.cmake:40 (include)
  C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGLWidgets/Qt6OpenGLWidgetsDependencies.cmake:91 (_qt_internal_find_dependencies)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGLWidgets/Qt6OpenGLWidgetsConfig.cmake:40 (include)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package)
  src/CMakeLists.txt:22 (find_package)


CMake Warning at C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
  Found package configuration file:

    C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLConfig.cmake

  but it set Qt6OpenGL_FOUND to FALSE so package "Qt6OpenGL" is considered to
  be NOT FOUND.  Reason given by package:

  Qt6OpenGL could not be found because dependency Qt6Core could not be found.

Call Stack (most recent call first):
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGLWidgets/Qt6OpenGLWidgetsDependencies.cmake:91 (_qt_internal_find_dependencies)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGLWidgets/Qt6OpenGLWidgetsConfig.cmake:40 (include)
  C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package)
  src/CMakeLists.txt:22 (find_package)


CMake Warning at C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package):
  Found package configuration file:

    C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGLWidgets/Qt6OpenGLWidgetsConfig.cmake

  but it set Qt6OpenGLWidgets_FOUND to FALSE so package "Qt6OpenGLWidgets" is
  considered to be NOT FOUND.  Reason given by package:

  Qt6OpenGLWidgets could not be found because dependency Qt6OpenGL could not
  be found.

Call Stack (most recent call first):
  src/CMakeLists.txt:22 (find_package)


CMake Error at src/CMakeLists.txt:22 (find_package):
  Found package configuration file:

    C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake

  but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
  FOUND.  Reason given by package:

  Failed to find Qt component "Widgets".

  Expected Config file at
  "C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake" exists

  Failed to find Qt component "OpenGL".

  Expected Config file at
  "C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLConfig.cmake" exists

  Failed to find Qt component "OpenGLWidgets".

  Expected Config file at
  "C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGLWidgets/Qt6OpenGLWidgetsConfig.cmake"
  exists
EN

回答 4

Stack Overflow用户

发布于 2022-06-22 18:14:22

将此添加到根cmake中。

代码语言:javascript
运行
复制
list(APPEND CMAKE_PREFIX_PATH "~/Qt/6.3.0/gcc_64")

根据需要更改路径。

票数 3
EN

Stack Overflow用户

发布于 2022-08-19 20:24:08

根据QTBUG-97615,不支持使用单个Qt6_DIR配置构建,而配置应用程序构建的“正式”方法是使用CMAKE_PREFIX_PATH (如其他答案所建议的)。

但是,如果您的工具不容易支持这样的appoach (比如VisualStudio/VSCode),那么这种情况是有解决办法的(我是在挖掘Qt6混乱的cmake脚本时发现的)。

QT_ADDITIONAL_PACKAGES_PREFIX_PATH 您可以使用来指定Qt根(以及Qt6_DIR最初将其挂起)。

命令行如下所示(只是为了说明方法):

cmake -DQt6_DIR:PATH=C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6 -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=C:/Qt6/6.2.3/mingw_64 ..

这两个变量都很容易通过VisualStudio/VSCode中的UI进行配置。

幸福大厦!:)

票数 2
EN

Stack Overflow用户

发布于 2022-03-18 16:25:58

来自Qt文档

您可以通过不同的方式告诉CMake有关Qt的信息,但最常见和推荐的方法是将CMake缓存变量CMAKE_PREFIX_PATH设置为包含Qt 6安装前缀。

因此,您应该将C:/Qt6 6/6.2.3/mingw_64/添加到路径分号分隔列表中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71086422

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档