1
0
mirror of https://github.com/eclipse/paho.mqtt.cpp.git synced 2025-05-10 03:39:07 +08:00

Merge pull request #374 from HpLightcorner/mqtt-c-submodule

Add paho.mqtt.c as a submodule
This commit is contained in:
Frank Pagliughi 2023-07-29 16:38:56 -04:00 committed by GitHub
commit d43808e7c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 19 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "src/externals/paho-mqtt-c"]
path = src/externals/paho-mqtt-c
url = https://github.com/eclipse/paho.mqtt.c.git

View File

@ -49,6 +49,7 @@ endif()
option(PAHO_BUILD_SAMPLES "Build sample programs" FALSE)
option(PAHO_BUILD_TESTS "Build tests" FALSE)
option(PAHO_BUILD_DOCUMENTATION "Create and install the API documentation (requires Doxygen)" FALSE)
option(PAHO_WITH_MQTT_C "Build paho.mqtt.c from the internal GIT submodule." FALSE)
## --- C++11 build flags ---

View File

@ -6,25 +6,36 @@ else()
set(_PAHO_MQTT_C_LIB_NAME paho-mqtt3a)
endif()
# add suffix when using static Paho MQTT C library variant on Windows
if(WIN32)
if(PAHO_BUILD_STATIC)
# add suffix when using static Paho MQTT C library variant
if(PAHO_BUILD_STATIC)
set(_PAHO_MQTT_C_LIB_NAME ${_PAHO_MQTT_C_LIB_NAME}-static)
endif()
endif()
find_library(PAHO_MQTT_C_LIBRARIES NAMES ${_PAHO_MQTT_C_LIB_NAME})
unset(_PAHO_MQTT_C_LIB_NAME)
find_path(PAHO_MQTT_C_INCLUDE_DIRS NAMES MQTTAsync.h)
if(PAHO_WITH_MQTT_C)
# Build the paho.mqtt.c library from the submodule
add_subdirectory(externals/paho-mqtt-c)
add_library(PahoMqttC::PahoMqttC ALIAS ${_PAHO_MQTT_C_LIB_NAME})
## install paho.mqtt.c library (appending to PahoMqttCpp export)
install(TARGETS ${_PAHO_MQTT_C_LIB_NAME} EXPORT PahoMqttCpp
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
find_path(PAHO_MQTT_C_INCLUDE_DIRS NAMES MQTTAsync.h
HINTS ${CMAKE_CURRENT_SOURCE_DIR}/externals/paho-mqtt-c/src)
else()
find_library(PAHO_MQTT_C_LIBRARIES NAMES ${_PAHO_MQTT_C_LIB_NAME})
unset(_PAHO_MQTT_C_LIB_NAME)
find_path(PAHO_MQTT_C_INCLUDE_DIRS NAMES MQTTAsync.h)
if (NOT TARGET PahoMqttC::PahoMqttC)
add_library(PahoMqttC::PahoMqttC UNKNOWN IMPORTED)
endif ()
set_target_properties(PahoMqttC::PahoMqttC PROPERTIES
set_target_properties(PahoMqttC::PahoMqttC PROPERTIES
IMPORTED_LOCATION "${PAHO_MQTT_C_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${PAHO_MQTT_C_INCLUDE_DIRS}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C")
endif()
if(PAHO_WITH_SSL)
set_target_properties(PahoMqttC::PahoMqttC PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "OPENSSL=1"
@ -32,5 +43,4 @@ if(PAHO_WITH_SSL)
endif()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PahoMqttC
REQUIRED_VARS PAHO_MQTT_C_LIBRARIES PAHO_MQTT_C_INCLUDE_DIRS)
find_package_handle_standard_args(PahoMqttC REQUIRED_VARS PAHO_MQTT_C_INCLUDE_DIRS)

View File

@ -23,7 +23,9 @@
# Frank Pagliughi - made the shared library optional
#*******************************************************************************/
find_package(PahoMqttC REQUIRED)
if (NOT TARGET PahoMqttC::PahoMqttC)
find_package(PahoMqttC REQUIRED)
endif()
# --- The headers ---

1
src/externals/paho-mqtt-c vendored Submodule

@ -0,0 +1 @@
Subproject commit 3b7ae6348bc917d42c04efa962e4868c09bbde9f