From 2ebf079e17fe659b94c23252851ffdd8051606c9 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 14 Dec 2019 11:50:29 +0100 Subject: [PATCH 1/7] Add zeromq/4.3.2 recipe --- recipes/zeromq/all/CMakeLists.txt | 16 +++ recipes/zeromq/all/conandata.yml | 4 + recipes/zeromq/all/conanfile.py | 101 ++++++++++++++++++ .../zeromq/all/test_package/CMakeLists.txt | 19 ++++ recipes/zeromq/all/test_package/conanfile.py | 18 ++++ .../zeromq/all/test_package/test_package.cpp | 23 ++++ recipes/zeromq/all/zeromq_extra.cmake | 13 +++ recipes/zeromq/config.yml | 3 + 8 files changed, 197 insertions(+) create mode 100644 recipes/zeromq/all/CMakeLists.txt create mode 100644 recipes/zeromq/all/conandata.yml create mode 100644 recipes/zeromq/all/conanfile.py create mode 100644 recipes/zeromq/all/test_package/CMakeLists.txt create mode 100644 recipes/zeromq/all/test_package/conanfile.py create mode 100644 recipes/zeromq/all/test_package/test_package.cpp create mode 100644 recipes/zeromq/all/zeromq_extra.cmake create mode 100644 recipes/zeromq/config.yml diff --git a/recipes/zeromq/all/CMakeLists.txt b/recipes/zeromq/all/CMakeLists.txt new file mode 100644 index 0000000000000..082b70cc5dfad --- /dev/null +++ b/recipes/zeromq/all/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 2.8.12) +project(cmake_wrapper) + +set(CONANBUILDINFO_PATH "" CACHE FILEPATH "Path to folder containing conanbuildinfo.cmake") +if(NOT CONANBUILDINFO_PATH) + message(FATAL_ERROR "CONANBUILDIFO_PATH not set") +endif() + +include("${CONANBUILDINFO_PATH}/conanbuildinfo.cmake") +conan_basic_setup() + +if(MSVC) + add_definitions("-D_NOEXCEPT=noexcept") +endif() + +add_subdirectory(source_subfolder) diff --git a/recipes/zeromq/all/conandata.yml b/recipes/zeromq/all/conandata.yml new file mode 100644 index 0000000000000..2906b9eeb00ad --- /dev/null +++ b/recipes/zeromq/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "4.3.2": + url: "https://github.com/zeromq/libzmq/archive/v4.3.2.tar.gz" + sha256: "02ecc88466ae38cf2c8d79f09cfd2675ba299a439680b64ade733e26a349edeb" diff --git a/recipes/zeromq/all/conanfile.py b/recipes/zeromq/all/conanfile.py new file mode 100644 index 0000000000000..096edf00560e0 --- /dev/null +++ b/recipes/zeromq/all/conanfile.py @@ -0,0 +1,101 @@ +import os +from conans import ConanFile, tools, CMake + + +class ZeroMQConan(ConanFile): + name = "zeromq" + homepage = "https://github.com/zeromq/libzmq" + 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 = "LGPL-3.0" + exports_sources = ["CMakeLists.txt", "zeromq_extra.cmake"] + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "encryption": [None, "libsodium", "tweetnacl"], + } + default_options = { + "shared": False, + "fPIC": True, + "encryption": "libsodium", + } + generators = "cmake" + + _source_subfolder = "source_subfolder" + _build_subfolder = "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if self.options.encryption == "libsodium": + self.requires.add("libsodium/1.0.18") + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + os.rename("libzmq-{}".format(self.version), self._source_subfolder) + + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["CONANBUILDINFO_PATH"] = self.build_folder + cmake.definitions["ENABLE_CURVE"] = self.options.encryption is not None + cmake.definitions["WITH_LIBSODIUM"] = self.options.encryption == "libsodium" + cmake.definitions["ZMQ_BUILD_TESTS"] = False + cmake.definitions["WITH_PERF_TOOL"] = False + cmake.definitions["BUILD_SHARED"] = self.options.shared + cmake.definitions["BUILD_STATIC"] = not self.options.shared + cmake.definitions["ENABLE_CPACK"] = False + cmake.configure(build_folder=self._build_subfolder) + return cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="COPYING*", src=self._source_subfolder, dst="licenses") + cmake = self._configure_cmake() + cmake.install() + + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "CMake")) + + self.copy("zeromq_extra.cmake", dst=os.path.join(self.package_folder, "lib", "cmake", "zeromq")) + + def package_info(self): + self.cpp_info.names["pkg_config"] = "libzmq" + self.cpp_info.names["cmake"] = "ZeroMQ" + self.cpp_info.names["cmake_find_package"] = "ZeroMQ" + self.cpp_info.names["cmake_find_package_multi"] = "ZeroMQ" + if self.settings.compiler == "Visual Studio": + version = "_".join(self.version.split(".")) + if self.settings.build_type == "Debug": + runtime = "-gd" if self.options.shared else "-sgd" + else: + runtime = "" if self.options.shared else "-s" + library_name = "libzmq-mt%s-%s" % (runtime, version) + if not os.path.isfile(os.path.join(self.package_folder, "lib", library_name)): + # unfortunately Visual Studio and Ninja generators produce different file names + toolset = {"12": "v120", + "14": "v140", + "15": "v141", + "16": "v142"}.get(str(self.settings.compiler.version)) + library_name = "libzmq-%s-mt%s-%s" % (toolset, runtime, version) + self.cpp_info.libs = [library_name] + self.cpp_info.system_libs = ["iphlpapi", "ws2_32"] + else: + self.cpp_info.libs = ["zmq"] + if self.settings.os == "Linux": + self.cpp_info.system_libs.extend(["pthread", "rt", "m"]) + if not self.options.shared: + self.cpp_info.defines.append("ZMQ_STATIC") + self.cpp_info.builddirs = [os.path.join("lib", "cmake", "zeromq")] + self.cpp_info.build_modules = [os.path.join("lib", "cmake", "zeromq", "zeromq_extra.cmake")] diff --git a/recipes/zeromq/all/test_package/CMakeLists.txt b/recipes/zeromq/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3323c3884340f --- /dev/null +++ b/recipes/zeromq/all/test_package/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12) +project(test_package) + +set(CMAKE_VERBOSE_MAKEFILE TRUE) + +find_package(ZeroMQ REQUIRED) +if(NOT TARGET libzmq OR NOT TARGET libzmq-static) + message(FATAL_ERROR "No target libzmq or libzmq-static created") +endif() + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) + +if(WITH_LIBSODIUM) + target_compile_definitions(${PROJECT_NAME} PRIVATE "WITH_LIBSODIUM") +endif() diff --git a/recipes/zeromq/all/test_package/conanfile.py b/recipes/zeromq/all/test_package/conanfile.py new file mode 100644 index 0000000000000..45fdf62868fff --- /dev/null +++ b/recipes/zeromq/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +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.definitions["WITH_LIBSODIUM"] = self.options["zmq"].encryption == "libsodium" + 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/zeromq/all/test_package/test_package.cpp b/recipes/zeromq/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..4ca88779568e5 --- /dev/null +++ b/recipes/zeromq/all/test_package/test_package.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +int main() try +{ + void *context = zmq_ctx_new(); + void *requester = zmq_socket(context, ZMQ_REQ); +#if defined(WITH_LIBSODIUM) + int is_server = 0; + if (0 != zmq_setsockopt(requester, ZMQ_CURVE_SERVER, &is_server, sizeof(is_server))) + throw std::runtime_error("zmq_setsockopt with ZMQ_CURVE_SERVER failed"); +#endif + zmq_close(requester); + zmq_ctx_destroy (context); + + return EXIT_SUCCESS; +} +catch (std::runtime_error & e) { + std::cerr << e.what() << std::endl; + return EXIT_FAILURE; +} diff --git a/recipes/zeromq/all/zeromq_extra.cmake b/recipes/zeromq/all/zeromq_extra.cmake new file mode 100644 index 0000000000000..c2951c5297235 --- /dev/null +++ b/recipes/zeromq/all/zeromq_extra.cmake @@ -0,0 +1,13 @@ +# This script should only run when included in a FindXXX.cmake module +if(NOT ZeroMQ_LIB_DIRS) + return() +endif() + +if(NOT TARGET libzmq) + add_library(libzmq INTERFACE IMPORTED) + set_property(TARGET libzmq PROPERTY INTERFACE_LINK_LIBRARIES ZeroMQ::ZeroMQ) +endif() +if(NOT TARGET libzmq-static) + add_library(libzmq-static INTERFACE IMPORTED) + set_property(TARGET libzmq-static PROPERTY INTERFACE_LINK_LIBRARIES ZeroMQ::ZeroMQ) +endif() diff --git a/recipes/zeromq/config.yml b/recipes/zeromq/config.yml new file mode 100644 index 0000000000000..ef8763e534823 --- /dev/null +++ b/recipes/zeromq/config.yml @@ -0,0 +1,3 @@ +versions: + "4.3.2": + folder: all From 28c777a412a406618badd0729c82a90939beecaf Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 19 Dec 2019 09:51:20 -0300 Subject: [PATCH 2/7] Remove custom build folder for ZeroMQ Signed-off-by: Uilian Ries --- recipes/zeromq/all/CMakeLists.txt | 7 +------ recipes/zeromq/all/conanfile.py | 9 +-------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/recipes/zeromq/all/CMakeLists.txt b/recipes/zeromq/all/CMakeLists.txt index 082b70cc5dfad..0b3792cffb165 100644 --- a/recipes/zeromq/all/CMakeLists.txt +++ b/recipes/zeromq/all/CMakeLists.txt @@ -1,12 +1,7 @@ cmake_minimum_required(VERSION 2.8.12) project(cmake_wrapper) -set(CONANBUILDINFO_PATH "" CACHE FILEPATH "Path to folder containing conanbuildinfo.cmake") -if(NOT CONANBUILDINFO_PATH) - message(FATAL_ERROR "CONANBUILDIFO_PATH not set") -endif() - -include("${CONANBUILDINFO_PATH}/conanbuildinfo.cmake") +include("conanbuildinfo.cmake") conan_basic_setup() if(MSVC) diff --git a/recipes/zeromq/all/conanfile.py b/recipes/zeromq/all/conanfile.py index 096edf00560e0..32f3e6642fd82 100644 --- a/recipes/zeromq/all/conanfile.py +++ b/recipes/zeromq/all/conanfile.py @@ -30,10 +30,6 @@ def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - def configure(self): - if self.options.shared: - del self.options.fPIC - def requirements(self): if self.options.encryption == "libsodium": self.requires.add("libsodium/1.0.18") @@ -44,7 +40,6 @@ def source(self): def _configure_cmake(self): cmake = CMake(self) - cmake.definitions["CONANBUILDINFO_PATH"] = self.build_folder cmake.definitions["ENABLE_CURVE"] = self.options.encryption is not None cmake.definitions["WITH_LIBSODIUM"] = self.options.encryption == "libsodium" cmake.definitions["ZMQ_BUILD_TESTS"] = False @@ -71,10 +66,8 @@ def package(self): self.copy("zeromq_extra.cmake", dst=os.path.join(self.package_folder, "lib", "cmake", "zeromq")) def package_info(self): + self.cpp_info.name = "ZeroMQ" self.cpp_info.names["pkg_config"] = "libzmq" - self.cpp_info.names["cmake"] = "ZeroMQ" - self.cpp_info.names["cmake_find_package"] = "ZeroMQ" - self.cpp_info.names["cmake_find_package_multi"] = "ZeroMQ" if self.settings.compiler == "Visual Studio": version = "_".join(self.version.split(".")) if self.settings.build_type == "Debug": From 605ab3d2e8d2ff417d166bf7907f38f03b39b4f1 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Mon, 23 Dec 2019 08:10:53 -0300 Subject: [PATCH 3/7] Revert configure remove Signed-off-by: Uilian Ries --- recipes/zeromq/all/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/zeromq/all/conanfile.py b/recipes/zeromq/all/conanfile.py index 32f3e6642fd82..d1581f45f39cc 100644 --- a/recipes/zeromq/all/conanfile.py +++ b/recipes/zeromq/all/conanfile.py @@ -30,6 +30,10 @@ def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def configure(self): + if self.options.shared: + del self.options.fPIC + def requirements(self): if self.options.encryption == "libsodium": self.requires.add("libsodium/1.0.18") From cf9a5d809bfd18dd55f0137db2d5883c5d2c62f2 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 11 Jan 2020 02:20:55 +0100 Subject: [PATCH 4/7] Rename to libzmq/4.3.2 --- recipes/{zeromq => libzmq}/all/CMakeLists.txt | 0 recipes/{zeromq => libzmq}/all/conandata.yml | 0 recipes/{zeromq => libzmq}/all/conanfile.py | 14 +++++--------- .../all/test_package/CMakeLists.txt | 5 ----- .../all/test_package/conanfile.py | 2 +- .../all/test_package/test_package.cpp | 0 recipes/{zeromq => libzmq}/config.yml | 0 recipes/zeromq/all/zeromq_extra.cmake | 13 ------------- 8 files changed, 6 insertions(+), 28 deletions(-) rename recipes/{zeromq => libzmq}/all/CMakeLists.txt (100%) rename recipes/{zeromq => libzmq}/all/conandata.yml (100%) rename recipes/{zeromq => libzmq}/all/conanfile.py (88%) rename recipes/{zeromq => libzmq}/all/test_package/CMakeLists.txt (69%) rename recipes/{zeromq => libzmq}/all/test_package/conanfile.py (91%) rename recipes/{zeromq => libzmq}/all/test_package/test_package.cpp (100%) rename recipes/{zeromq => libzmq}/config.yml (100%) delete mode 100644 recipes/zeromq/all/zeromq_extra.cmake diff --git a/recipes/zeromq/all/CMakeLists.txt b/recipes/libzmq/all/CMakeLists.txt similarity index 100% rename from recipes/zeromq/all/CMakeLists.txt rename to recipes/libzmq/all/CMakeLists.txt diff --git a/recipes/zeromq/all/conandata.yml b/recipes/libzmq/all/conandata.yml similarity index 100% rename from recipes/zeromq/all/conandata.yml rename to recipes/libzmq/all/conandata.yml diff --git a/recipes/zeromq/all/conanfile.py b/recipes/libzmq/all/conanfile.py similarity index 88% rename from recipes/zeromq/all/conanfile.py rename to recipes/libzmq/all/conanfile.py index d1581f45f39cc..9f00c4152097e 100644 --- a/recipes/zeromq/all/conanfile.py +++ b/recipes/libzmq/all/conanfile.py @@ -2,14 +2,14 @@ from conans import ConanFile, tools, CMake -class ZeroMQConan(ConanFile): - name = "zeromq" +class LibZMQConan(ConanFile): + name = "libzmq" homepage = "https://github.com/zeromq/libzmq" 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 = "LGPL-3.0" - exports_sources = ["CMakeLists.txt", "zeromq_extra.cmake"] + exports_sources = ["CMakeLists.txt"] settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -67,11 +67,9 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "share")) tools.rmdir(os.path.join(self.package_folder, "CMake")) - self.copy("zeromq_extra.cmake", dst=os.path.join(self.package_folder, "lib", "cmake", "zeromq")) - def package_info(self): - self.cpp_info.name = "ZeroMQ" - self.cpp_info.names["pkg_config"] = "libzmq" + self.cpp_info.names["cmake_find_package"] = "ZeroMQ" + self.cpp_info.names["cmake_find_package_multi"] = "ZeroMQ" if self.settings.compiler == "Visual Studio": version = "_".join(self.version.split(".")) if self.settings.build_type == "Debug": @@ -94,5 +92,3 @@ def package_info(self): self.cpp_info.system_libs.extend(["pthread", "rt", "m"]) if not self.options.shared: self.cpp_info.defines.append("ZMQ_STATIC") - self.cpp_info.builddirs = [os.path.join("lib", "cmake", "zeromq")] - self.cpp_info.build_modules = [os.path.join("lib", "cmake", "zeromq", "zeromq_extra.cmake")] diff --git a/recipes/zeromq/all/test_package/CMakeLists.txt b/recipes/libzmq/all/test_package/CMakeLists.txt similarity index 69% rename from recipes/zeromq/all/test_package/CMakeLists.txt rename to recipes/libzmq/all/test_package/CMakeLists.txt index 3323c3884340f..e9eb529d5c31c 100644 --- a/recipes/zeromq/all/test_package/CMakeLists.txt +++ b/recipes/libzmq/all/test_package/CMakeLists.txt @@ -3,11 +3,6 @@ project(test_package) set(CMAKE_VERBOSE_MAKEFILE TRUE) -find_package(ZeroMQ REQUIRED) -if(NOT TARGET libzmq OR NOT TARGET libzmq-static) - message(FATAL_ERROR "No target libzmq or libzmq-static created") -endif() - include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() diff --git a/recipes/zeromq/all/test_package/conanfile.py b/recipes/libzmq/all/test_package/conanfile.py similarity index 91% rename from recipes/zeromq/all/test_package/conanfile.py rename to recipes/libzmq/all/test_package/conanfile.py index 45fdf62868fff..7a0c8fcb79866 100644 --- a/recipes/zeromq/all/test_package/conanfile.py +++ b/recipes/libzmq/all/test_package/conanfile.py @@ -4,7 +4,7 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + generators = "cmake" def build(self): cmake = CMake(self) diff --git a/recipes/zeromq/all/test_package/test_package.cpp b/recipes/libzmq/all/test_package/test_package.cpp similarity index 100% rename from recipes/zeromq/all/test_package/test_package.cpp rename to recipes/libzmq/all/test_package/test_package.cpp diff --git a/recipes/zeromq/config.yml b/recipes/libzmq/config.yml similarity index 100% rename from recipes/zeromq/config.yml rename to recipes/libzmq/config.yml diff --git a/recipes/zeromq/all/zeromq_extra.cmake b/recipes/zeromq/all/zeromq_extra.cmake deleted file mode 100644 index c2951c5297235..0000000000000 --- a/recipes/zeromq/all/zeromq_extra.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# This script should only run when included in a FindXXX.cmake module -if(NOT ZeroMQ_LIB_DIRS) - return() -endif() - -if(NOT TARGET libzmq) - add_library(libzmq INTERFACE IMPORTED) - set_property(TARGET libzmq PROPERTY INTERFACE_LINK_LIBRARIES ZeroMQ::ZeroMQ) -endif() -if(NOT TARGET libzmq-static) - add_library(libzmq-static INTERFACE IMPORTED) - set_property(TARGET libzmq-static PROPERTY INTERFACE_LINK_LIBRARIES ZeroMQ::ZeroMQ) -endif() From 910750b187df2cf1cb34e086d6c801d5dfc5a46c Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 14 Jan 2020 15:37:58 +0100 Subject: [PATCH 5/7] zeromq: rename libzmq -> zeromq + cache cmake object --- recipes/{libzmq => zeromq}/all/CMakeLists.txt | 0 recipes/{libzmq => zeromq}/all/conandata.yml | 0 recipes/{libzmq => zeromq}/all/conanfile.py | 27 ++++++++++--------- .../all/test_package/CMakeLists.txt | 0 .../all/test_package/conanfile.py | 0 .../all/test_package/test_package.cpp | 0 recipes/{libzmq => zeromq}/config.yml | 0 7 files changed, 15 insertions(+), 12 deletions(-) rename recipes/{libzmq => zeromq}/all/CMakeLists.txt (100%) rename recipes/{libzmq => zeromq}/all/conandata.yml (100%) rename recipes/{libzmq => zeromq}/all/conanfile.py (81%) rename recipes/{libzmq => zeromq}/all/test_package/CMakeLists.txt (100%) rename recipes/{libzmq => zeromq}/all/test_package/conanfile.py (100%) rename recipes/{libzmq => zeromq}/all/test_package/test_package.cpp (100%) rename recipes/{libzmq => zeromq}/config.yml (100%) diff --git a/recipes/libzmq/all/CMakeLists.txt b/recipes/zeromq/all/CMakeLists.txt similarity index 100% rename from recipes/libzmq/all/CMakeLists.txt rename to recipes/zeromq/all/CMakeLists.txt diff --git a/recipes/libzmq/all/conandata.yml b/recipes/zeromq/all/conandata.yml similarity index 100% rename from recipes/libzmq/all/conandata.yml rename to recipes/zeromq/all/conandata.yml diff --git a/recipes/libzmq/all/conanfile.py b/recipes/zeromq/all/conanfile.py similarity index 81% rename from recipes/libzmq/all/conanfile.py rename to recipes/zeromq/all/conanfile.py index 9f00c4152097e..7996e36f99230 100644 --- a/recipes/libzmq/all/conanfile.py +++ b/recipes/zeromq/all/conanfile.py @@ -2,8 +2,8 @@ from conans import ConanFile, tools, CMake -class LibZMQConan(ConanFile): - name = "libzmq" +class ZeroMQConan(ConanFile): + name = "zeromq" homepage = "https://github.com/zeromq/libzmq" description = "ZeroMQ is a community of projects focused on decentralized messaging and computing" topics = ("conan", "zmq", "libzmq", "message-queue", "asynchronous") @@ -23,6 +23,7 @@ class LibZMQConan(ConanFile): } generators = "cmake" + _cmake = None _source_subfolder = "source_subfolder" _build_subfolder = "build_subfolder" @@ -43,16 +44,18 @@ def source(self): os.rename("libzmq-{}".format(self.version), self._source_subfolder) def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["ENABLE_CURVE"] = self.options.encryption is not None - cmake.definitions["WITH_LIBSODIUM"] = self.options.encryption == "libsodium" - cmake.definitions["ZMQ_BUILD_TESTS"] = False - cmake.definitions["WITH_PERF_TOOL"] = False - cmake.definitions["BUILD_SHARED"] = self.options.shared - cmake.definitions["BUILD_STATIC"] = not self.options.shared - cmake.definitions["ENABLE_CPACK"] = False - cmake.configure(build_folder=self._build_subfolder) - return cmake + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["ENABLE_CURVE"] = self.options.encryption is not None + self._cmake.definitions["WITH_LIBSODIUM"] = self.options.encryption == "libsodium" + self._cmake.definitions["ZMQ_BUILD_TESTS"] = False + self._cmake.definitions["WITH_PERF_TOOL"] = False + self._cmake.definitions["BUILD_SHARED"] = self.options.shared + self._cmake.definitions["BUILD_STATIC"] = not self.options.shared + self._cmake.definitions["ENABLE_CPACK"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake def build(self): cmake = self._configure_cmake() diff --git a/recipes/libzmq/all/test_package/CMakeLists.txt b/recipes/zeromq/all/test_package/CMakeLists.txt similarity index 100% rename from recipes/libzmq/all/test_package/CMakeLists.txt rename to recipes/zeromq/all/test_package/CMakeLists.txt diff --git a/recipes/libzmq/all/test_package/conanfile.py b/recipes/zeromq/all/test_package/conanfile.py similarity index 100% rename from recipes/libzmq/all/test_package/conanfile.py rename to recipes/zeromq/all/test_package/conanfile.py diff --git a/recipes/libzmq/all/test_package/test_package.cpp b/recipes/zeromq/all/test_package/test_package.cpp similarity index 100% rename from recipes/libzmq/all/test_package/test_package.cpp rename to recipes/zeromq/all/test_package/test_package.cpp diff --git a/recipes/libzmq/config.yml b/recipes/zeromq/config.yml similarity index 100% rename from recipes/libzmq/config.yml rename to recipes/zeromq/config.yml From 445354b4e90a8144517295a8863694a51e51d92a Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 15 Jan 2020 18:30:23 +0100 Subject: [PATCH 6/7] zeromq: use cmake_find_package to detect libsodium --- recipes/zeromq/all/conanfile.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/recipes/zeromq/all/conanfile.py b/recipes/zeromq/all/conanfile.py index 7996e36f99230..378bc54046c37 100644 --- a/recipes/zeromq/all/conanfile.py +++ b/recipes/zeromq/all/conanfile.py @@ -21,7 +21,7 @@ class ZeroMQConan(ConanFile): "fPIC": True, "encryption": "libsodium", } - generators = "cmake" + generators = "cmake", "cmake_find_package" _cmake = None _source_subfolder = "source_subfolder" @@ -57,7 +57,21 @@ def _configure_cmake(self): self._cmake.configure(build_folder=self._build_subfolder) return self._cmake + def _patch_sources(self): + os.unlink(os.path.join(self._source_subfolder, "builds", "cmake", "Modules", "FindSodium.cmake")) + os.rename("Findlibsodium.cmake", "FindSodium.cmake") + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + "SODIUM_FOUND", + "libsodium_FOUND") + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + "SODIUM_INCLUDE_DIRS", + "libsodium_INCLUDE_DIRS") + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + "SODIUM_LIBRARIES", + "libsodium_LIBRARIES") + def build(self): + self._patch_sources() cmake = self._configure_cmake() cmake.build() From c63349d31160ebc21948f8532481803d817af1cb Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Mon, 27 Jan 2020 16:26:08 +0100 Subject: [PATCH 7/7] zeromq: address feedback --- recipes/zeromq/all/CMakeLists.txt | 2 +- recipes/zeromq/all/test_package/CMakeLists.txt | 8 ++++++-- recipes/zeromq/all/test_package/conanfile.py | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/recipes/zeromq/all/CMakeLists.txt b/recipes/zeromq/all/CMakeLists.txt index 0b3792cffb165..7069ce7c180dd 100644 --- a/recipes/zeromq/all/CMakeLists.txt +++ b/recipes/zeromq/all/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.8.12) project(cmake_wrapper) -include("conanbuildinfo.cmake") +include(conanbuildinfo.cmake) conan_basic_setup() if(MSVC) diff --git a/recipes/zeromq/all/test_package/CMakeLists.txt b/recipes/zeromq/all/test_package/CMakeLists.txt index e9eb529d5c31c..65017f5551258 100644 --- a/recipes/zeromq/all/test_package/CMakeLists.txt +++ b/recipes/zeromq/all/test_package/CMakeLists.txt @@ -3,11 +3,15 @@ project(test_package) set(CMAKE_VERBOSE_MAKEFILE TRUE) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +option(WITH_LIBSODIUM "zeromq is built with libsodium") + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") conan_basic_setup() +find_package(ZeroMQ REQUIRED) + add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} ZeroMQ::ZeroMQ) if(WITH_LIBSODIUM) target_compile_definitions(${PROJECT_NAME} PRIVATE "WITH_LIBSODIUM") diff --git a/recipes/zeromq/all/test_package/conanfile.py b/recipes/zeromq/all/test_package/conanfile.py index 7a0c8fcb79866..2ec4389efb8ee 100644 --- a/recipes/zeromq/all/test_package/conanfile.py +++ b/recipes/zeromq/all/test_package/conanfile.py @@ -4,11 +4,11 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package" def build(self): cmake = CMake(self) - cmake.definitions["WITH_LIBSODIUM"] = self.options["zmq"].encryption == "libsodium" + cmake.definitions["WITH_LIBSODIUM"] = self.options["zeromq"].encryption == "libsodium" cmake.configure() cmake.build()