我在/ usr / lib文件夹中有一个libmosquittopp.so。 mosquittopp.h位于/ usr / include文件夹中。
我喜欢将我的项目链接到该库。
所以我的CMakeLists.txt文件是
cmake_minimum_required(VERSION 2.6)
PROJECT(MosquittoTest)
# The version number.
set (VERSION_MAJOR 1)
set (VERSION_MINOR 0)
include_directories("${PROJECT_BINARY_DIR}")
# Linked libariries
#For MQTT
#location of raspicam's cmake file is /usr/src/raspicam-0.1.3/build
link_directories(/usr/lib)
target_link_libraries (MosquittoTest mosquittopp)
ADD_EXECUTABLE(MosquittoTest MosquittoTest.cpp)
# add the install targets
install (TARGETS MosquittoTest DESTINATION bin)
install (FILES MosquittoInterface.h DESTINATION include)
但是当我在ccmake GUI中配置时,我的错误为
Cannot specify link ibraries for target MosquittoTest which is not built by this project.
我的cmake出了什么问题?
答案 0 :(得分:0)
我犯了错误,因为需要交换这两行。
target_link_libraries (MosquittoTest mosquittopp)
ADD_EXECUTABLE(MosquittoTest MosquittoTest.cpp)