Skip to content

Commit 2104ddd

Browse files
committed
modern-cpp-kafka: new recipe
1 parent 8dd8e43 commit 2104ddd

File tree

6 files changed

+74
-0
lines changed

6 files changed

+74
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sources:
2+
"v2022.06.15":
3+
url: https://github.com/morganstanley/modern-cpp-kafka/archive/refs/tags/v2022.06.15.tar.gz
4+
sha256: 478fcf560057b7cf7b4be851838ebf0520806d057b172de23261606fce088d27
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from conans import ConanFile, tools
2+
import os
3+
4+
required_conan_version = ">=1.33.0"
5+
6+
7+
class ModernCppKafkaConan(ConanFile):
8+
name = "modern-cpp-kafka"
9+
description = "A C++ API for Kafka clients (i.e. KafkaProducer, KafkaConsumer, AdminClient)"
10+
license = "Apache License 2.0"
11+
topics = ("conan", "modern-cpp-kafka", "kafka", "librdkafka", "kafkaproducer", "kafkaconsumer")
12+
url = "https://github.com/conan-io/conan-center-index"
13+
homepage = "https://github.com/morganstanley/modern-cpp-kafka"
14+
exports_sources = "include/*"
15+
no_copy_source = True
16+
17+
@property
18+
def _source_subfolder(self):
19+
return "source_subfolder"
20+
21+
def source(self):
22+
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)
23+
24+
def package(self):
25+
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
26+
self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include"))
27+
28+
def package_id(self):
29+
self.info.header_only()
30+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
project(test_package)
3+
4+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
5+
conan_basic_setup()
6+
7+
find_package(RdKafka REQUIRED CONFIG)
8+
9+
add_executable(${PROJECT_NAME} test_package.cpp)
10+
target_link_libraries(${PROJECT_NAME} RdKafka::rdkafka)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from conans import ConanFile, CMake, tools
2+
import os
3+
4+
class TestPackageConan(ConanFile):
5+
settings = "os", "arch", "compiler", "build_type"
6+
generators = "cmake", "cmake_find_package_multi"
7+
8+
def requirements(self):
9+
self.requires("librdkafka/1.8.2")
10+
11+
def build(self):
12+
cmake = CMake(self)
13+
cmake.configure()
14+
cmake.build()
15+
16+
def test(self):
17+
if not tools.cross_building(self):
18+
bin_path = os.path.join("bin", "test_package")
19+
self.run(bin_path, run_environment=True)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "kafka/Utility.h"
2+
3+
#include <iostream>
4+
5+
int main()
6+
{
7+
std::cout << "librdkafka version: " << kafka::utility::getLibRdKafkaVersion() << std::endl;
8+
}

recipes/modern-cpp-kafka/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
versions:
2+
"v2022.06.15":
3+
folder: all

0 commit comments

Comments
 (0)