MQTTSuite
Loading...
Searching...
No Matches
conanfile.py
Go to the documentation of this file.
1import os
2import re
3
4from conan import ConanFile
5from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
6from conans.tools import load
7from conans import tools as ctools
8
10 try:
11 version = os.getenv('PROJECT_VERSION', None)
12 if version:
13 return version
14
15 content = load('CMakeLists.txt')
16 version = re.search('set\‍(PROJECT_VERSION (.*)\‍)', content).group(1)
17 return version.strip()
18 except:
19 return None
20
21class JsonSchemaValidatorConan(ConanFile):
22 name = 'JsonSchemaValidator'
23 version = get_version()
24 url = 'https://github.com/pboettch/json-schema-validator'
25 license = 'MIT'
26
27 settings = 'os', 'compiler', 'build_type', 'arch'
28
29 options = {
30 'shared': [True, False],
31 'fPIC': [True, False],
32 'build_examples': [True, False],
33 'build_tests': [True, False],
34 'test_coverage': [True, False],
35 }
36
37 default_options = {
38 'shared': False,
39 'fPIC': True,
40 'build_examples': True,
41 'build_tests': False,
42 'test_coverage': False,
43 }
44
45 generators = 'CMakeDeps', 'CMakeToolchain', 'VirtualBuildEnv', 'VirtualRunEnv'
46
47 exports_sources = [
48 'CMakeLists.txt',
49 'conanfile.py',
50 'cmake/*',
51 'src/*',
52 'example/*',
53 'test/*',
54 ]
55
56 requires = [
57 'nlohmann_json/3.11.2'
58 ]
59
60 def generate(self):
61 tc = CMakeToolchain(self)
62 tc.variables['JSON_VALIDATOR_BUILD_EXAMPLES'] = self.options.build_examples
63 tc.variables['JSON_VALIDATOR_BUILD_TESTS'] = self.options.build_tests
64 tc.variables['JSON_VALIDATOR_SHARED_LIBS '] = self.options.shared
65 tc.variables['JSON_VALIDATOR_TEST_COVERAGE '] = self.options.test_coverage
66 tc.generate()
67
68 def layout(self):
69 cmake_layout(self)
70
71 def build(self):
72 cmake = CMake(self)
73 cmake.configure()
74 cmake.verbose = True
75 cmake.build()
76
77 def package(self):
78 cmake = CMake(self)
79 cmake.install()
80
81 def package_info(self):
82 includedir = os.path.join(self.package_folder, "include")
83 self.cpp_info.includedirs = [includedir]
84
85 libdir = os.path.join(self.package_folder, "lib")
86 self.cpp_info.libdirs = [libdir]
87 self.cpp_info.libs += ctools.collect_libs(self, libdir)
88
89 bindir = os.path.join(self.package_folder, "bin")
90 self.output.info("Appending PATH environment variable: {}".format(bindir))
91 self.env_info.PATH.append(bindir)
92
93 self.user_info.VERSION = self.version
get_version()
Definition conanfile.py:9