Updates conanfile.py

This commit is contained in:
Erwin Nindl 2022-09-02 13:13:58 +02:00 committed by Patrick Boettcher
parent e1e48ddbe0
commit 1c126b6f3d

View File

@ -15,7 +15,6 @@ def get_version():
except: except:
return None return None
class JsonSchemaValidatorConan(ConanFile): class JsonSchemaValidatorConan(ConanFile):
name = 'JsonSchemaValidator' name = 'JsonSchemaValidator'
version = get_version() version = get_version()
@ -24,34 +23,49 @@ class JsonSchemaValidatorConan(ConanFile):
settings = 'os', 'compiler', 'build_type', 'arch' settings = 'os', 'compiler', 'build_type', 'arch'
options = { options = {
'shared': [True, False], 'shared': [True, False],
'fPIC': [True, False] 'fPIC': [True, False],
'build_examples': [True, False],
'build_tests': [True, False]
} }
default_options = { default_options = {
'shared': False, 'shared': False,
'fPIC': True 'fPIC': True,
'build_examples': True,
'build_tests': False
} }
generators = "cmake" generators = "CMakeDeps"
exports_sources = [ exports_sources = [
'CMakeLists.txt', 'CMakeLists.txt',
'nlohmann_json_schema_validatorConfig.cmake.in', 'nlohmann_json_schema_validatorConfig.cmake.in',
'src/*', 'src/*',
'app/*', 'app/*',
'test/*',
] ]
requires = ( requires = (
'nlohmann_json/3.7.3' 'nlohmann_json/3.11.2'
) )
_cmake = None
def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions['JSON_VALIDATOR_BUILD_EXAMPLES'] = self.options.build_examples
self._cmake.definitions['JSON_VALIDATOR_BUILD_TESTS'] = self.options.build_tests
self._cmake.configure()
return self._cmake
def layout(self):
build_type = str(self.settings.build_type).lower()
self.folders.build = "build-{}".format(build_type)
def build(self): def build(self):
cmake = CMake(self) cmake = self._configure_cmake()
cmake.definitions['nlohmann_json_DIR'] = os.path.join(self.deps_cpp_info['nlohmann_json'].rootpath, 'include')
cmake.definitions['JSON_VALIDATOR_BUILD_EXAMPLES'] = True
cmake.definitions['JSON_VALIDATOR_BUILD_TESTS'] = False
cmake.configure() cmake.configure()
cmake.build() cmake.build()
def package(self): def package(self):
cmake = CMake(self) cmake = self._configure_cmake()
cmake.install() cmake.install()
def package_info(self): def package_info(self):