-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconanfile.py
75 lines (62 loc) · 2.66 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
import re
import os
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
class InfluxdbCxxConan(ConanFile):
name = "influxdb-cxx"
license = "MIT"
author = "offa <offa@github>"
url = "https://github.com/offa/influxdb-cxx"
hompage = url
description = "InfluxDB C++ client library."
topics = ("influxdb", "influxdb-client")
settings = "os", "compiler", "build_type", "arch"
generators = ("cmake_find_package", "cmake_paths")
options = {"shared": [True, False],
"tests": [True, False],
"system": [True, False],
"boost": [True, False]}
default_options = {"shared": False,
"tests": False,
"system": False,
"boost": True,
"boost:shared": True,
"libcurl:shared": True}
exports = ["LICENSE"]
exports_sources = ("CMakeLists.txt", "src/*", "include/*", "test/*", "cmake/*", "3rd-party/*")
def set_version(self):
cmake_lists_content = tools.load(os.path.join(self.recipe_folder, "CMakeLists.txt"))
project_match = re.search(r'project\s*\((.+?)\)', cmake_lists_content, re.DOTALL)
if not project_match:
raise ConanInvalidConfiguration("No valid project() statement found in CMakeLists.txt")
project_params = project_match.group(1).split()
version_string = project_params[project_params.index("VERSION") + 1]
if not re.search(r'\d+\.\d+\.\d+(?:\.\d)?', version_string):
raise ConanInvalidConfiguration("No valid version found in CMakeLists.txt")
self.version = version_string
self.output.info(f"Project version from CMakeLists.txt: '{self.version}'")
def requirements(self):
if not self.options.system:
self.requires("libcurl/7.80.0")
if self.options.boost:
self.requires("boost/1.78.0")
if self.options.tests:
self.requires("catch2/2.13.9")
self.requires("trompeloeil/42")
def build(self):
cmake = self._configure_cmake()
cmake.build()
if self.options.tests:
cmake.test()
def package(self):
cmake = self._configure_cmake()
cmake.install()
self.copy("LICENSE", dst="licenses")
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["INFLUXCXX_TESTING"] = self.options.tests
cmake.definitions["INFLUXCXX_WITH_BOOST"] = self.options.boost
cmake.configure(build_folder="build")
return cmake