繁体   English   中英

在带有 vcpkg static 导出的 CMake 项目中找不到“Qt5”

[英]'Qt5' not found in CMake project with vcpkg static export

我想创建一个使用 VSCode+CMake+VCPKG(VTK+Qt5) 的项目而且我仍然想与队友分享我的 VCPKG 依赖。 所以我导出 VCPKG。

当我尝试find_package(Qt5 COMPONENTS Core REQUIRED)时发生问题

By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5", but
  CMake did not find one.
  Could not find a package configuration file provided by "Qt5" with any of
  the following names:
    Qt5Config.cmake
    qt5-config.cmake
  Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
  to a directory containing one of the above files.  If "Qt5" provides a
  separate development package or SDK, be sure it has been installed.

我尝试set(Qt5_DIR "{vckpg_root_path}\installed\x64-windows\share\qt5")

没有Qt5Config.cmake让cmake读取!!

在此处输入图像描述

里面就是这样。

如何准确使用 Qt5 并在 cmakelist.txt 中设置包含文件目录?

最后,我找到了如何在 CMALKELIST.txt 中添加脚本

cmake_minimum_required(VERSION 3.0.0)
set(VCPKG_DIR "C:/vcpkg/installed/x64-windows")
set(VCPKG_TARGET_TRIPLET "x64-windows"
      CACHE STRING "")
set(CMAKE_TOOLCHAIN_FILE "C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
      CACHE STRING "")

并添加 Qt 组件,导致 Qt package 被划分为多个位。 因此,将COMPOMENTS与您想要包含的 Qt package 一起使用。

find_package(Qt5 COMPONENTS Core Widgets CONFIG REQUIRED)
if (${Qt5Core_FOUND})
    message("Found Qt " ${Qt5_VERSION})
else()
    message("Couldn't find Qt")
endif()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM