Skip to content

Commit 6f40aa8

Browse files
committed
Change conanfile.py to consume only (#233)
1 parent 94ae527 commit 6f40aa8

File tree

1 file changed

+7
-75
lines changed

1 file changed

+7
-75
lines changed

conanfile.py

Lines changed: 7 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,25 @@
1-
import re
2-
import os
31
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-
82

93
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")
174
settings = "os", "compiler", "build_type", "arch"
5+
generators = "CMakeDeps", "CMakeToolchain"
6+
187
options = {
19-
"shared": [True, False],
208
"tests": [True, False],
219
"system": [True, False],
2210
"boost": [True, False]
2311
}
2412
default_options = {
25-
"shared": False,
26-
"tests": False,
13+
"tests": True,
2714
"system": False,
2815
"boost": True,
2916
"boost/*:shared": True,
3017
}
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}'")
5518

5619
def requirements(self):
57-
self.requires("cpr/1.10.0")
20+
self.requires("cpr/1.10.5")
5821
if not self.options.system and self.options.boost:
59-
self.requires("boost/1.81.0")
22+
self.requires("boost/1.85.0")
6023
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

Comments
 (0)