我正在尝试在CMake环境中运行Qt项目。在解决编译错误后,我一直在尝试解决我在下面引用的CMake错误:
目标" ColorCorrector"链接到目标" Qt5 :: Quick"但找不到目标。可能是IMPORTED目标缺少find_package()调用,或者缺少ALIAS目标?
目标" ColorCorrector_lib"链接到目标" Qt5 :: Quick"但找不到目标。可能是IMPORTED目标缺少find_package()调用,或者缺少ALIAS目标?
我为以下目标获得的错误相同: " Qt5 :: Sql" ," Qt5 :: XmaPatterns" ,如附带的打印屏幕所示:
我正在处理的CMakeList.txt文件下面:
cmake_minimum_required (VERSION 3.1)
project(colorCorrector)
find_package( OpenCV REQUIRED )
find_package( Boost COMPONENTS system thread filesystem REQUIRED)
find_package ( Qt5 REQUIRED COMPONENTS Quick Sql XmlPatterns Xml )
###
### make sure we use c++11
###
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
###
###boost include stuff (required for all libcam)
###
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
###
### QT stuff (required if you want a GUI)
###
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5Widgets)
find_package(Qt5PrintSupport)
#find all the qt UI stuff
file(GLOB UI
"ui/*.ui"
)
#make them into headers
qt5_wrap_ui (UI_HDRS ${UI})
###
### add all your non QT sources
###
# find all non ui sources
file(GLOB SRCS
"src/*.h"
"src/*.cpp"
"src/*.hpp"
)
# find all ui related sources
file(GLOB UI_SRCS
"ui/*.h"
"ui/*.cpp"
"ui/*.hpp"
)
###
### Add executables
###
add_executable(colorCorrector main/main.cpp ui/qdarkstyle/style.qrc ${SRCS} ${UI_HDRS})
target_link_libraries (colorCorrector libCam Qt5::Widgets Qt5::Quick Qt5::Sql Qt5::XmlPatterns Qt5::Xml ${Boost_LIBRARIES} ${OpenCV_LIBS} Qt5::PrintSupport)
###
### Add Library
###
add_library(colorCorrector_lib SHARED ui/qdarkstyle/style.qrc ${SRCS} ${UI_HDRS})
target_include_directories (colorCorrector_lib PUBLIC "src/" "ui/")
target_link_libraries (colorCorrector_lib libCam Qt5::Widgets Qt5::PrintSupport ${Boost_LIBRARIES} ${OpenCV_LIBS} Qt5::Quick Qt5::Sql Qt5::XmlPatterns Qt5::Xml)
我正在寻找不同的可能解决方案,例如我a link我查看了这个link也很有用,但仍然没有解决我的问题。
此外,我尝试根据CMake文档将以下内容添加到上面提到的CMakeList.txt文件中:
find_package(Qt5Sql)
find_package(Qt5XmlPatterns)
find_package(Qt5Quick)
find_package(Qt5Widgets)
find_package(Qt5PrintSupport)
知道问题可能是什么?