收到CMake错误:无法为非项目创建的目标指定链接库 [英] Getting a CMake Error: Cannot specify link libraries for target which is not built by the project

查看:257
本文介绍了收到CMake错误:无法为非项目创建的目标指定链接库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在代码中实现CMake,但出现错误

I am implementing CMake in my code but I'm getting the error


无法为目标 Qt5 ::指定链接库:窗口小部件,它不是由项目构建的。

"Cannot specify link libraries for target "Qt5::Widgets" which is not built by the project".

以下是CMakeLists.txt的内容:

Below are the contents of the CMakeLists.txt:

#Specify the version being used aswell as the language
cmake_minimum_required(VERSION 2.6)

#Name your project here
project(eCAD)

#Sends the -std=c++11 flag to the gcc compiler
ADD_DEFINITIONS(-std=c++11)

#This tells CMake to main.cpp and name it eCAD
add_executable(eCAD main.cpp)


#include the subdirectory containing our libs
add_subdirectory (gui)
include_directories(gui)

#include Qt directories
find_package(Qt5Widgets)
find_package(Qt5Core)
find_package(Qt5Designer)
SET(QT_USE_QTDESIGNER ON)

#link_libraries
target_link_libraries(Qt5::Widgets Qt5::Core) 


推荐答案

target_link_libraries 的第一个参数是目标名称:

The first argument of target_link_libraries is the target name:

target_link_libraries(eCAD Qt5::Widgets Qt5::Core) 

这篇关于收到CMake错误:无法为非项目创建的目标指定链接库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆