我如何使用cmake包含另一个项目的标头

时间:2019-01-22 14:26:04

标签: c cmake mqtt paho

我一直在尝试从另一个项目(尤其是Paho MQTT的MQTTClient.h)添加头文件。

当前项目如下:

  • src /
    • main.c
    • CMakeLists.txt
  • inc /
    • paho.mqtt.c-master /
      • CMakeLists.txt
      • src /
        • MQTTClient.h
        • CMakeLists.txt

目前,我的CMakeList.txt如下:

cmake_minimum_required(VERSION 2.8)
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)

project(market_listener)


SET(MQTT_INCLUDE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/inc/paho.mqtt.c-master)

set(MQTT
        "${MQTT_INCLUDE_DIR}"
        "${MQTT_INCLUDE_DIR}/src/MQTTClient.h"
)

INCLUDE_DIRECTORIES(${MQTT_INCLUDE_DIR}/src)
INCLUDE_DIRECTORIES(${MQTT_INCLUDE_DIR}/inc/paho.mqtt.c-master)


add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/inc/paho.mqtt.c-master)
add_executable(listener src/main.c)


install (TARGETS listener DESTINATION bin)
install (FILES "src/main.c" DESTINATION src)

这是失败尝试的合并,所以看起来很奇怪,我对此也很不好。

我可以cmake ..,但是当我make时,我得到以下信息:

E:/Projekti/C/Test_1/inc/paho.mqtt.c-master/src/Socket.c: In function 'Socket_error':
E:/Projekti/C/Test_1/inc/paho.mqtt.c-master/src/Socket.c:104:6: warning: '_errno' redeclared without dllimport attribute after being referenced with dll linkage
  int errno;

enter image description here

及以后:

E:/Projekti/C/Test_1/inc/paho.mqtt.c-master/src/Base64.c: In function 'Base64_encode':
E:/Projekti/C/Test_1/inc/paho.mqtt.c-master/src/Base64.c:36:63: error: 'CRYPT_STRING_NOCRLF' undeclared (first use in this function)
  if ( CryptBinaryToStringA( in, in_len, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, out, &dw_out_len ) )

E:/Projekti/C/Test_1/inc/paho.mqtt.c-master/src/Base64.c:36:63: note: each undeclared identifier is reported only once for each function it appears in

enter image description here

链接到我要从中获取标头的项目: https://github.com/eclipse/paho.mqtt.c

0 个答案:

没有答案