forked from eclipse-paho/paho.mqtt.c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
114 lines (95 loc) · 4 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#*******************************************************************************
# Copyright (c) 2015, 2020 logi.cals GmbH and others
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# and Eclipse Distribution License v1.0 which accompany this distribution.
#
# The Eclipse Public License is available at
# https://www.eclipse.org/legal/epl-2.0/
# and the Eclipse Distribution License is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# Contributors:
# Rainer Poisel - initial version
# Genis Riera Perez - Add support for building debian package
#*******************************************************************************/
# Note: on OS X you should install XCode and the associated command-line tools
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
PROJECT("Eclipse Paho C" C)
MESSAGE(STATUS "CMake version: " ${CMAKE_VERSION})
MESSAGE(STATUS "CMake system name: " ${CMAKE_SYSTEM_NAME})
SET(CMAKE_SCRIPTS "${CMAKE_SOURCE_DIR}/cmake")
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
## build settings
file(READ version.major PAHO_VERSION_MAJOR)
file(READ version.minor PAHO_VERSION_MINOR)
file(READ version.patch PAHO_VERSION_PATCH)
SET(CLIENT_VERSION ${PAHO_VERSION_MAJOR}.${PAHO_VERSION_MINOR}.${PAHO_VERSION_PATCH})
INCLUDE(GNUInstallDirs)
STRING(TIMESTAMP BUILD_TIMESTAMP UTC)
MESSAGE(STATUS "Timestamp is ${BUILD_TIMESTAMP}")
IF (PAHO_HIGH_PERFORMANCE)
ADD_DEFINITIONS(-DHIGH_PERFORMANCE=1)
ENDIF()
IF(WIN32)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -DWIN32_LEAN_AND_MEAN -MD)
ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
ADD_DEFINITIONS(-DOSX)
ENDIF()
## build options
SET(PAHO_WITH_SSL FALSE CACHE BOOL "Flag that defines whether to build ssl-enabled binaries too. ")
SET(PAHO_BUILD_SHARED TRUE CACHE BOOL "Build shared library")
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_SAMPLES FALSE CACHE BOOL "Build sample programs")
SET(PAHO_BUILD_DEB_PACKAGE FALSE CACHE BOOL "Build debian package")
SET(PAHO_ENABLE_TESTING TRUE CACHE BOOL "Build tests and run")
SET(PAHO_ENABLE_CPACK TRUE CACHE BOOL "Enable CPack")
IF (NOT PAHO_BUILD_SHARED AND NOT PAHO_BUILD_STATIC)
MESSAGE(FATAL_ERROR "You must set either PAHO_BUILD_SHARED, PAHO_BUILD_STATIC, or both")
ENDIF()
IF(PAHO_BUILD_DEB_PACKAGE)
set(CMAKE_INSTALL_DOCDIR share/doc/libpaho-mqtt)
ENDIF()
ADD_SUBDIRECTORY(src)
IF(PAHO_BUILD_SAMPLES)
ADD_SUBDIRECTORY(src/samples)
ENDIF()
IF(PAHO_BUILD_DOCUMENTATION)
ADD_SUBDIRECTORY(doc)
ENDIF()
IF (PAHO_ENABLE_CPACK)
### packaging settings
FILE(GLOB samples "src/samples/*.c")
INSTALL(FILES ${samples} DESTINATION ${CMAKE_INSTALL_DOCDIR}/samples)
SET(CPACK_PACKAGE_VENDOR "Eclipse Paho")
SET(CPACK_PACKAGE_NAME "Eclipse-Paho-MQTT-C")
INSTALL(FILES CONTRIBUTING.md epl-v20 edl-v10 README.md notice.html DESTINATION ${CMAKE_INSTALL_DOCDIR})
IF (WIN32)
SET(CPACK_GENERATOR "ZIP")
ELSEIF(PAHO_BUILD_DEB_PACKAGE)
INSTALL(FILES CONTRIBUTING.md epl-v20 edl-v10 README.md notice.html DESTINATION ${CMAKE_INSTALL_DOCDIR})
SET(CPACK_GENERATOR "DEB")
CONFIGURE_FILE(${CMAKE_SCRIPTS}/CPackDebConfig.cmake.in
${CMAKE_BINARY_DIR}/CPackDebConfig.cmake @ONLY)
SET(CPACK_PROJECT_CONFIG_FILE ${CMAKE_BINARY_DIR}/CPackDebConfig.cmake)
ADD_SUBDIRECTORY(debian)
ELSE()
SET(CPACK_GENERATOR "TGZ")
ENDIF()
ELSE()
FILE(GLOB samples "src/samples/*.c")
INSTALL(FILES ${samples} DESTINATION ${CMAKE_INSTALL_DOCDIR})
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)
IF(PAHO_ENABLE_TESTING)
ENABLE_TESTING()
INCLUDE_DIRECTORIES(test src)
ADD_SUBDIRECTORY(test)
ELSE()
INCLUDE_DIRECTORIES(src)
ENDIF()