|
1 |
| -import re |
2 |
| -import os |
3 | 1 | from conan import ConanFile
|
4 |
| -from conan.tools.files import load, copy, collect_libs |
5 |
| -from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps |
6 |
| -from conan.errors import ConanInvalidConfiguration |
7 |
| - |
8 | 2 |
|
9 | 3 | class InfluxdbCxxConan(ConanFile):
|
10 |
| - name = "influxdb-cxx" |
11 |
| - license = "MIT" |
12 |
| - author = "offa <offa@github>" |
13 |
| - url = "https://github.com/offa/influxdb-cxx" |
14 |
| - hompage = url |
15 |
| - description = "InfluxDB C++ client library." |
16 |
| - topics = ("influxdb", "influxdb-client") |
17 | 4 | settings = "os", "compiler", "build_type", "arch"
|
| 5 | + generators = "CMakeDeps", "CMakeToolchain" |
| 6 | + |
18 | 7 | options = {
|
19 |
| - "shared": [True, False], |
20 | 8 | "tests": [True, False],
|
21 | 9 | "system": [True, False],
|
22 | 10 | "boost": [True, False]
|
23 | 11 | }
|
24 | 12 | default_options = {
|
25 |
| - "shared": False, |
26 |
| - "tests": False, |
| 13 | + "tests": True, |
27 | 14 | "system": False,
|
28 | 15 | "boost": True,
|
29 | 16 | "boost/*:shared": True,
|
30 | 17 | }
|
31 |
| - exports = ["LICENSE"] |
32 |
| - exports_sources = ("CMakeLists.txt", "src/*", "include/*", "test/*", |
33 |
| - "cmake/*", "3rd-party/*") |
34 |
| - |
35 |
| - def set_version(self): |
36 |
| - cmake_lists_content = load( |
37 |
| - self, os.path.join(self.recipe_folder, "CMakeLists.txt")) |
38 |
| - project_match = re.search(r'project\s*\((.+?)\)', cmake_lists_content, |
39 |
| - re.DOTALL) |
40 |
| - |
41 |
| - if not project_match: |
42 |
| - raise ConanInvalidConfiguration( |
43 |
| - "No valid project() statement found in CMakeLists.txt") |
44 |
| - |
45 |
| - project_params = project_match.group(1).split() |
46 |
| - version_string = project_params[project_params.index("VERSION") + 1] |
47 |
| - |
48 |
| - if not re.search(r'\d+\.\d+\.\d+(?:\.\d)?', version_string): |
49 |
| - raise ConanInvalidConfiguration( |
50 |
| - "No valid version found in CMakeLists.txt") |
51 |
| - |
52 |
| - self.version = version_string |
53 |
| - self.output.info( |
54 |
| - f"Project version from CMakeLists.txt: '{self.version}'") |
55 | 18 |
|
56 | 19 | def requirements(self):
|
57 |
| - self.requires("cpr/1.10.0") |
| 20 | + self.requires("cpr/1.10.5") |
58 | 21 | if not self.options.system and self.options.boost:
|
59 |
| - self.requires("boost/1.81.0") |
| 22 | + self.requires("boost/1.85.0") |
60 | 23 | if self.options.tests:
|
61 |
| - self.requires("catch2/3.3.1") |
62 |
| - self.requires("trompeloeil/43") |
63 |
| - |
64 |
| - def generate(self): |
65 |
| - tc = CMakeToolchain(self) |
66 |
| - tc.cache_variables["INFLUXCXX_TESTING"] = self.options.tests |
67 |
| - tc.cache_variables["INFLUXCXX_WITH_BOOST"] = self.options.boost |
68 |
| - tc.generate() |
69 |
| - |
70 |
| - deps = CMakeDeps(self) |
71 |
| - deps.generate() |
72 |
| - |
73 |
| - def build(self): |
74 |
| - cmake = self._configure_cmake() |
75 |
| - cmake.build() |
76 |
| - |
77 |
| - if self.options.tests: |
78 |
| - cmake.test() |
79 |
| - |
80 |
| - def package(self): |
81 |
| - cmake = self._configure_cmake() |
82 |
| - cmake.install() |
83 |
| - copy(self, pattern="LICENSE", dst="licenses", src=self.source_folder) |
84 |
| - |
85 |
| - def package_info(self): |
86 |
| - self.cpp_info.libs = collect_libs(self) |
87 |
| - self.cpp_info.set_property("cmake_file_name", "InfluxDB") |
88 |
| - self.cpp_info.set_property("cmake_target_name", "InfluxData::InfluxDB") |
89 |
| - |
90 |
| - def _configure_cmake(self): |
91 |
| - cmake = CMake(self) |
92 |
| - cmake.configure() |
93 |
| - return cmake |
| 24 | + self.requires("catch2/3.7.1") |
| 25 | + self.requires("trompeloeil/48") |
0 commit comments