building header only libs tests and examples

This commit is contained in:
Balazs Benics 2019-07-28 22:04:16 +02:00
parent 4073167fa4
commit 707bb945fd
2 changed files with 16 additions and 21 deletions

View file

@ -4,14 +4,10 @@
from cpt.packager import ConanMultiPackager from cpt.packager import ConanMultiPackager
if __name__ == "__main__": if __name__ == "__main__":
options = { 'nameof:build_tests': True, 'nameof:build_examples': True }
always_true = lambda build: True
builder = ConanMultiPackager() builder = ConanMultiPackager()
builder.add_common_builds() builder.add_common_builds()
updated_builds = [] builder.update_build_if(always_true, new_options = options)
for settings, options, env_vars, build_requires, reference in builder.items:
options['prometheus-cpp:mode'] = 'pull'
updated_builds.append([settings, options, env_vars, build_requires])
options = options.copy()
options['prometheus-cpp:mode'] = 'push'
updated_builds.append([settings, options, env_vars, build_requires])
builder.builds = updated_builds
builder.run() builder.run()

View file

@ -3,7 +3,7 @@
from conans import ConanFile, tools, CMake from conans import ConanFile, tools, CMake
from conans.model.version import Version from conans.model.version import Version
from conans.errors import ConanException from conans.errors import ConanInvalidConfiguration
class NameofConan(ConanFile): class NameofConan(ConanFile):
name = 'nameof' name = 'nameof'
@ -12,6 +12,11 @@ class NameofConan(ConanFile):
topics = ( topics = (
'conan', 'conan',
'nameof', 'nameof',
'cplusplus',
'enum-to-string',
'serialization',
'reflection',
'header-only',
'introspection', 'introspection',
'compile-time' 'compile-time'
) )
@ -22,6 +27,7 @@ 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 = []
settings = ('os', 'compiler', 'build_type', 'arch') settings = ('os', 'compiler', 'build_type', 'arch')
options = { options = {
'build_tests': [True, False], 'build_tests': [True, False],
@ -50,21 +56,11 @@ class NameofConan(ConanFile):
def requirements(self): def requirements(self):
if self.options.build_tests: if self.options.build_tests:
self.requires('Catch2/2.9.1@catchorg/stable') self.build_requires.append('Catch2/2.9.1@catchorg/stable')
def configure(self): def configure(self):
if not self.supports_string_view: if not self.supports_string_view:
raise ConanException('The specified compiler must support C++17') raise ConanInvalidConfiguration('The specified compiler must support C++17')
def config_options(self):
needs_build = self.options.build_tests or self.options.build_examples
# remove all build settings since it is a header-only library
if not needs_build:
del self.options.os
del self.options.compiler
del self.options.build_type
del self.options.arch
def configure_cmake(self): def configure_cmake(self):
cmake = CMake(self) cmake = CMake(self)
@ -82,3 +78,6 @@ class NameofConan(ConanFile):
def package(self): def package(self):
cmake = self.configure_cmake() cmake = self.configure_cmake()
cmake.install() cmake.install()
def package_id(self):
self.info.header_only()