Skip to content

Commit 1c126b6

Browse files
Erwin Nindlpboettch
Erwin Nindl
authored andcommitted
Updates conanfile.py
1 parent e1e48dd commit 1c126b6

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

conanfile.py

+25-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def get_version():
1515
except:
1616
return None
1717

18-
1918
class JsonSchemaValidatorConan(ConanFile):
2019
name = 'JsonSchemaValidator'
2120
version = get_version()
@@ -24,34 +23,49 @@ class JsonSchemaValidatorConan(ConanFile):
2423
settings = 'os', 'compiler', 'build_type', 'arch'
2524
options = {
2625
'shared': [True, False],
27-
'fPIC': [True, False]
26+
'fPIC': [True, False],
27+
'build_examples': [True, False],
28+
'build_tests': [True, False]
2829
}
2930
default_options = {
3031
'shared': False,
31-
'fPIC': True
32+
'fPIC': True,
33+
'build_examples': True,
34+
'build_tests': False
3235
}
33-
generators = "cmake"
36+
generators = "CMakeDeps"
3437
exports_sources = [
3538
'CMakeLists.txt',
3639
'nlohmann_json_schema_validatorConfig.cmake.in',
3740
'src/*',
3841
'app/*',
42+
'test/*',
3943
]
40-
4144
requires = (
42-
'nlohmann_json/3.7.3'
45+
'nlohmann_json/3.11.2'
4346
)
47+
_cmake = None
48+
49+
def _configure_cmake(self):
50+
if self._cmake:
51+
return self._cmake
52+
self._cmake = CMake(self)
53+
self._cmake.definitions['JSON_VALIDATOR_BUILD_EXAMPLES'] = self.options.build_examples
54+
self._cmake.definitions['JSON_VALIDATOR_BUILD_TESTS'] = self.options.build_tests
55+
self._cmake.configure()
56+
return self._cmake
57+
58+
def layout(self):
59+
build_type = str(self.settings.build_type).lower()
60+
self.folders.build = "build-{}".format(build_type)
4461

4562
def build(self):
46-
cmake = CMake(self)
47-
cmake.definitions['nlohmann_json_DIR'] = os.path.join(self.deps_cpp_info['nlohmann_json'].rootpath, 'include')
48-
cmake.definitions['JSON_VALIDATOR_BUILD_EXAMPLES'] = True
49-
cmake.definitions['JSON_VALIDATOR_BUILD_TESTS'] = False
63+
cmake = self._configure_cmake()
5064
cmake.configure()
5165
cmake.build()
5266

5367
def package(self):
54-
cmake = CMake(self)
68+
cmake = self._configure_cmake()
5569
cmake.install()
5670

5771
def package_info(self):

0 commit comments

Comments
 (0)