paho.mqtt.cpp/CMakeLists.txt
David Wagner d16b94c646 cmake: modernize the build system
- Write a CMake module for finding and importing the Paho MQTT C library.
- Prepare the build system for exporting targets

Signed-off-by: David Wagner <david.wagner@easymile.com>
2018-04-23 17:29:09 +02:00

90 lines
2.5 KiB
CMake

# CMakeLists.txt
#
# Top-level CMake file for the Paho C++ library.
#
#*******************************************************************************
# This is part of the Paho MQTT C++ client library.
#
# Copyright (c) 2016-2017, Guilherme Maciel Ferreira
# Copyright (c) 2017, Frank Pagliughi
#
# 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:
# Guilherme Maciel Ferreira - initial version
# Frank Pagliughi
#*******************************************************************************/
## Note: on OS X you should install XCode and the associated command-line tools
## cmake flags
cmake_minimum_required(VERSION 3.1)
## project name
project("paho-mqtt-cpp" LANGUAGES CXX)
## library name
set(PAHO_MQTT_CPP paho-mqttpp3)
set(PAHO_MQTT_CPP_STATIC ${PAHO_MQTT_CPP}-static)
## build settings
set(PAHO_VERSION_MAJOR 1)
set(PAHO_VERSION_MINOR 0)
set(PAHO_VERSION_PATCH 0)
set(CLIENT_VERSION ${PAHO_VERSION_MAJOR}.${PAHO_VERSION_MINOR}.${PAHO_VERSION_PATCH})
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(GNUInstallDirs)
## --- Build options ---
if(WIN32)
option(PAHO_BUILD_STATIC "Build static library" TRUE)
option(PAHO_BUILD_SHARED "Build shared library (DLL)" FALSE)
option(PAHO_WITH_SSL "Build SSL-enabled library" FALSE)
else()
option(PAHO_BUILD_STATIC "Build static library" FALSE)
option(PAHO_BUILD_SHARED "Build shared library" TRUE)
option(PAHO_WITH_SSL "Build SSL-enabled library" TRUE)
endif()
option(PAHO_BUILD_SAMPLES "Build sample programs" FALSE)
option(PAHO_BUILD_DOCUMENTATION "Create and install the API documentation (requires Doxygen)" FALSE)
## --- C++11 build flags ---
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
## --- Build directories ---
# For the paho_mqtt_c module
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
add_subdirectory(src)
if(PAHO_BUILD_DOCUMENTATION)
add_subdirectory(doc)
endif()
## --- Packaging settings ---
if(WIN32)
set(CPACK_GENERATOR "ZIP")
elseif(UNIX)
set(CPACK_GENERATOR "TGZ")
endif()
include(CPack)