diff --git a/recipes/cppzmq/all/CMakeLists.txt b/recipes/cppzmq/all/CMakeLists.txt new file mode 100644 index 0000000000000..97030501e5bd7 --- /dev/null +++ b/recipes/cppzmq/all/CMakeLists.txt @@ -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) diff --git a/recipes/cppzmq/all/conandata.yml b/recipes/cppzmq/all/conandata.yml new file mode 100644 index 0000000000000..d0b07f6299c24 --- /dev/null +++ b/recipes/cppzmq/all/conandata.yml @@ -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" diff --git a/recipes/cppzmq/all/conanfile.py b/recipes/cppzmq/all/conanfile.py new file mode 100644 index 0000000000000..d33f904b48c77 --- /dev/null +++ b/recipes/cppzmq/all/conanfile.py @@ -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() diff --git a/recipes/cppzmq/all/patches/0001-cmakelists-alias-libzmq-no-export.patch b/recipes/cppzmq/all/patches/0001-cmakelists-alias-libzmq-no-export.patch new file mode 100644 index 0000000000000..6f7fb380fa9aa --- /dev/null +++ b/recipes/cppzmq/all/patches/0001-cmakelists-alias-libzmq-no-export.patch @@ -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}) diff --git a/recipes/cppzmq/all/test_package/CMakeLists.txt b/recipes/cppzmq/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..6440538d22221 --- /dev/null +++ b/recipes/cppzmq/all/test_package/CMakeLists.txt @@ -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}) + diff --git a/recipes/cppzmq/all/test_package/conanfile.py b/recipes/cppzmq/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1d0bdd3779793 --- /dev/null +++ b/recipes/cppzmq/all/test_package/conanfile.py @@ -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) diff --git a/recipes/cppzmq/all/test_package/test_package.cpp b/recipes/cppzmq/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..60d610003c7ea --- /dev/null +++ b/recipes/cppzmq/all/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include + +#include + +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; +} diff --git a/recipes/cppzmq/config.yml b/recipes/cppzmq/config.yml new file mode 100644 index 0000000000000..91f08686aa1a4 --- /dev/null +++ b/recipes/cppzmq/config.yml @@ -0,0 +1,3 @@ +versions: + "4.5.0": + folder: all