当我使用以下代码时:
find_package(Qt5Widgets REQUIRED)
add_executable(ex ex.cc)
target_link_libraries(ex Qt5::Widgets Qt5::DBus)
我明白了:
Error:By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5Widgets", but CMake did not find one.
Could not find a package configuration file provided by "Qt5Widgets" with any of the following names:
我的qtbase路径位于" / media / roroco / disk750 / Downloads / qt5 / qtbase",我编译了它,如何在find_package
答案 0 :(得分:0)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(CMAKE_PREFIX_PATH $ENV{QT64_LOCATION})
message(STATUS "QT find path: $ENV{QT64_LOCATION}")
ELSE()
SET(CMAKE_PREFIX_PATH $ENV{QT_LOCATION})
message(STATUS "QT find path: $ENV{QT_LOCATION}")
ENDIF()
并将路径添加到环境变量(如果未定义或硬编码) - CMAKE_PREFIX_PATH“C:\ Qt \ .. \ msvc2010 \”或Linux中的qmake路径 即“/ media / roroco / disk750 / Downloads / qt5 / bin / qmake”
您也可以设置默认的qt路径
/usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf
将其设置为/ media / roroco / disk750 / Downloads / qt5 / bin /
答案 1 :(得分:0)
将CMAKE_PREFIX_PATH
设置为Qt
文件夹。例如:
SET(CMAKE_PREFIX_PATH "C:/Qt/5.5/msvc2013")
根据您的操作系统,路径可能会有所不同。