refine conan requirements and packaging
This commit is contained in:
parent
5a1e58bbdf
commit
3ae26b5430
1 changed files with 26 additions and 9 deletions
33
conanfile.py
33
conanfile.py
|
@ -22,22 +22,39 @@ class NameofConan(ConanFile):
|
||||||
exports_sources = ['example/*','include/*','test/*','CMakeLists.txt','LICENSE']
|
exports_sources = ['example/*','include/*','test/*','CMakeLists.txt','LICENSE']
|
||||||
exports = ['LICENSE.md']
|
exports = ['LICENSE.md']
|
||||||
_build_subfolder = 'build_subfolder'
|
_build_subfolder = 'build_subfolder'
|
||||||
build_requires = 'Catch2/2.9.1@catchorg/stable'
|
settings = ('os', 'compiler', 'build_type', 'arch')
|
||||||
|
options = {
|
||||||
|
'build_tests': [True, False],
|
||||||
|
'build_examples': [True, False],
|
||||||
|
}
|
||||||
|
default_options = {
|
||||||
|
'build_tests': False,
|
||||||
|
'build_examples': False,
|
||||||
|
}
|
||||||
|
|
||||||
def configure_cmake(self, build_tests_and_examples):
|
def requirements(self):
|
||||||
|
if self.options.build_tests:
|
||||||
|
self.requires('Catch2/2.9.1@catchorg/stable')
|
||||||
|
|
||||||
|
def config_options(self):
|
||||||
|
needs_build = self.options.build_tests or self.options.build_examples
|
||||||
|
if not needs_build:
|
||||||
|
# remove all build settings since it is a header-only library
|
||||||
|
self.options.remove(['os', 'compiler', 'build_type', 'arch'])
|
||||||
|
|
||||||
|
def configure_cmake(self):
|
||||||
cmake = CMake(self)
|
cmake = CMake(self)
|
||||||
if self.develop:
|
cmake.definitions['NAMEOF_OPT_BUILD_TESTS'] = self.options.build_tests
|
||||||
self.output.info("Develop mode on, building with tests and examples")
|
cmake.definitions['NAMEOF_OPT_BUILD_EXAMPLES'] = self.options.build_examples
|
||||||
cmake.definitions['NAMEOF_OPT_BUILD_TESTS'] = build_tests_and_examples
|
|
||||||
cmake.definitions['NAMEOF_OPT_BUILD_EXAMPLES'] = build_tests_and_examples
|
|
||||||
cmake.configure(build_folder=self._build_subfolder)
|
cmake.configure(build_folder=self._build_subfolder)
|
||||||
return cmake
|
return cmake
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
cmake = self.configure_cmake(build_tests_and_examples = True)
|
cmake = self.configure_cmake()
|
||||||
cmake.build()
|
cmake.build()
|
||||||
|
if self.options.build_tests:
|
||||||
cmake.test()
|
cmake.test()
|
||||||
|
|
||||||
def package(self):
|
def package(self):
|
||||||
cmake = self.configure_cmake(build_tests_and_examples = False)
|
cmake = self.configure_cmake()
|
||||||
cmake.install()
|
cmake.install()
|
||||||
|
|
Loading…
Reference in a new issue