-
Notifications
You must be signed in to change notification settings - Fork 2k
modern-cpp-kafka: new recipe #11430
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
Merged
conan-center-bot
merged 8 commits into
conan-io:master
from
kenneth-jia:RecipeForModernCppKafka
Jul 21, 2022
Merged
modern-cpp-kafka: new recipe #11430
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
eed689c
modern-cpp-kafka: new recipe
kenneth-jia 01a8503
Apply suggestions from code review
kenneth-jia 6b8c0e8
Update recipes/modern-cpp-kafka/all/conanfile.py
kenneth-jia 3fc9902
modern-cpp-kafka: new recipe -- build test with c++17
kenneth-jia 1396f74
modern-cpp-kafka: update the requirements & validate, fix the text
kenneth-jia f5c2989
Update recipes/modern-cpp-kafka/all/test_package/conanfile.py
kenneth-jia 49a5db3
Update recipes/modern-cpp-kafka/all/test_package/conanfile.py
kenneth-jia acac571
Update recipes/modern-cpp-kafka/all/test_package/conanfile.py
kenneth-jia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"2022.06.15": | ||
url: https://github.com/morganstanley/modern-cpp-kafka/archive/refs/tags/v2022.06.15.tar.gz | ||
sha256: 478fcf560057b7cf7b4be851838ebf0520806d057b172de23261606fce088d27 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from conans import ConanFile, tools | ||
import os | ||
|
||
required_conan_version = ">=1.33.0" | ||
|
||
|
||
class ModernCppKafkaConan(ConanFile): | ||
name = "modern-cpp-kafka" | ||
description = "A C++ API for Kafka clients (i.e. KafkaProducer, KafkaConsumer, AdminClient)" | ||
license = "Apache-2.0" | ||
topics = ("kafka", "librdkafka", "kafkaproducer", "kafkaconsumer") | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/morganstanley/modern-cpp-kafka" | ||
settings = "arch", "build_type", "compiler", "os" | ||
no_copy_source = True | ||
|
||
def requirements(self): | ||
self.requires("librdkafka/1.8.2") | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
tools.check_min_cppstd(self, 17) | ||
|
||
def package(self): | ||
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) | ||
self.copy(pattern="*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) | ||
|
||
def package_id(self): | ||
self.info.header_only() | ||
|
||
def package_info(self): | ||
self.cpp_info.set_property("cmake_target_name", "ModernCppKafka::ModernCppKafka") | ||
|
||
self.cpp_info.names["cmake_find_package"] = "ModernCppKafka" | ||
self.cpp_info.names["cmake_find_package_multi"] = "ModernCppKafka" | ||
|
||
if self.settings.os in ["Linux", "Macos"]: | ||
self.cpp_info.system_libs.append("pthread") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
kenneth-jia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
find_package(ModernCppKafka REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} ModernCppKafka::ModernCppKafka) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# pylint: skip-file | ||
kenneth-jia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from conans import ConanFile, CMake, tools | ||
kenneth-jia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import os | ||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
kenneth-jia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "kafka/Utility.h" | ||
|
||
#include <iostream> | ||
|
||
int main() | ||
{ | ||
std::cout << "librdkafka version: " << kafka::utility::getLibRdKafkaVersion() << std::endl; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"2022.06.15": | ||
folder: all |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.