我试过这个:
cmake_minimum_required(VERSION 2.8.12)project(qtquick_hello_cmake)set(CMAKE_PREFIX_PATH "/opt/Qt5.9.1/5.9.1/")set(CMAKE_INCLUDE_CURRENT_DIR ON)set(CMAKE_autoMOC ON)set(CMAKE_autoRCC ON)find_package(Qt5 COMPONENTS Quick Core required)qt5_add_resources(RESOURCES qml.qrc)add_executable(${PROJECT_name} "main.cpp" "qml.qrc")qt5_use_modules(${PROJECT_name} Quick Core)target_link_librarIEs(${PROJECT_name} Qt5::Core Qt5::Quick)
这是cmake的输出.
:~/junk/qtquick_hello_cmake$cmake .CMake Error at CMakeLists.txt:11 (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.-- Configuring incomplete,errors occurred!See also "/home/.../junk/qtquick_hello_cmake/CMakefiles/CMakeOutput.log".
这表明/opt/Qt5.9.1/确实存在.
:~/junk/qtquick_hello_cmake$cd /opt/Qt5.9.1/5.9.1/:/opt/Qt5.9.1/5.9.1$lsandroID_armv7 androID_x86 gcc_64 Src
这里我使用-DCMAKE选项运行cmake,但输出仍然相同:
:~/junk/qtquick_hello_cmake$cmake -DCMAKE_PREFIX_PATH=/opt/Qt5.9.1/5.9.1/ -DWITH_QT5=1 .CMake Error at CMakeLists.txt:11 (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",errors occurred!See also "/home/.../junk/qtquick_hello_cmake/CMakefiles/CMakeOutput.log".
目录的内容:
:~/junk/qtquick_hello_cmake$lsCMakeCache.txt CMakefiles CMakeLists.txt main.cpp main.qml qml.qrc解决方法 我安装了以下缺少的包:
sudo apt-get install qtbase5-devsudo apt-get install qtdeclarative5-dev
现在不需要附加任何类型的前缀:
:~/junk/qtquick_hello_cmake$cat CMakeLists.txt cmake_minimum_required(VERSION 2.8.12) project(qtquick_hello_cmake) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_autoMOC ON) set(CMAKE_autoRCC ON) find_package(Qt5 COMPONENTS Quick Core required) qt5_add_resources(RESOURCES qml.qrc) add_executable(${PROJECT_name} "main.cpp" "qml.qrc") qt5_use_modules(${PROJECT_name} Quick Core) target_link_librarIEs(${PROJECT_name} Qt5::Core Qt5::Quick):~/junk/qtquick_hello_cmake$lsbuild CMakeLists.txt main.cpp main.qml qml.qrc:~/junk/qtquick_hello_cmake$cd build/:~/junk/qtquick_hello_cmake/build$rm -rf *:~/junk/qtquick_hello_cmake/build$cmake ../-- The C compiler IDentification is GNU 4.8.4-- The CXX compiler IDentification is GNU 4.8.4-- Check for working C compiler: /usr/bin/cc-- Check for working C compiler: /usr/bin/cc -- works-- Detecting C compiler ABI info-- Detecting C compiler ABI info - done-- Check for working CXX compiler: /usr/bin/c++-- Check for working CXX compiler: /usr/bin/c++ -- works-- Detecting CXX compiler ABI info-- Detecting CXX compiler ABI info - done-- Configuring done-- Generating done-- Build files have been written to: /home/.../junk/qtquick_hello_cmake/build
错误现在消失了.
谢谢:
https://answers.ros.org/question/236324/could-not-find-a-package-configuration-file-provided-by-qt5widgets/
https://askubuntu.com/questions/508503/whats-the-development-package-for-qt5-in-14-04
以上是内存溢出为你收集整理的linux – CMAKE_PREFIX_PATH无法帮助CMake查找Qt5全部内容,希望文章能够帮你解决linux – CMAKE_PREFIX_PATH无法帮助CMake查找Qt5所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)