Skip to content

Commit

Permalink
Add czmq/4.2.0 recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Jan 29, 2020
1 parent dbf6094 commit 355cc83
Show file tree
Hide file tree
Showing 11 changed files with 508 additions and 0 deletions.
16 changes: 16 additions & 0 deletions recipes/czmq/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 2.8.12)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

if(MSVC)
add_definitions("-D_NOEXCEPT=noexcept")
endif()

add_subdirectory(source_subfolder)

foreach(TARGET zmakecert zsp test_randof czmq_selftest)
set_target_properties("${TARGET}"
PROPERTIES EXCLUDE_FROM_ALL ON)
endforeach()
14 changes: 14 additions & 0 deletions recipes/czmq/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sources:
"4.2.0":
url: "https://github.com/zeromq/czmq/archive/v4.2.0.tar.gz"
sha256: "31185090b500b64855003be2450ced00efa6b58544639acfc68aa13c9ec249f8"
patches:
"4.2.0":
- base_path: source_subfolder
patch_file: patches/0001-allow-cmake-subproject.patch
- base_path: source_subfolder
patch_file: patches/0002-dont-build-zmakecert.patch
- base_path: source_subfolder
patch_file: patches/0003-fix-cmake-find-package.patch
- base_path: source_subfolder
patch_file: patches/0004-make-czmq-link-using-cxx-compiler.patch
95 changes: 95 additions & 0 deletions recipes/czmq/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import os
from conans import ConanFile, tools, CMake


class CzmqConan(ConanFile):
name = "czmq"
homepage = "https://github.com/zeromq/czmq"
description = "ZeroMQ is a community of projects focused on decentralized messaging and computing"
topics = ("conan", "zmq", "libzmq", "message-queue", "asynchronous")
url = "https://github.com/conan-io/conan-center-index"
license = "MPL-2.0"
exports_sources = "CMakeLists.txt", "patches/**"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_libcurl": [True, False],
"with_lz4": [True, False],
"with_libuuid": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_libcurl": True,
"with_lz4": True,
"with_libuuid": True,
}
generators = "cmake"

_cmake = None
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
# libuuid is not available on Windows
del self.options.with_uuid

def configure(self):
if self.options.shared:
del self.options.fPIC

def requirements(self):
self.requires("openssl/1.1.1d") # zdigest depends on openssl
self.requires.add("zeromq/4.3.2")
if self.options.with_libcurl:
self.requires("libcurl/7.67.0")
if self.options.with_lz4:
self.requires.add("lz4/1.9.2")
if self.settings.os != "Windows":
if self.options.with_libuuid:
self.requires.add("libuuid/1.0.3")

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

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["CZMQ_BUILD_SHARED"] = self.options.shared
self._cmake.definitions["CZMQ_BUILD_STATIC"] = not self.options.shared
self._cmake.configure(build_folder=self._build_subfolder)
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", src=self._source_subfolder, dst="licenses")
cmake = self._configure_cmake()
cmake.install()

tools.rmdir(os.path.join(self.package_folder, "CMake"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))

def package_info(self):
if self.settings.compiler == "Visual Studio":
self.cpp_info.libs = ["czmq" if self.options.shared else "libczmq"]
self.cpp_info.system_libs.append("rpcrt4")
else:
self.cpp_info.libs = ["czmq"]
if self.settings.os == "Linux":
self.cpp_info.system_libs.extend(["pthread", "m"])
if not self.options.shared:
self.cpp_info.defines.append("CZMQ_STATIC")
92 changes: 92 additions & 0 deletions recipes/czmq/all/patches/0001-allow-cmake-subproject.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -74,7 +74,7 @@ endif()

file(REMOVE "${SOURCE_DIR}/src/platform.h")

-file(WRITE "${CMAKE_BINARY_DIR}/platform.h.in" "
+file(WRITE "${PROJECT_BINARY_DIR}/platform.h.in" "
#cmakedefine HAVE_LINUX_WIRELESS_H
#cmakedefine HAVE_NET_IF_H
#cmakedefine HAVE_NET_IF_MEDIA_H
@@ -82,7 +82,7 @@ file(WRITE "${CMAKE_BINARY_DIR}/platform.h.in" "
#cmakedefine HAVE_FREEIFADDRS
")

-configure_file("${CMAKE_BINARY_DIR}/platform.h.in" "${CMAKE_BINARY_DIR}/platform.h")
+configure_file("${PROJECT_BINARY_DIR}/platform.h.in" "${PROJECT_BINARY_DIR}/platform.h")

#The MSVC C compiler is too out of date,
#so the sources have to be compiled as c++
@@ -299,7 +299,7 @@ install(FILES ${czmq_headers} DESTINATION include)
########################################################################


-include_directories("${SOURCE_DIR}/src" "${SOURCE_DIR}/include" "${CMAKE_BINARY_DIR}")
+include_directories("${SOURCE_DIR}/src" "${SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}")
set (czmq_sources
src/zactor.c
src/zarmour.c
@@ -658,17 +658,17 @@ ENDIF (ENABLE_DRAFTS)

add_custom_target(
copy-selftest-ro ALL
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/src/selftest-ro ${CMAKE_BINARY_DIR}/src/selftest-ro
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/src/selftest-ro ${PROJECT_BINARY_DIR}/src/selftest-ro
)

add_custom_target(
make-selftest-rw ALL
- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/src/selftest-rw
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/src/selftest-rw
)

set_directory_properties(
PROPERTIES
- ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/src/selftest-ro;${CMAKE_BINARY_DIR}/src/selftest-rw"
+ ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_BINARY_DIR}/src/selftest-ro;${PROJECT_BINARY_DIR}/src/selftest-rw"
)

foreach(TEST_CLASS ${TEST_CLASSES})
@@ -693,22 +693,22 @@ include(CTest)
########################################################################
add_custom_target (distclean @echo Cleaning for source distribution)

-set(cmake_generated ${CMAKE_BINARY_DIR}/CMakeCache.txt
- ${CMAKE_BINARY_DIR}/cmake_install.cmake
- ${CMAKE_BINARY_DIR}/Makefile
- ${CMAKE_BINARY_DIR}/CMakeFiles
- ${CMAKE_BINARY_DIR}/CTestTestfile.cmake
- ${CMAKE_BINARY_DIR}/DartConfiguration.tcl
- ${CMAKE_BINARY_DIR}/Testing
- ${CMAKE_BINARY_DIR}/compile_commands.json
- ${CMAKE_BINARY_DIR}/platform.h
- ${CMAKE_BINARY_DIR}/src/libczmq.pc
- ${CMAKE_BINARY_DIR}/src/libczmq.so
- ${CMAKE_BINARY_DIR}/src/czmq_selftest
- ${CMAKE_BINARY_DIR}/src/zmakecert
- ${CMAKE_BINARY_DIR}/src/zsp
- ${CMAKE_BINARY_DIR}/src/test_randof
- ${CMAKE_BINARY_DIR}/src/czmq_selftest
+set(cmake_generated ${PROJECT_BINARY_DIR}/CMakeCache.txt
+ ${PROJECT_BINARY_DIR}/cmake_install.cmake
+ ${PROJECT_BINARY_DIR}/Makefile
+ ${PROJECT_BINARY_DIR}/CMakeFiles
+ ${PROJECT_BINARY_DIR}/CTestTestfile.cmake
+ ${PROJECT_BINARY_DIR}/DartConfiguration.tcl
+ ${PROJECT_BINARY_DIR}/Testing
+ ${PROJECT_BINARY_DIR}/compile_commands.json
+ ${PROJECT_BINARY_DIR}/platform.h
+ ${PROJECT_BINARY_DIR}/src/libczmq.pc
+ ${PROJECT_BINARY_DIR}/src/libczmq.so
+ ${PROJECT_BINARY_DIR}/src/czmq_selftest
+ ${PROJECT_BINARY_DIR}/src/zmakecert
+ ${PROJECT_BINARY_DIR}/src/zsp
+ ${PROJECT_BINARY_DIR}/src/test_randof
+ ${PROJECT_BINARY_DIR}/src/czmq_selftest
)

add_custom_command(
--
2.21.0

24 changes: 24 additions & 0 deletions recipes/czmq/all/patches/0002-dont-build-zmakecert.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -502,7 +502,7 @@
# executables
########################################################################
add_executable(
+ zmakecert EXCLUDE_FROM_ALL
- zmakecert
"${SOURCE_DIR}/src/zmakecert.c"
)
if (TARGET czmq)
@@ -522,9 +522,9 @@
${OPTIONAL_LIBRARIES_STATIC}
)
endif()
-install(TARGETS zmakecert
- RUNTIME DESTINATION bin
-)
+#install(TARGETS zmakecert
+# RUNTIME DESTINATION bin
+#)
add_executable(
zsp
"${SOURCE_DIR}/src/zsp.c"
Loading

0 comments on commit 355cc83

Please sign in to comment.