Skip to content

Instantly share code, notes, and snippets.

@vdeurzen
Created September 29, 2018 20:14
Show Gist options
  • Save vdeurzen/4dddf349d430fb9b59e06814f63d2b5c to your computer and use it in GitHub Desktop.
Save vdeurzen/4dddf349d430fb9b59e06814f63d2b5c to your computer and use it in GitHub Desktop.
from conans import ConanFile, CMake, tools
class CPPKafkaConan(ConanFile):
name = "cppkafka"
version = "0.1.6"
description = "A nice C++ wrapper around librdkafka"
license = "BSD-2"
settings = "os", "compiler", "build_type", "arch"
url = "https://github.com/mfontanini/cppkafka"
options = {"shared": [True, False]}
default_options = "shared=True"
generator = "cmake"
requires = (
'cmake_findboost_modular/0.1.0@bincrafters/stable',
'boost_program_options/1.66.0@bincrafters/stable',
'boost_optional/1.66.0@bincrafters/stable',
'librdkafka/0.11.4@blockport/stable'
)
def source(self):
# extend CMake include path with location of modular findBoost.
self.run("git clone https://github.com/mfontanini/cppkafka")
# tools.replace_in_file(
# 'cppkafka/CMakeLists.txt',
# "find_package(Boost REQUIRED ${FIND_PACKAGE_QUIET})",
# '''
# include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
# find_package(Boost REQUIRED ${FIND_PACKAGE_QUIET})
# '''
# )
def build(self):
cmake = CMake(self)
cmake.definitions['CPPKAFKA_CMAKE_VERBOSE'] = 'ON'
cmake.definitions['CPPKAFKA_BUILD_SHARED'] = self.options.shared
cmake.definitions['CPPKAFKA_DISABLE_TESTS'] = 'ON'
cmake.definitions['CPPKAFKA_DISABLE_EXAMPLES'] = 'ON'
cmake.definitions['RDKAFKA_INCLUDE_DIR'] = self.deps_cpp_info['librdkafka'].include_paths[0]
cmake.definitions['RDKAFKA_ROOT_DIR'] = self.deps_cpp_info['librdkafka'].rootpath
cmake.configure(source_folder="cppkafka")
cmake.build()
def package(self):
self.copy("*.hpp", dst="include", src="cppkafka/include")
self.copy("*.h", dst="include", src="cppkafka/include")
self.copy("*.so*", dst="lib", keep_path=False)
self.copy("*.a*", dst="lib", keep_path=False)
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
if self.settings.os == "Linux":
self.cpp_info.includedirs.extend(
["boost_program_options", "boost_optional"])
self.cpp_info.libs.extend(
["boost_program_options", "boost_optional"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment