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

Add cppzmq/4.5.0 recipe #491

Merged
merged 1 commit into from
Jan 31, 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/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)
8 changes: 8 additions & 0 deletions recipes/cppzmq/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sources:
"4.5.0":
url: "https://github.com/zeromq/cppzmq/archive/v4.5.0.tar.gz"
sha256: "64eb4e58eaf0c77505391c6c9a606cffcb57c6086f3431567a1ef4a25b01fa36"
patches:
"4.5.0":
- base_path: "source_subfolder"
patch_file: "patches/0001-cmakelists-alias-libzmq-no-export.patch"
51 changes: 51 additions & 0 deletions recipes/cppzmq/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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", "patches/**"
generators = "cmake", "cmake_find_package"
requires = "zeromq/4.3.2"

_cmake = None

@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):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["CPPZMQ_BUILD_TESTS"] = False
self._cmake.configure()
return self._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"))

def package_id(self):
self.info.header_only()
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -7,6 +7,10 @@
project(cppzmq VERSION ${DETECTED_CPPZMQ_VERSION})

find_package(ZeroMQ QUIET)
+add_library(libzmq INTERFACE)
+target_link_libraries(libzmq INTERFACE ZeroMQ::ZeroMQ)
+add_library(libzmq-static INTERFACE)
+target_link_libraries(libzmq-static INTERFACE ZeroMQ::ZeroMQ)

# libzmq autotools install: fallback to pkg-config
if(NOT ZeroMQ_FOUND)
@@ -68,17 +72,12 @@
libzmq-pkg-config/FindZeroMQ.cmake
COPYONLY)

-export(EXPORT ${PROJECT_NAME}-targets
- FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
configure_package_config_file(${PROJECT_NAME}Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CPPZMQ_CMAKECONFIG_INSTALL_DIR})
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${CPPZMQ_VERSION}
COMPATIBILITY AnyNewerVersion)
-install(EXPORT ${PROJECT_NAME}-targets
- FILE ${PROJECT_NAME}Targets.cmake
- DESTINATION ${CPPZMQ_CMAKECONFIG_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CPPZMQ_CMAKECONFIG_INSTALL_DIR})
11 changes: 11 additions & 0 deletions recipes/cppzmq/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 2.8.12)
project(test_package)

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})

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