Qt+VS2019+OpenCV 使用问题 - Cound not find "QT"
软件信息:
Qt5+VS2019x64+OpenCV3.4
CMakeList.txt文件如下
...
# Add OpenCV library
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
list(APPEND LIBS_EXTERNAL ${OpenCV_LIBS})
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
...
当加载项目,并执行CMake时报错:
error: Could not find a package configuration file provided by “QT” with any of the following names: Qt6Config.cmake qt6-config.cmake Qt5Config.cmake qt5-config.cmake Add the installation prefix of “QT” to CMAKE_PREFIX_PATH or set “QT_DIR” to a directory containing one of the above files. If “QT” provides a separate development package or SDK, be sure it has been installed.
修改OpenCV与Qt的find_package顺序,即修改CMakeLists.txt文件如下:
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
fi