This repository has been archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
conanfile.py
74 lines (64 loc) · 2.9 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
# -*- coding: utf-8 -*-
import os
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
class PahocppConan(ConanFile):
name = "paho-cpp"
version = "1.0.1"
license = "EPL-1.0"
homepage = "https://github.com/eclipse/paho.mqtt.cpp"
description = "The open-source client implementations of MQTT and MQTT-SN"
url = "https://github.com/conan-community/conan-paho-cpp"
author = "Conan Communty"
topics = ("conan", "paho-cpp", "paho", "mqtt", "mqtt-sn")
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False],
"SSL": [True, False],
"fPIC": [True, False]}
default_options = {"shared": False, "SSL": False, "fPIC": True}
generators = "cmake"
exports = "LICENSE"
exports_sources = [
"CMakeLists.txt",
"0001-fix-cmake-module-path.patch",
"0002-fix-cmake-find-paho-mqtt-c-static.patch",
"0003-fix-paho-mqtt-cpp-config-cmake.patch"
]
requires = "paho-c/1.3.0@conan/stable"
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.settings.os == "Windows" and self.options.shared:
raise ConanInvalidConfiguration("Paho cpp can not be built as shared on Windows.")
self.options["paho-c"].shared = self.options.shared
self.options["paho-c"].SSL = self.options.SSL
@property
def _source_subfolder(self):
return "sources"
def source(self):
sha256 = "42faf223bf78300eaaa8fa7d0e1bc039ff5de2890a392b83973f1be59aa68ea3"
tools.get("%s/archive/v%s.zip" % (self.homepage, self.version), sha256=sha256)
os.rename("paho.mqtt.cpp-%s" % self.version, self._source_subfolder)
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["PAHO_BUILD_DOCUMENTATION"] = False
cmake.definitions["PAHO_BUILD_SAMPLES"] = False
cmake.definitions["PAHO_BUILD_STATIC"] = not self.options.shared
cmake.definitions["PAHO_BUILD_SHARED"] = self.options.shared
cmake.definitions["PAHO_WITH_SSL"] = self.options.SSL
cmake.configure()
return cmake
def build(self):
tools.patch(base_path=self._source_subfolder, patch_file="0001-fix-cmake-module-path.patch")
tools.patch(base_path=self._source_subfolder, patch_file="0002-fix-cmake-find-paho-mqtt-c-static.patch")
tools.patch(base_path=self._source_subfolder, patch_file="0003-fix-paho-mqtt-cpp-config-cmake.patch")
cmake = self._configure_cmake()
cmake.build()
def package(self):
for license_file in ["edl-v10", "epl-v10", "notice.html"]:
self.copy(license_file, src=self._source_subfolder, dst="licenses")
cmake = self._configure_cmake()
cmake.install()
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)