Skip to content

Commit

Permalink
(#11993) hazelcast-cpp-client: update dependencies and migration to C…
Browse files Browse the repository at this point in the history
…onan v2

* hazelcast-cpp-client: update dependencies

* migration to Conan V2

* fix import path for check_min_cppstd

* add CMakeDeps

* link ws2_32

* use get_safe() for cppstd

* add VirtualRunEnv to test_package

* follow conan v2

* remove unused modules

Co-authored-by: Daniel <danimanzaneque@gmail.com>

* remove unused modules

Co-authored-by: Daniel <danimanzaneque@gmail.com>

Co-authored-by: Daniel <danimanzaneque@gmail.com>
  • Loading branch information
toge and danimtb authored Sep 15, 2022
1 parent bbe0878 commit 5d82e07
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 73 deletions.
7 changes: 0 additions & 7 deletions recipes/hazelcast-cpp-client/all/CMakeLists.txt

This file was deleted.

7 changes: 0 additions & 7 deletions recipes/hazelcast-cpp-client/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ sources:
"4.0.1":
url: "https://github.com/hazelcast/hazelcast-cpp-client/archive/v4.0.1.zip"
sha256: "4b3c6a876ebca2a4dcf23a556d3c3d4da2284e4ce1d2bbdf335df7f86b03fd28"
"4.0.0":
url: "https://github.com/hazelcast/hazelcast-cpp-client/archive/v4.0.0.zip"
sha256: "1bba72aec47951cefb367a99c196fd8989a2d621e527310fee9483313d347d1b"
patches:
"4.1.0":
- patch_file: "patches/gcc_4.9_5_fix.patch"
base_path: "source_subfolder"
"4.0.0":
- patch_file: "patches/cmake_install.patch"
base_path: "source_subfolder"
92 changes: 48 additions & 44 deletions recipes/hazelcast-cpp-client/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.scm import Version
from conan.tools import files
from conan.tools.build import check_min_cppstd

import os
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration

required_conan_version = ">=1.50.0"

class HazelcastCppClient(ConanFile):
name = "hazelcast-cpp-client"
description = "C++ client library for Hazelcast in-memory database."
license = "Apache-2.0"
topics = ("conan", "hazelcast", "client", "database", "cache", "in-memory", "distributed", "computing", "ssl")
homepage = "https://github.com/hazelcast/hazelcast-cpp-client"
url = "https://github.com/conan-io/conan-center-index"
exports_sources = ["CMakeLists.txt", "patches/**"]
generators = "cmake", "cmake_find_package"
homepage = "https://github.com/hazelcast/hazelcast-cpp-client"
topics = ("hazelcast", "client", "database", "cache", "in-memory", "distributed", "computing", "ssl")
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
Expand All @@ -23,15 +27,9 @@ class HazelcastCppClient(ConanFile):
"with_openssl": False
}

_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _cmake_name(self):
return "hazelcastcxx" if tools.Version(self.version) <= "4.0.0" else "hazelcast-cpp-client"
def export_sources(self):
for p in self.conan_data.get("patches", {}).get(self.version, []):
files.copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder)

def config_options(self):
if self.settings.os == "Windows":
Expand All @@ -40,50 +38,56 @@ def config_options(self):
def configure(self):
if self.options.shared:
del self.options.fPIC
if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, 11)

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires("boost/1.76.0")
self.requires("boost/1.79.0")
if self.options.with_openssl:
self.requires("openssl/1.1.1k")
self.requires("openssl/1.1.1q")

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 11)

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename(self.name + "-" + self.version, self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["WITH_OPENSSL"] = self.options.with_openssl
if tools.Version(self.version) <= "4.0.0":
self._cmake.definitions["BUILD_STATIC_LIB"] = not self.options.shared
self._cmake.definitions["BUILD_SHARED_LIB"] = self.options.shared
files.get(self,
**self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)

def generate(self):
toolchain = CMakeToolchain(self)
toolchain.variables["WITH_OPENSSL"] = self.options.with_openssl
if Version(self.version) <= "4.0.0":
toolchain.variables["BUILD_STATIC_LIB"] = not self.options.shared
toolchain.variables["BUILD_SHARED_LIB"] = self.options.shared
else:
self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared
self._cmake.configure()
return self._cmake
toolchain.variables["BUILD_SHARED_LIBS"] = self.options.shared
toolchain.generate()

deps = CMakeDeps(self)
deps.generate()

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
cmake = self._configure_cmake()
files.apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
self.copy("LICENSE", dst="licenses", src=self.source_folder)
cmake = CMake(self)
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
files.rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):
self.cpp_info.filenames["cmake_find_package"] = self._cmake_name
self.cpp_info.filenames["cmake_find_package_multi"] = self._cmake_name
self.cpp_info.names["cmake_find_package"] = self._cmake_name
self.cpp_info.names["cmake_find_package_multi"] = self._cmake_name
self.cpp_info.set_property("cmake_file_name", "hazelcast-cpp-client")
self.cpp_info.set_property("cmake_target_name", "hazelcast-cpp-client::hazelcast-cpp-client")

self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.libs = ["hazelcast-cpp-client"]
self.cpp_info.defines = ["BOOST_THREAD_VERSION=5"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("pthread")
if self.settings.os == "Windows":
self.cpp_info.system_libs.append("ws2_32")
13 changes: 6 additions & 7 deletions recipes/hazelcast-cpp-client/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
cmake_minimum_required(VERSION 3.10)
project(PackageTest CXX)
cmake_minimum_required(VERSION 3.8)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
find_package(hazelcast-cpp-client REQUIRED CONFIG)

add_executable(test_package test_package.cpp)
target_link_libraries(test_package PUBLIC ${CONAN_LIBS})
set_property(TARGET test_package PROPERTY CXX_STANDARD 11)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE hazelcast-cpp-client::hazelcast-cpp-client)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
21 changes: 15 additions & 6 deletions recipes/hazelcast-cpp-client/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os

from conans import ConanFile, CMake, tools

class TestPackageHazelcastCppClient(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
self.run(os.path.join("bin", "test_package"), run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
11 changes: 11 additions & 0 deletions recipes/hazelcast-cpp-client/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(hazelcast-cpp-client REQUIRED CONFIG)

add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE hazelcast-cpp-client::hazelcast-cpp-client)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
17 changes: 17 additions & 0 deletions recipes/hazelcast-cpp-client/all/test_v1_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", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
2 changes: 0 additions & 2 deletions recipes/hazelcast-cpp-client/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ versions:
folder: all
"4.0.1":
folder: all
"4.0.0":
folder: all

0 comments on commit 5d82e07

Please sign in to comment.