Add static library to CMake build

Signed-off-by: 's avatarGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
parent cfda8029
...@@ -34,6 +34,7 @@ STRING(STRIP ${BUILD_TIMESTAMP} BUILD_TIMESTAMP) ...@@ -34,6 +34,7 @@ STRING(STRIP ${BUILD_TIMESTAMP} BUILD_TIMESTAMP)
## build options ## build options
SET(PAHO_WITH_SSL FALSE CACHE BOOL "Flag that defines whether to build ssl-enabled binaries too. ") SET(PAHO_WITH_SSL FALSE CACHE BOOL "Flag that defines whether to build ssl-enabled binaries too. ")
SET(PAHO_BUILD_STATIC FALSE CACHE BOOL "Build static library")
SET(PAHO_BUILD_DOCUMENTATION FALSE CACHE BOOL "Create and install the HTML based API documentation (requires Doxygen)") SET(PAHO_BUILD_DOCUMENTATION FALSE CACHE BOOL "Create and install the HTML based API documentation (requires Doxygen)")
SET(PAHO_BUILD_SAMPLES FALSE CACHE BOOL "Build sample programs") SET(PAHO_BUILD_SAMPLES FALSE CACHE BOOL "Build sample programs")
......
...@@ -36,6 +36,7 @@ Before compiling, determine the value of some variables in order to configure fe ...@@ -36,6 +36,7 @@ Before compiling, determine the value of some variables in order to configure fe
Variable | Default Value | Description Variable | Default Value | Description
------------ | ------------- | ------------- ------------ | ------------- | -------------
PAHO_BUILD_STATIC | FALSE | Build a static version of the libraries
PAHO_WITH_SSL | FALSE | Flag that defines whether to build ssl-enabled binaries too. PAHO_WITH_SSL | FALSE | Flag that defines whether to build ssl-enabled binaries too.
OPENSSL_INC_SEARCH_PATH | "" (system default) | Directory containing OpenSSL includes OPENSSL_INC_SEARCH_PATH | "" (system default) | Directory containing OpenSSL includes
OPENSSL_LIB_SEARCH_PATH | "" (system default) | Directory containing OpenSSL libraries OPENSSL_LIB_SEARCH_PATH | "" (system default) | Directory containing OpenSSL libraries
...@@ -125,6 +126,8 @@ The Paho C client comprises four shared libraries: ...@@ -125,6 +126,8 @@ The Paho C client comprises four shared libraries:
* libmqttv3c.so - "classic" / synchronous * libmqttv3c.so - "classic" / synchronous
* libmqttv3cs.so - "classic" / synchronous with SSL * libmqttv3cs.so - "classic" / synchronous with SSL
Optionally, you can build static version of those libraries.
## Usage and API ## Usage and API
Detailed API documentation is available by building the Doxygen docs in the ``doc`` directory. A [snapshot is also available online](http://www.eclipse.org/paho/files/mqttdoc/Cclient/index.html). Detailed API documentation is available by building the Doxygen docs in the ``doc`` directory. A [snapshot is also available online](http://www.eclipse.org/paho/files/mqttdoc/Cclient/index.html).
......
...@@ -76,6 +76,22 @@ INSTALL(TARGETS paho-mqtt3c paho-mqtt3a ...@@ -76,6 +76,22 @@ INSTALL(TARGETS paho-mqtt3c paho-mqtt3a
LIBRARY DESTINATION lib) LIBRARY DESTINATION lib)
INSTALL(TARGETS MQTTVersion INSTALL(TARGETS MQTTVersion
RUNTIME DESTINATION bin) RUNTIME DESTINATION bin)
IF (PAHO_BUILD_STATIC)
ADD_LIBRARY(paho-mqtt3c-static STATIC $<TARGET_OBJECTS:common_obj> MQTTClient.c)
ADD_LIBRARY(paho-mqtt3a-static STATIC $<TARGET_OBJECTS:common_obj> MQTTAsync.c)
TARGET_LINK_LIBRARIES(paho-mqtt3c-static ${LIBS_SYSTEM})
TARGET_LINK_LIBRARIES(paho-mqtt3a-static ${LIBS_SYSTEM})
INSTALL(TARGETS paho-mqtt3c-static
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
INSTALL(TARGETS paho-mqtt3a-static
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
ENDIF()
INSTALL(FILES MQTTAsync.h MQTTClient.h MQTTClientPersistence.h INSTALL(FILES MQTTAsync.h MQTTClient.h MQTTClientPersistence.h
DESTINATION include) DESTINATION include)
...@@ -107,5 +123,21 @@ IF (PAHO_WITH_SSL) ...@@ -107,5 +123,21 @@ IF (PAHO_WITH_SSL)
INSTALL(TARGETS paho-mqtt3as INSTALL(TARGETS paho-mqtt3as
ARCHIVE DESTINATION lib ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib) LIBRARY DESTINATION lib)
IF (PAHO_BUILD_STATIC)
ADD_LIBRARY(paho-mqtt3cs-static STATIC $<TARGET_OBJECTS:common_ssl_obj> MQTTClient.c SSLSocket.c)
ADD_LIBRARY(paho-mqtt3as-static STATIC $<TARGET_OBJECTS:common_ssl_obj> MQTTAsync.c SSLSocket.c)
TARGET_LINK_LIBRARIES(paho-mqtt3cs-static ${OPENSSL_LIBRARIES} ${LIBS_SYSTEM})
TARGET_LINK_LIBRARIES(paho-mqtt3as-static ${OPENSSL_LIBRARIES} ${LIBS_SYSTEM})
INSTALL(TARGETS paho-mqtt3cs-static
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
INSTALL(TARGETS paho-mqtt3as-static
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
ENDIF()
ENDIF() ENDIF()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment