且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CMAKE_PREFIX_PATH不能帮助CMake查找Qt5

更新时间:2022-05-29 03:25:51

我安装了以下缺少的软件包:

I installed the following missing packages:

sudo apt-get install qtbase5-dev
sudo apt-get install qtdeclarative5-dev

现在不需要附加任何前缀:

Attaching any kind of prefix is not required now:

    :~/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$ ls
build  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