Skip to content

Commit

Permalink
Add cppzmq/4.5.0 recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Dec 14, 2019
1 parent 8a07dd9 commit 38fd3c3
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 0 deletions.
7 changes: 7 additions & 0 deletions recipes/cppzmq/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8.12)
project(cmake_wrapper)

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

add_subdirectory(source_subfolder)
6 changes: 6 additions & 0 deletions recipes/cppzmq/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sources:
"4.5.0":
url: "https://github.com/zeromq/cppzmq/archive/v4.5.0.tar.gz"
sha256: "64eb4e58eaf0c77505391c6c9a606cffcb57c6086f3431567a1ef4a25b01fa36"
patches:
"4.5.0": []
52 changes: 52 additions & 0 deletions recipes/cppzmq/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os
from conans import ConanFile, CMake, tools


class CppZmqConan(ConanFile):
name = "cppzmq"
description = "C++ binding for 0MQ"
homepage = "https://github.com/zeromq/cppzmq"
license = "MIT"
topics = ("conan", "cppzmq", "zmq-cpp", "zmq", "cpp-bind")
url = "https://github.com/conan-io/conan-center-index"
exports_sources = ["CMakeLists.txt", "cppzmq_extra.cmake"]
generators = "cmake", "cmake_find_package"
requires = "zeromq/4.3.2"

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

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("cppzmq-{}".format(self.version), self._source_subfolder)

def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["CPPZMQ_BUILD_TESTS"] = False
cmake.configure()
return cmake

def _patch_sources(self):
for patch in self.conan_data["patches"][self.version]:
tools.patch(**patch)

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

def package(self):
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

tools.rmdir(os.path.join(self.package_folder, "share"))
self.copy("cppzmq_extra.cmake", dst=os.path.join(self.package_folder, "lib", "cmake", "cppzmq"))

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

def package_info(self):
self.cpp_info.builddir = [os.path.join(self.package_folder, "lib", "cmake", "cppzmq")]
self.cpp_info.build_modules = [os.path.join(self.package_folder, "lib", "cmake", "cppzmq", "cppzmq_extra.cmake")]
9 changes: 9 additions & 0 deletions recipes/cppzmq/all/cppzmq_extra.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This script should only run when included in a FindXXX.cmake module
if(NOT cppzmq_LIB_DIRS)
return()
endif()

if(NOT TARGET cppzmq)
add_library(cppzmq INTERFACE IMPORTED)
set_property(TARGET cppzmq PROPERTY INTERFACE_LINK_LIBRARIES cppzmq::cppzmq)
endif()
16 changes: 16 additions & 0 deletions recipes/cppzmq/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 2.8.12)
project(test_package)

set(CMAKE_VERBOSE_MAKEFILE TRUE)

find_package(cppzmq REQUIRED)
if(NOT TARGET cppzmq)
message(FATAL_ERROR "Target cppzmq not found")
endif()

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

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})

17 changes: 17 additions & 0 deletions recipes/cppzmq/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", "cmake_find_package"

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)
13 changes: 13 additions & 0 deletions recipes/cppzmq/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <zmq.hpp>
#include <string>

int main ()
{
// Prepare our context and socket
zmq::context_t context (1);
zmq::socket_t socket (context, ZMQ_REQ);

socket.connect ("tcp://localhost:5555");

return 0;
}
3 changes: 3 additions & 0 deletions recipes/cppzmq/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"4.5.0":
folder: all

0 comments on commit 38fd3c3

Please sign in to comment.