-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #491 from madebr/cppzmq
Add cppzmq/4.5.0 recipe
- Loading branch information
Showing
8 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,7 @@ | ||
cmake_minimum_required(VERSION 2.8.12) | ||
project(cmake_wrapper) | ||
|
||
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") | ||
conan_basic_setup() | ||
|
||
add_subdirectory(source_subfolder) |
This file contains 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 @@ | ||
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" |
This file contains 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,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() |
31 changes: 31 additions & 0 deletions
31
recipes/cppzmq/all/patches/0001-cmakelists-alias-libzmq-no-export.patch
This file contains 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,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}) |
This file contains 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,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}) | ||
|
This file contains 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 @@ | ||
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) |
This file contains 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,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; | ||
} |
This file contains 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: | ||
"4.5.0": | ||
folder: all |