Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add libavrocpp/1.10.1 #4393

Merged
merged 15 commits into from
Feb 9, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

class LibavrocppConan(ConanFile):
name = "libavrocpp"
version = "1.10.1"
license = "Apache License 2.0"
license = "Apache-2.0"
url = "https://github.com/conan-io/conan-center-index"
description = "Avro is a data serialization system."
homepage = "https://avro.apache.org/"
Expand All @@ -22,37 +21,23 @@ class LibavrocppConan(ConanFile):
default_options = {"shared": False, "fPIC": True, "with_snappy": True}
generators = "cmake", "cmake_find_package"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
@property
def _source_subfolder(self):
return os.path.join("source_subfolder", "lang", "c++")

def configure(self):
if self.options.shared:
del self.options.fPIC
@property
def _build_subfolder(self):
return "build_subfolder"

compiler = str(self.settings.compiler)
compiler_version = Version(self.settings.compiler.version.value)

minimal_version = {
"Visual Studio": "10",
"gcc": "4.9.1",
"clang": "3.3",
"apple-clang": "5",
}

if compiler in minimal_version and compiler_version < minimal_version[compiler]:
raise ConanInvalidConfiguration(
"%s requires a compiler that supports"
" at least C++11. %s %s is not"
" supported." % (self.name, compiler, compiler_version)
)
_cmake = None

if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, "11")
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("avro-release-" + self.version, "source_subfolder")
def _configure_cmake(self):
if self._cmake:
return self._cmake
tools.replace_in_file(
plopp marked this conversation as resolved.
Show resolved Hide resolved
os.path.join(self._source_subfolder, "CMakeLists.txt"),
"project (Avro-cpp)",
Expand All @@ -67,34 +52,42 @@ def source(self):
"find_package(Snappy)",
"",
)
self._cmake = CMake(self)
self._cmake.configure(source_folder=self._source_subfolder)
return self._cmake

@property
def _source_subfolder(self):
return os.path.join("source_subfolder", "lang", "c++")

@property
def _build_subfolder(self):
return "build_subfolder"
def configure(self):
plopp marked this conversation as resolved.
Show resolved Hide resolved
if self.options.shared:
del self.options.fPIC
if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, "11")

def requirements(self):
self.requires("boost/[>=1.38.0]")

def build_requirements(self):
self.build_requires("boost/[>=1.38.0]")
plopp marked this conversation as resolved.
Show resolved Hide resolved
if self.options.with_snappy:
self.requires("snappy/1.1.8")
self.build_requires("snappy/1.1.8")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("avro-release-" + self.version, "source_subfolder")

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
self.copy("NOTICE", dst="licenses", src=self._source_subfolder)
cmake = CMake(self)
cmake.configure(source_folder=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
plopp marked this conversation as resolved.
Show resolved Hide resolved
self.cpp_info.components["avrocpp"].libs = ["avrocpp"]
self.cpp_info.components["avrocpp"].requires = ["boost::boost"]
if self.options.with_snappy:
self.cpp_info.components["avrocpp"].requires.append("snappy::snappy")

def build(self):
cmake = CMake(self)
cmake.configure(source_folder=self._source_subfolder)
cmake.build()
if self.options.shared:
self.cpp_info.components["avrocpp"].libs = ["avrocpp"]
self.cpp_info.components["avrocpp"].requires = ["boost::boost"]
else:
self.cpp_info.components["avrocpp_s"].libs = ["avrocpp_s"]
self.cpp_info.components["avrocpp_s"].requires = ["boost::boost"]
plopp marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

find_package(libavrocpp REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} libavrocpp::avrocpp)

set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)

if(AVROCPP_SHARED)
target_link_libraries(${PROJECT_NAME} libavrocpp::avrocpp)
else()
target_link_libraries(${PROJECT_NAME} libavrocpp::avrocpp_s)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class TestPackageConan(ConanFile):

def build(self):
cmake = CMake(self)
cmake.definitions["AVROCPP_SHARED"] = self.options["libavrocpp"].shared
cmake.configure()
cmake.build()

Expand Down
2 changes: 1 addition & 1 deletion recipes/libavrocpp/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
versions:
1.10.1:
folder: 1.10.1
folder: all