mirror of https://github.com/eclipse/paho.mqtt.c
Support for the CMake build system
Signed-off-by: Rainer Poisel <rainer.poisel@gmail.com>
This commit is contained in:
parent
1292fbd4ad
commit
3b8a5645f0
|
|
@ -1,2 +1,3 @@
|
|||
/dep/
|
||||
/build/output/
|
||||
/build/
|
||||
*.swp
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
#*******************************************************************************
|
||||
# Copyright (c) 2015 logi.cals GmbH
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||
#
|
||||
# The Eclipse Public License is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
# and the Eclipse Distribution License is available at
|
||||
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
#
|
||||
# Contributors:
|
||||
# Rainer Poisel - initial version
|
||||
#*******************************************************************************/
|
||||
|
||||
# Note: on OS X you should install XCode and the associated command-line tools
|
||||
|
||||
PROJECT("paho" C)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
|
||||
|
||||
## build settings
|
||||
SET(PAHO_VERSION_MAJOR 1)
|
||||
SET(PAHO_VERSION_MINOR 0)
|
||||
SET(PAHO_VERSION_PATCH 3)
|
||||
SET(CLIENT_VERSION ${PAHO_VERSION_MAJOR}.${PAHO_VERSION_MINOR}.${PAHO_VERSION_PATCH})
|
||||
|
||||
EXECUTE_PROCESS(COMMAND date -u OUTPUT_VARIABLE BUILD_TIMESTAMP)
|
||||
STRING(STRIP ${BUILD_TIMESTAMP} BUILD_TIMESTAMP)
|
||||
|
||||
## build options
|
||||
SET(PAHO_WITH_SSL FALSE CACHE BOOL "Flag that defines whether to build ssl-enabled binaries too. ")
|
||||
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")
|
||||
|
||||
ADD_SUBDIRECTORY(src)
|
||||
IF(PAHO_BUILD_SAMPLES)
|
||||
ADD_SUBDIRECTORY(src/samples)
|
||||
ENDIF()
|
||||
|
||||
IF(PAHO_BUILD_DOCUMENTATION)
|
||||
ADD_SUBDIRECTORY(doc)
|
||||
ENDIF()
|
||||
|
||||
### packaging settings
|
||||
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
SET(CPACK_GENERATOR "ZIP")
|
||||
ELSE()
|
||||
SET(CPACK_GENERATOR "TGZ")
|
||||
ENDIF()
|
||||
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR ${PAHO_VERSION_MAJOR})
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR ${PAHO_VERSION_MINOR})
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH ${PAHO_VERSION_PATCH})
|
||||
INCLUDE(CPack)
|
||||
55
Makefile
55
Makefile
|
|
@ -50,6 +50,18 @@ ifndef blddir
|
|||
blddir = build/output
|
||||
endif
|
||||
|
||||
ifndef blddir_work
|
||||
blddir_work = build
|
||||
endif
|
||||
|
||||
ifndef docdir
|
||||
docdir = $(blddir)/doc
|
||||
endif
|
||||
|
||||
ifndef docdir_work
|
||||
docdir_work = $(blddir)/../doc
|
||||
endif
|
||||
|
||||
ifndef prefix
|
||||
prefix = /usr/local
|
||||
endif
|
||||
|
|
@ -115,7 +127,7 @@ MQTTLIB_A_TARGET = ${blddir}/lib${MQTTLIB_A}.so.${VERSION}
|
|||
MQTTLIB_AS_TARGET = ${blddir}/lib${MQTTLIB_AS}.so.${VERSION}
|
||||
MQTTVERSION_TARGET = ${blddir}/MQTTVersion
|
||||
|
||||
CCFLAGS_SO = -g -fPIC $(CFLAGS) -Os -Wall -fvisibility=hidden
|
||||
CCFLAGS_SO = -g -fPIC $(CFLAGS) -Os -Wall -fvisibility=hidden -I$(blddir_work)
|
||||
FLAGS_EXE = $(LDFLAGS) -I ${srcdir} -lpthread -L ${blddir}
|
||||
FLAGS_EXES = $(LDFLAGS) -I ${srcdir} ${START_GROUP} -lpthread -lssl -lcrypto ${END_GROUP} -L ${blddir}
|
||||
|
||||
|
|
@ -124,9 +136,11 @@ LDFLAGS_CS = $(LDFLAGS) -shared $(START_GROUP) -lpthread $(EXTRA_LIB) -lssl -lcr
|
|||
LDFLAGS_A = $(LDFLAGS) -shared -Wl,-init,$(MQTTASYNC_INIT) -lpthread
|
||||
LDFLAGS_AS = $(LDFLAGS) -shared $(START_GROUP) -lpthread $(EXTRA_LIB) -lssl -lcrypto $(END_GROUP) -Wl,-init,$(MQTTASYNC_INIT)
|
||||
|
||||
ifeq ($(OSTYPE),Linux)
|
||||
SED_COMMAND = sed \
|
||||
-e "s/@CLIENT_VERSION@/${release.version}/g" \
|
||||
-e "s/@BUILD_TIMESTAMP@/${build.level}/g"
|
||||
|
||||
SED_COMMAND = sed -i "s/\#\#MQTTCLIENT_VERSION_TAG\#\#/${release.version}/g; s/\#\#MQTTCLIENT_BUILD_TAG\#\#/${build.level}/g"
|
||||
ifeq ($(OSTYPE),Linux)
|
||||
|
||||
MQTTCLIENT_INIT = MQTTClient_init
|
||||
MQTTASYNC_INIT = MQTTAsync_init
|
||||
|
|
@ -142,8 +156,6 @@ LDFLAGS_AS += -Wl,-soname,lib${MQTTLIB_AS}.so.${MAJOR_VERSION} -Wl,-no-whole-arc
|
|||
|
||||
else ifeq ($(OSTYPE),Darwin)
|
||||
|
||||
SED_COMMAND = sed -i "" -e "s/\#\#MQTTCLIENT_VERSION_TAG\#\#/${release.version}/g" -e "s/\#\#MQTTCLIENT_BUILD_TAG\#\#/${build.level}/g"
|
||||
|
||||
MQTTCLIENT_INIT = _MQTTClient_init
|
||||
MQTTASYNC_INIT = _MQTTAsync_init
|
||||
START_GROUP =
|
||||
|
|
@ -189,26 +201,25 @@ ${SYNC_SAMPLES}: ${blddir}/samples/%: ${srcdir}/samples/%.c $(MQTTLIB_C_TARGET)
|
|||
${ASYNC_SAMPLES}: ${blddir}/samples/%: ${srcdir}/samples/%.c $(MQTTLIB_A_TARGET)
|
||||
${CC} -o $@ $< -l${MQTTLIB_A} ${FLAGS_EXE}
|
||||
|
||||
${MQTTLIB_C_TARGET}: ${SOURCE_FILES_C} ${HEADERS_C}
|
||||
$(SED_COMMAND) $(srcdir)/MQTTClient.c
|
||||
$(blddir_work)/VersionInfo.h: $(srcdir)/VersionInfo.h.in
|
||||
$(SED_COMMAND) $< > $@
|
||||
|
||||
${MQTTLIB_C_TARGET}: ${SOURCE_FILES_C} ${HEADERS_C} $(blddir_work)/VersionInfo.h
|
||||
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_C} ${LDFLAGS_C}
|
||||
-ln -s lib$(MQTTLIB_C).so.${VERSION} ${blddir}/lib$(MQTTLIB_C).so.${MAJOR_VERSION}
|
||||
-ln -s lib$(MQTTLIB_C).so.${MAJOR_VERSION} ${blddir}/lib$(MQTTLIB_C).so
|
||||
|
||||
${MQTTLIB_CS_TARGET}: ${SOURCE_FILES_CS} ${HEADERS_C}
|
||||
$(SED_COMMAND) $(srcdir)/MQTTClient.c
|
||||
${MQTTLIB_CS_TARGET}: ${SOURCE_FILES_CS} ${HEADERS_C} $(blddir_work)/VersionInfo.h
|
||||
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_CS} -DOPENSSL ${LDFLAGS_CS}
|
||||
-ln -s lib$(MQTTLIB_CS).so.${VERSION} ${blddir}/lib$(MQTTLIB_CS).so.${MAJOR_VERSION}
|
||||
-ln -s lib$(MQTTLIB_CS).so.${MAJOR_VERSION} ${blddir}/lib$(MQTTLIB_CS).so
|
||||
|
||||
${MQTTLIB_A_TARGET}: ${SOURCE_FILES_A} ${HEADERS_A}
|
||||
$(SED_COMMAND) $(srcdir)/MQTTAsync.c
|
||||
${MQTTLIB_A_TARGET}: ${SOURCE_FILES_A} ${HEADERS_A} $(blddir_work)/VersionInfo.h
|
||||
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_A} ${LDFLAGS_A}
|
||||
-ln -s lib$(MQTTLIB_A).so.${VERSION} ${blddir}/lib$(MQTTLIB_A).so.${MAJOR_VERSION}
|
||||
-ln -s lib$(MQTTLIB_A).so.${MAJOR_VERSION} ${blddir}/lib$(MQTTLIB_A).so
|
||||
|
||||
${MQTTLIB_AS_TARGET}: ${SOURCE_FILES_AS} ${HEADERS_A}
|
||||
$(SED_COMMAND) $(srcdir)/MQTTAsync.c
|
||||
${MQTTLIB_AS_TARGET}: ${SOURCE_FILES_AS} ${HEADERS_A} $(blddir_work)/VersionInfo.h
|
||||
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_AS} -DOPENSSL ${LDFLAGS_AS}
|
||||
-ln -s lib$(MQTTLIB_AS).so.${VERSION} ${blddir}/lib$(MQTTLIB_AS).so.${MAJOR_VERSION}
|
||||
-ln -s lib$(MQTTLIB_AS).so.${MAJOR_VERSION} ${blddir}/lib$(MQTTLIB_AS).so
|
||||
|
|
@ -251,8 +262,18 @@ uninstall:
|
|||
rm $(DESTDIR)${includedir}/MQTTClient.h
|
||||
rm $(DESTDIR)${includedir}/MQTTClientPersistence.h
|
||||
|
||||
REGEX_DOXYGEN := \
|
||||
's;@PROJECT_SOURCE_DIR@/src/\?;;' \
|
||||
's;@PROJECT_SOURCE_DIR@;..;' \
|
||||
's;@CMAKE_CURRENT_BINARY_DIR@;../build/output;'
|
||||
SED_DOXYGEN := $(foreach sed_exp,$(REGEX_DOXYGEN),-e $(sed_exp))
|
||||
define process_doxygen
|
||||
cd ${srcdir}; sed $(SED_DOXYGEN) ../doc/${1}.in > ../$(docdir_work)/${1}
|
||||
cd ${srcdir}; $(DOXYGEN_COMMAND) ../$(docdir_work)/${1}
|
||||
endef
|
||||
html:
|
||||
-mkdir -p ${blddir}/doc
|
||||
cd ${srcdir}; $(DOXYGEN_COMMAND) ../doc/DoxyfileV3ClientAPI
|
||||
cd ${srcdir}; $(DOXYGEN_COMMAND) ../doc/DoxyfileV3AsyncAPI
|
||||
cd ${srcdir}; $(DOXYGEN_COMMAND) ../doc/DoxyfileV3ClientInternal
|
||||
-mkdir -p $(docdir_work)
|
||||
-mkdir -p ${docdir}
|
||||
$(call process_doxygen,DoxyfileV3ClientAPI)
|
||||
$(call process_doxygen,DoxyfileV3AsyncAPI)
|
||||
$(call process_doxygen,DoxyfileV3ClientInternal)
|
||||
|
|
|
|||
122
README.md
122
README.md
|
|
@ -7,34 +7,114 @@ This code builds libraries which enable applications to connect to an [MQTT](htt
|
|||
|
||||
Both synchronous and asynchronous modes of operation are supported.
|
||||
|
||||
## Build requirements / compilation
|
||||
## Build requirements / compilation using CMake
|
||||
|
||||
The build process requires GNU Make and gcc, and also requires OpenSSL libraries and includes to be available. There are make rules for a number of Linux "flavors" including ARM and s390, OS X, AIX and Solaris.
|
||||
There build process currently supports a number of Linux "flavors" including ARM and s390, OS X, AIX and Solaris as well as the Windows operating system. The build process requires the following tools:
|
||||
* CMake (http://cmake.org)
|
||||
* Ninja (https://martine.github.io/ninja/; preferred) or
|
||||
GNU Make (https://www.gnu.org/software/make/), and
|
||||
* gcc (https://gcc.gnu.org/).
|
||||
|
||||
The documentation requires doxygen and optionally graphviz.
|
||||
|
||||
Before compiling, set some environment variables (or pass these values to the make command directly) in order to configure library locations and other options.
|
||||
|
||||
Specify the location of OpenSSL using `SSL_DIR`
|
||||
|
||||
e.g. using [homebrew](http://mxcl.github.com/homebrew/) on OS X:
|
||||
|
||||
`export SSL_DIR=/usr/local/Cellar/openssl/1.0.1e`
|
||||
|
||||
Specify where the source files are in relation to where the make command is being executed.
|
||||
|
||||
``export MQTTCLIENT_DIR=../src``
|
||||
|
||||
To build the samples, enable the option (`BUILD_SAMPLES`), and specify the location of the code:
|
||||
On Debian based systems this would mean that the following packages have to be installed:
|
||||
|
||||
```
|
||||
export BUILD_SAMPLES=YES
|
||||
export SAMPLES_DIR=../src/samples
|
||||
apt-get install build-essential gcc make cmake cmake-gui cmake-curses-gui
|
||||
```
|
||||
Ninja can be downloaded from its github project page in the "releases" section. Optionally it is possible to build binaries with SSL support. This requires the OpenSSL libraries and includes to be available. E. g. on Debian:
|
||||
|
||||
```
|
||||
apt-get install libssl-dev
|
||||
```
|
||||
|
||||
One more useful environment variable is ``TARGET_PLATFORM``. This provides for cross-compilation. Currently the only recognised value is "Arm" - for instance to cross-compile a Linux ARM version of the libraries:
|
||||
The documentation requires doxygen and optionally graphviz:
|
||||
|
||||
``export TARGET_PLATFORM=Arm``
|
||||
```
|
||||
apt-get install doxygen graphviz
|
||||
```
|
||||
|
||||
Before compiling, determine the value of some variables in order to configure features, library locations, and other options:
|
||||
|
||||
Variable | Default Value | Description
|
||||
------------ | ------------- | -------------
|
||||
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_LIB_SEARCH_PATH | "" (system default) | Directory containing OpenSSL libraries
|
||||
PAHO_BUILD_DOCUMENTATION | FALSE | Create and install the HTML based API documentation (requires Doxygen)
|
||||
PAHO_BUILD_SAMPLES | FALSE | Build sample programs
|
||||
|
||||
Using these variables CMake can be used to generate your Ninja or Make files. Using CMake, building out-of-source is the default. Therefore it is recommended to invoke all build commands inside your chosen build directory but outside of the source tree.
|
||||
|
||||
An example build session targeting the build platform could look like this:
|
||||
|
||||
```
|
||||
mkdir /tmp/build.paho
|
||||
cd /tmp/build.paho
|
||||
cmake -GNinja -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_DOCUMENTATION=TRUE -DPAHO_BUILD_SAMPLES=TRUE ~/git/org.eclipse.paho.mqtt.c
|
||||
```
|
||||
|
||||
Invoking cmake and specifying build options can also be performed using cmake-gui or ccmake (see https://cmake.org/runningcmake/). For example:
|
||||
|
||||
```
|
||||
ccmake -GNinja ~/git/org.eclipse.paho.mqtt.c
|
||||
```
|
||||
|
||||
To compile/link the binaries and to generate packages, simply invoke `ninja package` or `make -j <number-of-cores-to-use> package` after CMake. To simply compile/link invoke `ninja` or `make -j <number-of-cores-to-use>`.
|
||||
|
||||
### Debug builds
|
||||
|
||||
Debug builds can be performed by defining the value of the ```CMAKE_BUILD_TYPE``` option to ```Debug```. For example:
|
||||
|
||||
```
|
||||
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug git/org.eclipse.paho.mqtt.c
|
||||
```
|
||||
|
||||
### Cross compilation
|
||||
|
||||
Cross compilation using CMake is performed by using so called "toolchain files" (see: http://www.vtk.org/Wiki/CMake_Cross_Compiling).
|
||||
|
||||
The path to the toolchain file can be specified by using CMake's `-DCMAKE_TOOLCHAIN_FILE` option. In case no toolchain file is specified, the build is performed for the native build platform.
|
||||
|
||||
For your convenience toolchain files for the following platforms can be found in the `cmake` directory of Eclipse Paho:
|
||||
* Linux x86
|
||||
* Linux ARM11 (a.k.a. the Raspberry Pi)
|
||||
* Windows x86_64
|
||||
* Windows x86
|
||||
|
||||
The provided toolchain files assume that required compilers/linkers are to be found in the environment, i. e. the PATH-Variable of your user or system. If you prefer, you can also specify the absolute location of your compilers in the toolchain files.
|
||||
|
||||
Example invocation for the Raspberry Pi:
|
||||
|
||||
```
|
||||
cmake -GNinja -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_SAMPLES=TRUE -DPAHO_BUILD_DOCUMENTATION=TRUE -DOPENSSL_LIB_SEARCH_PATH=/tmp/libssl-dev/usr/lib/arm-linux-gnueabihf -DOPENSSL_INC_SEARCH_PATH="/tmp/libssl-dev/usr/include/openssl;/tmp/libssl-dev/usr/include/arm-linux-gnueabihf" -DCMAKE_TOOLCHAIN_FILE=~/git/org.eclipse.paho.mqtt.c/cmake/toolchain.linux-arm11.cmake ~/git/org.eclipse.paho.mqtt.c
|
||||
```
|
||||
|
||||
Compilers for the Raspberry Pi can be obtained from e. g. Linaro (see: http://releases.linaro.org/15.06/components/toolchain/binaries/4.8/arm-linux-gnueabihf/). This example assumes that OpenSSL-libraries and includes have been installed in the ```/tmp/libssl-dev``` directory.
|
||||
|
||||
Example invocation for Windows 64 bit:
|
||||
|
||||
```
|
||||
cmake -GNinja -DPAHO_BUILD_SAMPLES=TRUE -DCMAKE_TOOLCHAIN_FILE=~/git/org.eclipse.paho.mqtt.c/cmake/toolchain.win64.cmake ~/git/org.eclipse.paho.mqtt.c
|
||||
|
||||
```
|
||||
|
||||
In this case the libraries and executable are not linked against OpenSSL Libraries. Cross compilers for the Windows platform can be installed on Debian like systems like this:
|
||||
|
||||
```
|
||||
apt-get install gcc-mingw-w64-x86-64 gcc-mingw-w64-i686
|
||||
```
|
||||
|
||||
|
||||
## Build instructions for GNU Make (deprecated)
|
||||
|
||||
The provided GNU Makefile is intended to perform all build steps in the ```build``` directory within the source-tree of Eclipse Paho. Generated binares, libraries, and the documentation can be found in the ```build/output``` directory after completion.
|
||||
|
||||
Options that are passed to the compiler/linker can be specified by typical Unix build variables:
|
||||
|
||||
Variable | Description
|
||||
------------ | -------------
|
||||
CC | Path to the C compiler
|
||||
CFLAGS | Flags passed to compiler calls
|
||||
LDFLAGS | Flags passed to linker calls
|
||||
|
||||
## Libraries
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
# path to compiler and utilities
|
||||
# specify the cross compiler
|
||||
SET(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
|
||||
|
||||
# Name of the target platform
|
||||
SET(CMAKE_SYSTEM_NAME Linux)
|
||||
SET(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
|
||||
# Version of the system
|
||||
SET(CMAKE_SYSTEM_VERSION 1)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# Name of the target platform
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
# Version of the system
|
||||
SET(CMAKE_SYSTEM_VERSION 1)
|
||||
|
||||
# specify the cross compiler
|
||||
SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
|
||||
SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
|
||||
SET(CMAKE_RC_COMPILER_ENV_VAR "RC")
|
||||
SET(CMAKE_RC_COMPILER "")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS
|
||||
"-fdata-sections -ffunction-sections -Wl,--enable-stdcall-fixup -static-libgcc -static -lpthread" CACHE STRING "" FORCE)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS
|
||||
"-fdata-sections -ffunction-sections -Wl,--enable-stdcall-fixup -static-libgcc -static -lpthread" CACHE STRING "" FORCE)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# Name of the target platform
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
# Version of the system
|
||||
SET(CMAKE_SYSTEM_VERSION 1)
|
||||
|
||||
# specify the cross compiler
|
||||
SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
||||
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
|
||||
SET(CMAKE_RC_COMPILER_ENV_VAR "RC")
|
||||
SET(CMAKE_RC_COMPILER "")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS
|
||||
"-fdata-sections -ffunction-sections -Wl,--enable-stdcall-fixup -static-libgcc -static -lpthread" CACHE STRING "" FORCE)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS
|
||||
"-fdata-sections -ffunction-sections -Wl,--enable-stdcall-fixup -static-libgcc -static -lpthread" CACHE STRING "" FORCE)
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
#*******************************************************************************
|
||||
# Copyright (c) 2015 logi.cals GmbH
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||
#
|
||||
# The Eclipse Public License is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
# and the Eclipse Distribution License is available at
|
||||
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
#
|
||||
# Contributors:
|
||||
# Rainer Poisel - initial version
|
||||
#*******************************************************************************/
|
||||
|
||||
# Note: on OS X you should install XCode and the associated command-line tools
|
||||
|
||||
### documentation settings
|
||||
FIND_PACKAGE(Doxygen)
|
||||
IF(NOT DOXYGEN_FOUND)
|
||||
message(FATAL_ERROR "Doxygen is needed to build the documentation.")
|
||||
ENDIF()
|
||||
SET(DOXYTARGETS)
|
||||
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc)
|
||||
FOREACH(DOXYFILE_SRC DoxyfileV3ClientAPI;DoxyfileV3AsyncAPI;DoxyfileV3ClientInternal)
|
||||
SET(DOXYFILE_IN ${DOXYFILE_SRC}.in)
|
||||
SET(DOXYFILE ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE_SRC})
|
||||
|
||||
CONFIGURE_FILE(${DOXYFILE_IN} ${DOXYFILE} @ONLY)
|
||||
ADD_CUSTOM_TARGET(${DOXYFILE_SRC}.target
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen"
|
||||
VERBATIM
|
||||
)
|
||||
SET(DOXYTARGETS ${DOXYTARGETS} ${DOXYFILE_SRC}.target)
|
||||
ENDFOREACH(DOXYFILE_SRC)
|
||||
ADD_CUSTOM_TARGET(doc ALL DEPENDS ${DOXYTARGETS})
|
||||
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc DESTINATION share)
|
||||
|
|
@ -45,14 +45,14 @@ PROJECT_BRIEF =
|
|||
# exceed 55 pixels and the maximum width should not exceed 200 pixels.
|
||||
# Doxygen will copy the logo to the output directory.
|
||||
|
||||
PROJECT_LOGO = "../doc/pahologo.png"
|
||||
PROJECT_LOGO = "@PROJECT_SOURCE_DIR@/doc/pahologo.png"
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
# If a relative path is entered, it will be relative to the location
|
||||
# where doxygen was started. If left blank the current directory will be used.
|
||||
|
||||
OUTPUT_DIRECTORY = "../build/output/doc/MQTTAsync/"
|
||||
OUTPUT_DIRECTORY = "@CMAKE_CURRENT_BINARY_DIR@/doc/MQTTAsync/"
|
||||
|
||||
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
|
||||
# 4096 sub-directories (in 2 levels) under the output directory of each output
|
||||
|
|
@ -665,8 +665,9 @@ WARN_LOGFILE =
|
|||
# directories like "/usr/src/myproject". Separate the files or directories
|
||||
# with spaces.
|
||||
|
||||
INPUT = MQTTAsync.h \
|
||||
MQTTClientPersistence.h
|
||||
STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@/src
|
||||
INPUT = @PROJECT_SOURCE_DIR@/src/MQTTAsync.h \
|
||||
@PROJECT_SOURCE_DIR@/src/MQTTClientPersistence.h
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
|
||||
|
|
@ -45,14 +45,14 @@ PROJECT_BRIEF =
|
|||
# exceed 55 pixels and the maximum width should not exceed 200 pixels.
|
||||
# Doxygen will copy the logo to the output directory.
|
||||
|
||||
PROJECT_LOGO = "../doc/pahologo.png"
|
||||
PROJECT_LOGO = "@PROJECT_SOURCE_DIR@/doc/pahologo.png"
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
# If a relative path is entered, it will be relative to the location
|
||||
# where doxygen was started. If left blank the current directory will be used.
|
||||
|
||||
OUTPUT_DIRECTORY = "../build/output/doc/MQTTClient/"
|
||||
OUTPUT_DIRECTORY = "@CMAKE_CURRENT_BINARY_DIR@/doc/MQTTClient/"
|
||||
|
||||
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
|
||||
# 4096 sub-directories (in 2 levels) under the output directory of each output
|
||||
|
|
@ -665,8 +665,9 @@ WARN_LOGFILE =
|
|||
# directories like "/usr/src/myproject". Separate the files or directories
|
||||
# with spaces.
|
||||
|
||||
INPUT = MQTTClient.h \
|
||||
MQTTClientPersistence.h
|
||||
STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@/src
|
||||
INPUT = @PROJECT_SOURCE_DIR@/src/MQTTClient.h \
|
||||
@PROJECT_SOURCE_DIR@/src/MQTTClientPersistence.h
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
|
||||
|
|
@ -45,14 +45,14 @@ PROJECT_BRIEF =
|
|||
# exceed 55 pixels and the maximum width should not exceed 200 pixels.
|
||||
# Doxygen will copy the logo to the output directory.
|
||||
|
||||
PROJECT_LOGO = "../doc/pahologo.png"
|
||||
PROJECT_LOGO = "@PROJECT_SOURCE_DIR@/doc/pahologo.png"
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
# If a relative path is entered, it will be relative to the location
|
||||
# where doxygen was started. If left blank the current directory will be used.
|
||||
|
||||
OUTPUT_DIRECTORY = "../build/output/doc/MQTTClient_internal/"
|
||||
OUTPUT_DIRECTORY = "@CMAKE_CURRENT_BINARY_DIR@/doc/MQTTClient_internal/"
|
||||
|
||||
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
|
||||
# 4096 sub-directories (in 2 levels) under the output directory of each output
|
||||
|
|
@ -665,7 +665,9 @@ WARN_LOGFILE =
|
|||
# directories like "/usr/src/myproject". Separate the files or directories
|
||||
# with spaces.
|
||||
|
||||
INPUT = "."
|
||||
STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@/src
|
||||
INPUT = @PROJECT_SOURCE_DIR@/src
|
||||
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
#*******************************************************************************
|
||||
# Copyright (c) 2015 logi.cals GmbH
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||
#
|
||||
# The Eclipse Public License is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
# and the Eclipse Distribution License is available at
|
||||
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
#
|
||||
# Contributors:
|
||||
# Rainer Poisel - initial version
|
||||
#*******************************************************************************/
|
||||
|
||||
# Note: on OS X you should install XCode and the associated command-line tools
|
||||
|
||||
## compilation/linkage settings
|
||||
INCLUDE_DIRECTORIES(
|
||||
.
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
CONFIGURE_FILE(VersionInfo.h.in
|
||||
${CMAKE_BINARY_DIR}/VersionInfo.h
|
||||
@ONLY
|
||||
)
|
||||
|
||||
SET(common_src
|
||||
MQTTProtocolClient.c
|
||||
Clients.c
|
||||
utf-8.c
|
||||
StackTrace.c
|
||||
MQTTPacket.c
|
||||
MQTTPacketOut.c
|
||||
Messages.c
|
||||
Tree.c
|
||||
Socket.c
|
||||
Log.c
|
||||
MQTTPersistence.c
|
||||
Thread.c
|
||||
MQTTProtocolOut.c
|
||||
MQTTPersistenceDefault.c
|
||||
SocketBuffer.c
|
||||
Heap.c
|
||||
LinkedList.c
|
||||
)
|
||||
|
||||
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
SET(LIBS_SYSTEM ws2_32)
|
||||
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
SET(LIBS_SYSTEM dl)
|
||||
ENDIF()
|
||||
|
||||
ADD_EXECUTABLE(MQTTVersion MQTTVersion.c)
|
||||
ADD_LIBRARY(paho-mqtt3c SHARED ${common_src} MQTTClient.c)
|
||||
ADD_LIBRARY(paho-mqtt3a SHARED ${common_src} MQTTAsync.c)
|
||||
TARGET_LINK_LIBRARIES(paho-mqtt3c pthread ${LIBS_SYSTEM})
|
||||
TARGET_LINK_LIBRARIES(paho-mqtt3a pthread ${LIBS_SYSTEM})
|
||||
TARGET_LINK_LIBRARIES(MQTTVersion paho-mqtt3a paho-mqtt3c ${LIBS_SYSTEM})
|
||||
SET_TARGET_PROPERTIES(
|
||||
paho-mqtt3c paho-mqtt3a PROPERTIES
|
||||
VERSION ${CLIENT_VERSION}
|
||||
SOVERSION ${PAHO_VERSION_MAJOR})
|
||||
INSTALL(TARGETS paho-mqtt3c paho-mqtt3a MQTTVersion
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib)
|
||||
|
||||
IF (PAHO_WITH_SSL)
|
||||
SET(OPENSSL_LIB_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL libraries")
|
||||
SET(OPENSSL_INC_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL includes")
|
||||
SET(OPENSSL_LIBRARIES ssl crypto)
|
||||
LINK_DIRECTORIES(
|
||||
${OPENSSL_LIB_SEARCH_PATH}
|
||||
)
|
||||
INCLUDE_DIRECTORIES(
|
||||
${OPENSSL_INC_SEARCH_PATH}
|
||||
)
|
||||
ADD_LIBRARY(paho-mqtt3cs SHARED ${common_src} MQTTClient.c SSLSocket.c)
|
||||
ADD_LIBRARY(paho-mqtt3as SHARED ${common_src} MQTTAsync.c SSLSocket.c)
|
||||
TARGET_LINK_LIBRARIES(paho-mqtt3cs pthread ${OPENSSL_LIBRARIES} ${LIBS_SYSTEM})
|
||||
TARGET_LINK_LIBRARIES(paho-mqtt3as pthread ${OPENSSL_LIBRARIES} ${LIBS_SYSTEM})
|
||||
SET_TARGET_PROPERTIES(
|
||||
paho-mqtt3cs paho-mqtt3as PROPERTIES
|
||||
VERSION ${CLIENT_VERSION}
|
||||
SOVERSION ${PAHO_VERSION_MAJOR})
|
||||
INSTALL(TARGETS paho-mqtt3cs
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib)
|
||||
INSTALL(TARGETS paho-mqtt3as
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib)
|
||||
ENDIF()
|
||||
|
||||
|
|
@ -55,8 +55,7 @@
|
|||
|
||||
#define URI_TCP "tcp://"
|
||||
|
||||
#define BUILD_TIMESTAMP "##MQTTCLIENT_BUILD_TAG##"
|
||||
#define CLIENT_VERSION "##MQTTCLIENT_VERSION_TAG##"
|
||||
#include <VersionInfo.h>
|
||||
|
||||
char* client_timestamp_eye = "MQTTAsyncV3_Timestamp " BUILD_TIMESTAMP;
|
||||
char* client_version_eye = "MQTTAsyncV3_Version " CLIENT_VERSION;
|
||||
|
|
|
|||
|
|
@ -62,8 +62,7 @@
|
|||
|
||||
#define URI_TCP "tcp://"
|
||||
|
||||
#define BUILD_TIMESTAMP "##MQTTCLIENT_BUILD_TAG##"
|
||||
#define CLIENT_VERSION "##MQTTCLIENT_VERSION_TAG##"
|
||||
#include <VersionInfo.h>
|
||||
|
||||
char* client_timestamp_eye = "MQTTClientV3_Timestamp " BUILD_TIMESTAMP;
|
||||
char* client_version_eye = "MQTTClientV3_Version " CLIENT_VERSION;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef VERSIONINFO_H
|
||||
#define VERSIONINFO_H
|
||||
|
||||
#define BUILD_TIMESTAMP "@BUILD_TIMESTAMP@"
|
||||
#define CLIENT_VERSION "@CLIENT_VERSION@"
|
||||
|
||||
#endif /* VERSIONINFO_H */
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#*******************************************************************************
|
||||
# Copyright (c) 2015 logi.cals GmbH
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||
#
|
||||
# The Eclipse Public License is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
# and the Eclipse Distribution License is available at
|
||||
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
#
|
||||
# Contributors:
|
||||
# Rainer Poisel - initial version
|
||||
#*******************************************************************************/
|
||||
|
||||
# Note: on OS X you should install XCode and the associated command-line tools
|
||||
|
||||
## compilation/linkage settings
|
||||
INCLUDE_DIRECTORIES(
|
||||
.
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
# sample files c
|
||||
ADD_EXECUTABLE(stdinpub stdinpub.c)
|
||||
ADD_EXECUTABLE(stdoutsub stdoutsub.c)
|
||||
ADD_EXECUTABLE(pubsync pubsync.c)
|
||||
ADD_EXECUTABLE(pubasync pubasync.c)
|
||||
ADD_EXECUTABLE(subasync subasync.c)
|
||||
|
||||
TARGET_LINK_LIBRARIES(stdinpub paho-mqtt3c)
|
||||
TARGET_LINK_LIBRARIES(stdoutsub paho-mqtt3c)
|
||||
TARGET_LINK_LIBRARIES(pubsync paho-mqtt3c)
|
||||
TARGET_LINK_LIBRARIES(pubasync paho-mqtt3c)
|
||||
TARGET_LINK_LIBRARIES(subasync paho-mqtt3c)
|
||||
|
||||
ADD_EXECUTABLE(stdoutsuba stdoutsuba.c)
|
||||
ADD_EXECUTABLE(MQTTAsync_subscribe MQTTAsync_subscribe.c)
|
||||
ADD_EXECUTABLE(MQTTAsync_publish MQTTAsync_publish.c)
|
||||
|
||||
TARGET_LINK_LIBRARIES(stdoutsuba paho-mqtt3a)
|
||||
TARGET_LINK_LIBRARIES(MQTTAsync_subscribe paho-mqtt3a)
|
||||
TARGET_LINK_LIBRARIES(MQTTAsync_publish paho-mqtt3a)
|
||||
|
||||
INSTALL(TARGETS stdinpub stdoutsub pubsync pubasync subasync stdoutsuba MQTTAsync_subscribe MQTTAsync_publish
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib)
|
||||
|
||||
Loading…
Reference in New Issue