forked from eclipse-paho/paho.mqtt.c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
92 lines (83 loc) · 3.87 KB
/
conanfile.py
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
from conans import ConanFile, CMake, tools
class PahocConan(ConanFile):
name = "paho.mqtt.c"
version = "1.3.1"
license = "Eclipse Public License - v 1.0"
url = "https://github.com/eclipse/paho.mqtt.c"
description = """The Eclipse Paho project provides open-source client implementations of MQTT
and MQTT-SN messaging protocols aimed at new, existing, and emerging applications for the Internet
of Things (IoT)"""
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "SSL": [True, False], "asynchronous": [True, False]}
default_options = "shared=False", "SSL=False", "asynchronous=False"
generators = "cmake"
exports_sources = "*"
def requirements(self):
if self.options.SSL:
self.requires("OpenSSL/1.0.2n@conan/stable")
def build(self):
tools.replace_in_file("CMakeLists.txt", "PROJECT(\"paho\" C)", '''PROJECT("paho" C)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()''')
tools.replace_in_file("CMakeLists.txt", "ADD_SUBDIRECTORY(test)", "") # Disable tests
tools.replace_in_file("CMakeLists.txt",
"ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -DWIN32_LEAN_AND_MEAN -MD)",
"ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -DWIN32_LEAN_AND_MEAN)") # Allow other runtimes
cmake = CMake(self)
cmake.definitions["PAHO_BUILD_DOCUMENTATION"] = False
cmake.definitions["PAHO_BUILD_SAMPLES"] = False
cmake.definitions["PAHO_BUILD_DEB_PACKAGE"] = False
cmake.definitions["PAHO_BUILD_STATIC"] = not self.options.shared
cmake.definitions["PAHO_WITH_SSL"] = self.options.SSL
cmake.configure()
cmake.build()
def package(self):
self.copy("*e*l-v10", dst="licenses")
self.copy("*.h", dst="include", src="src")
self.copy("*paho*.dll", dst="bin", keep_path=False)
self.copy("*paho*.dylib", dst="lib", keep_path=False)
self.copy("*paho*.so*", dst="lib", keep_path=False)
self.copy("*paho*.a", dst="lib", keep_path=False)
self.copy("*paho*.lib", dst="lib", keep_path=False)
def package_info(self):
self.cpp_info.libs = []
if self.options.shared and self:
if self.options.asynchronous:
if self.options.SSL:
self.cpp_info.libs.append("paho-mqtt3as")
else:
self.cpp_info.libs.append("paho-mqtt3a")
else:
if self.options.SSL:
self.cpp_info.libs.append("paho-mqtt3cs")
else:
self.cpp_info.libs.append("paho-mqtt3c")
else:
if self.options.asynchronous:
if self.options.SSL:
self.cpp_info.libs.append("paho-mqtt3as")
else:
self.cpp_info.libs.append("paho-mqtt3a")
else:
if self.options.SSL:
self.cpp_info.libs.append("paho-mqtt3cs")
else:
self.cpp_info.libs.append("paho-mqtt3c")
if self.settings.os == "Windows":
if not self.options.shared:
self.cpp_info.libs.append("ws2_32")
if self.settings.compiler == "gcc":
self.cpp_info.libs.append("wsock32") # (MinGW) needed?
else:
if self.settings.os == "Linux":
self.cpp_info.libs.append("c")
self.cpp_info.libs.append("dl")
self.cpp_info.libs.append("pthread")
elif self.settings.os == "FreeBSD":
self.cpp_info.libs.append("compat")
self.cpp_info.libs.append("pthread")
else:
self.cpp_info.libs.append("c")
self.cpp_info.libs.append("pthread")
def configure(self):
del self.settings.compiler.libcxx