【问题标题】:CMAKE_PREFIX_PATH for Qt5Qt5 的 CMAKE_PREFIX_PATH
【发布时间】:2020-04-25 22:36:52
【问题描述】:

我想编译this,它需要Qt 5.14,并且我从我的linux存储库安装了Qt 5.12。我刚刚从源代码编译了Qt并将其安装在/usr/local/Qt-6.0.0/(默认位置)。
但是尽管我添加了 set(CMAKE_PREFIX_PATH "/usr/local/Qt-6.0.0/include") 和/或 set(CMAKE_PREFIX_PATH "/usr/local/Qt-6.0.0/"),但 CMake 会打印以下错误:

The following configuration files were considered but not accepted:

/usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake, version: 5.12.8
/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake, version: 5.12.8

【问题讨论】:

  • 你必须指向配置文件所在的位置。例如:Qt5_DIR="/Users/bob/Qt/5.12.7/clang_64/lib/cmake/Qt5" 您可以使用Qt5_DIRCMAKE_PREFIX_PATH,两者都应该可以工作。
  • @cppiscute 在我的情况下,QT5_DIR 工作。谢谢。
  • 这能回答你的问题吗? cmake does not find qt 5.1.1
  • @squareskittles QT5_DIR 就足够了。重要的是它应该指向“Qt_installation/lib/cmake/Qt5/”目录,其中包含一些帮助CMake查找Qt库的模块。
  • 这个response也涉及到这个话题,特别提到了Qt5_DIR的使用。

标签: linux qt cmake qt5


【解决方案1】:

既然它已经解决了你的问题,我只是把它作为一个答案在这里。稍后我会更详细地改进这部分。

如果您使用 cmake,请使用 find_package 查找包,然后链接到您的 后期二进制。

In order for find_package to be successful, Qt 5 must be found below the
CMAKE_PREFIX_PATH, or the Qt5_DIR must be set in the CMake cache to the 
location   of the Qt5Config.cmake file. The easiest way to use CMake is to set the
CMAKE_PREFIX_PATH environment variable to the install prefix of Qt 5.

如果您只想查找 Qt 模块,只需设置 Qt5_DIR
ex: Qt5_DIR="/Users/bob/Qt/5.12.7/clang_64/lib/cmake/Qt5"

使用 CMake 构建时,您可以使用 Qt5_DIR 或 CMAKE_PREFIX_PATH,两者都应该可以工作。

更多关于使用 CMake 构建的解释可以找到here

【讨论】:

    猜你喜欢
    • 2018-05-18
    • 2019-08-02
    • 1970-01-01
    • 2020-12-09
    • 1970-01-01
    • 1970-01-01
    • 2023-02-23
    • 2020-11-26
    相关资源
    最近更新 更多