QT配置cmake 报错:Cannot specify link libraries for target " XXX XXX " which is not built by this project.或The keyword signature for target_link_libraries has already been used with the target

报错 Cannot specify link libraries for target " XXX XXX " which is not built by this project
是因为在使用target_link_libraries的时候,没有放到add_executable后面.
然而qt项目中的cmakelist.txt已经自动帮你写过add_executable了,所以如果自己加上add_executable又会报错有同名文件被添加。
image
特别注意一个项目中所有链接库要么都是Private要么都不是,如蓝色框框所示,否则会报错
The keyword signature for target_link_libraries has already been used with the target

顺便提一下cmake编译opencv源码

cmake-gui中选择本地编译器,.../qt/tools/mingwxx/bin中,c选择gcc.exe,c++选择g++.exe,选择advance模式,搜索cmake_make_program选择mingw32make.exe,都在前面所说的路径下,并把.../qt/tools/mingwxx/bin添加到系统环境变量Path中,提前下载opencv_videoio_ffpeg.dll并放入opencv4.6.0\sources\3rdparty\ffmpeg下

posted @ 2022-12-08 10:48  Los1r  阅读(3327)  评论(0)    收藏  举报