mirror of
https://github.com/eclipse/paho.mqtt.cpp.git
synced 2025-05-09 11:21:24 +08:00
Merge pull request #374 from HpLightcorner/mqtt-c-submodule
Add paho.mqtt.c as a submodule
This commit is contained in:
commit
d43808e7c9
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal 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
|
@ -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 ---
|
||||
|
||||
|
@ -6,31 +6,41 @@ 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)
|
||||
set(_PAHO_MQTT_C_LIB_NAME ${_PAHO_MQTT_C_LIB_NAME}-static)
|
||||
endif()
|
||||
# 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()
|
||||
|
||||
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
|
||||
IMPORTED_LOCATION "${PAHO_MQTT_C_LIBRARIES}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${PAHO_MQTT_C_INCLUDE_DIRS}"
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C")
|
||||
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"
|
||||
INTERFACE_LINK_LIBRARIES "OpenSSL::SSL;OpenSSL::Crypto")
|
||||
INTERFACE_COMPILE_DEFINITIONS "OPENSSL=1"
|
||||
INTERFACE_LINK_LIBRARIES "OpenSSL::SSL;OpenSSL::Crypto")
|
||||
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)
|
||||
|
@ -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
1
src/externals/paho-mqtt-c
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 3b7ae6348bc917d42c04efa962e4868c09bbde9f
|
Loading…
x
Reference in New Issue
Block a user