Skip to content

Commit 443d508

Browse files
NeroReflexDenis Benato
authored andcommitted
Add CMake support for esp-idf
The esp-idf SDK requires components (including the main software sources) to be declared with idf_component_register: use that if ESP_PLATFORM is detected. Signed-off-by: Denis Benato <[email protected]>
1 parent d06e246 commit 443d508

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@
1414
# Ian Craggs - initial version
1515
#*******************************************************************************/
1616

17+
if(ESP_PLATFORM)
18+
19+
idf_component_register(
20+
INCLUDE_DIRS
21+
"MQTTClient-C/src/idf"
22+
"MQTTClient-C/src"
23+
"MQTTPacket/src"
24+
SRCS
25+
"MQTTClient-C/src/FreeRTOS/MQTTFreeRTOSPrimitives.c"
26+
"MQTTClient-C/src/linux/MQTTLinuxNetwork.c"
27+
"MQTTClient-C/src/MQTTClient.c"
28+
"MQTTPacket/src/MQTTConnectClient.c"
29+
"MQTTPacket/src/MQTTConnectServer.c"
30+
"MQTTPacket/src/MQTTDeserializePublish.c"
31+
"MQTTPacket/src/MQTTSerializePublish.c"
32+
"MQTTPacket/src/MQTTFormat.c"
33+
"MQTTPacket/src/MQTTPacket.c"
34+
"MQTTPacket/src/MQTTSubscribeClient.c"
35+
"MQTTPacket/src/MQTTSubscribeServer.c"
36+
"MQTTPacket/src/MQTTUnsubscribeClient.c"
37+
"MQTTPacket/src/MQTTUnsubscribeServer.c"
38+
REQUIRES
39+
freertos
40+
)
41+
42+
else()
43+
1744
cmake_minimum_required(VERSION 2.8)
1845
project (embedded-mqtt)
1946
set(CMAKE_BUILD_TYPE Debug)
@@ -44,3 +71,5 @@ enable_testing()
4471
ADD_SUBDIRECTORY(MQTTPacket)
4572
ADD_SUBDIRECTORY(MQTTClient)
4673
ADD_SUBDIRECTORY(MQTTClient-C)
74+
75+
endif()

MQTTClient-C/src/MQTTClient.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
#define xstr(s) str(s)
4444
#define str(s) #s
4545
#include xstr(MQTTCLIENT_PLATFORM_HEADER)
46+
#elif defined(ESP_PLATFORM)
47+
#include "MQTTidf.h"
4648
#endif
4749

4850
#define MAX_PACKET_ID 65535 /* according to the MQTT specification - do not change! */

MQTTClient-C/src/idf/MQTTidf.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2014, 2015 IBM Corp.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v1.0
6+
* and Eclipse Distribution License v1.0 which accompany this distribution.
7+
*
8+
* The Eclipse Public License is available at
9+
* http://www.eclipse.org/legal/epl-v10.html
10+
* and the Eclipse Distribution License is available at
11+
* http://www.eclipse.org/org/documents/edl-v10.php.
12+
*
13+
* Contributors:
14+
* Denis Benato - support for esp-idf: the esp32 platform
15+
*******************************************************************************/
16+
17+
#if !defined(MQTTidf_H)
18+
#define MQTTidf_H
19+
20+
#include "../FreeRTOS/MQTTFreeRTOSPrimitives.h"
21+
#include "../linux/MQTTLinuxNetwork.h"
22+
23+
#endif

0 commit comments

Comments
 (0)