zoukankan      html  css  js  c++  java
  • 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.

    环境 qt5.12.3  deepin15.10

    cmake构建

    由于之前使用的是仓库自带的qt环境,后来需要更高版本qt,于是从官网下载安装器自己安装,重新构建之后便出现这个问题,具体报错如下

    CMake Warning at src/CMakeLists.txt:45 (find_package):
      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.

    我去翻看了cmake官方文档,然后看到一篇文章才明白,cmake在find_package的时候需要提供对应模块的*.cmake文件,根据推测要么是cmake自己提供,显然不是,于是在我的qt安装目录下找到相应目录提供给cmake查找

    在我的qt安装路径下的"/opt/Qt/5.12.3/gcc_64/lib/cmake"里面便可以找到提供给cmake的各个模块的文件夹,每个文件夹下提供了对应的*.cmake文件。这篇文章给我的答案:https://stackoverflow.com/questions/15639781/how-to-find-the-qt5-cmake-module-on-windows#

    我是这样做的

    set(CMAKE_PREFIX_PATH "/opt/Qt/5.12.3/gcc_64")
    为每个模块提供*.cmake文件搜索路径
    set(Qt5_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5")
    set(Qt5Widgets_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5Widgets")
    set(Qt5Network_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5Network")
    set(Qt5LinguistTools_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5LinguistTools")
    然后查找
    find_package(Qt5 COMPONENTS Widgets Network LinguistTools)
  • 相关阅读:
    [Tips] Resolve error: server certificate verification failed.
    [Tips] bzr Import error
    NPAPI命休矣
    [Buzz Today]2013.08.18
    [Tips]Fix node.js addon build error: "gyp: binding.gyp not found"
    The.first.glance.at.linux.commands
    [Idea Fragments]2013.08.08
    Linux利器:WinSCP,Putty,pscp和psftp
    本博客已经迁移去http://blog.brightwang.com/
    将博客搬至CSDN
  • 原文地址:https://www.cnblogs.com/ohsolong/p/10825573.html
Copyright © 2011-2022 走看看