简体   繁体   English

如何解决mac中的qt5(未找到包)cmake错误?

[英]How to solve qt5 (packages not found) cmake errors in mac?

I get these following errors during build of a file using CMake:在使用 CMake 构建文件期间,我收到以下错误:

CMake Warning at CMakeLists.txt:33 (FIND_PACKAGE):

By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5Core", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5Core" with any of the following names:

    Qt5CoreConfig.cmake
    qt5core-config.cmake

Anybody know how to solve this?有谁知道如何解决这个问题? Thanks in advance提前致谢

You should find the cmake packages in your Qt installation in:您应该在 Qt 安装中找到 cmake 包:

<install_prefix>/lib/cmake

Assuming <install_prefix> is the root path of your installation.假设<install_prefix>是安装的根路径。 Set the variable Qt5_DIR to <install_prefix>/lib/cmake/Qt5 in your configuration and cmake should be able to find all the modules在您的配置中将变量 Qt5_DIR 设置为<install_prefix>/lib/cmake/Qt5并且 cmake 应该能够找到所有模块

Maybe, you should try to add the proper path to the CMAKE_PREFIX_PATH variable in the environment or config.也许,您应该尝试在环境或配置中添加到CMAKE_PREFIX_PATH变量的正确路径。

export CMAKE_PREFIX_PATH=path_to/Qt/5.9/clang_64:$CMAKE_PREFIX_PATH

Replace path_to with your real path.path_to替换为您的真实路径。

One possible cause for this error message is outdated CMake code like [1]此错误消息的一个可能原因是过时的 CMake 代码,例如 [1]

find_package(Qt5Core REQUIRED).

Then there is a good chance for solving the problem by changing to那么很有可能通过更改为来解决问题

find_package(Qt5 COMPONENTS REQUIRED Core).

[1] http://cmake.3232098.n2.nabble.com/debugging-CMAKE-PREFIX-PATH-td7596290.html [1] http://cmake.3232098.n2.nabble.com/debugging-CMAKE-PREFIX-PATH-td7596290.html

in many times its enough to have the PATH environment variable correctly set, so when typing qmake in terminal, it executes the right file.很多时候它足以正确设置 PATH 环境变量,因此在终端中键入 qmake 时,它​​会执行正确的文件。 Once you have it, execute cmake in the command line有了它后,在命令行中执行 cmake

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

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