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

added msgpack #883

Merged
merged 3 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions recipes/msgpack/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.0)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory("source_subfolder")
4 changes: 4 additions & 0 deletions recipes/msgpack/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"3.2.1":
url: "https://github.com/msgpack/msgpack-c/archive/cpp-3.2.1.tar.gz"
sha256: "464f46744a6be778626d11452c4db3c2d09461080c6db42e358e21af19d542f6"
81 changes: 81 additions & 0 deletions recipes/msgpack/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
from conans import ConanFile, CMake, tools
import os


class MsgpackConan(ConanFile):
name = "msgpack"
description = "The official C++ library for MessagePack"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/msgpack/msgpack-c"
topics = ("conan", "msgpack", "message-pack", "serialization")
license = "BSL-1.0"
exports_sources = "CMakeLists.txt"
generators = "cmake"
settings = "os", "arch", "build_type", "compiler"
options = {"fPIC": [True, False], "shared": [True, False], "header_only": [True, False], "with_boost": [True, False]}
default_options = {"fPIC": True, "shared": False, "header_only": False, "with_boost": False}
_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
if self.options.header_only:
del self.options.shared
del self.options.fPIC
del self.options.with_boost

def requirements(self):
if not self.options.header_only and self.options.with_boost:
self.requires.add("boost/1.72.0")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = "msgpack-c-cpp-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["MSGPACK_BOOST"] = self.options.with_boost
self._cmake.definitions["MSGPACK_32BIT"] = self.settings.arch == "x86"
self._cmake.definitions["MSGPACK_BUILD_EXAMPLE"] = False
self._cmake.definitions["MSGPACK_BUILD_TESTS"] = False
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

def build(self):
if not self.options.header_only:
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("LICENSE_1_0.txt", dst="licenses", src=self._source_subfolder)
if self.options.header_only:
self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "include"))
self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include"))
else:
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))

def package_id(self):
if self.options.header_only:
self.info.header_only()

def package_info(self):
if not self.options.header_only:
self.cpp_info.libs = tools.collect_libs(self)
11 changes: 11 additions & 0 deletions recipes/msgpack/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
project(test_package)
cmake_minimum_required(VERSION 2.8.11)

set(CMAKE_VERBOSE_MAKEFILE TRUE)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
17 changes: 17 additions & 0 deletions recipes/msgpack/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
10 changes: 10 additions & 0 deletions recipes/msgpack/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <iostream>
#include <tuple>

#include <msgpack.hpp>

int main() {
msgpack::object obj(123);
std::cout << obj << "\n";
return 0;
}
3 changes: 3 additions & 0 deletions recipes/msgpack/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"3.2.1":
folder: all