Skip to content

Commit

Permalink
Merge branch 'master' of github.com:conan-io/conan-center-index into …
Browse files Browse the repository at this point in the history
…develop

* 'master' of github.com:conan-io/conan-center-index:
  (conan-io#12847) fmt: conan v2 modernize
  (conan-io#11993) hazelcast-cpp-client: update dependencies and migration to Conan v2
  • Loading branch information
datalogics-kam committed Sep 15, 2022
2 parents 26ce757 + 328bff8 commit a7fba48
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 95 deletions.
39 changes: 17 additions & 22 deletions recipes/fmt/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import get, apply_conandata_patches, copy, rmdir


required_conan_version = ">=1.50.0"
required_conan_version = ">=1.51.3"


class FmtConan(ConanFile):
Expand All @@ -16,8 +15,6 @@ class FmtConan(ConanFile):
topics = ("fmt", "format", "iostream", "printf")
url = "https://github.com/conan-io/conan-center-index"
license = "MIT"
exports_sources = "patches/*"

settings = "os", "arch", "compiler", "build_type"
options = {
"header_only": [True, False],
Expand All @@ -38,6 +35,10 @@ class FmtConan(ConanFile):
def _has_with_os_api_option(self):
return Version(str(self.version)) >= "7.0.0"

def export_sources(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
copy(self, patch["patch_file"], src=self.recipe_folder, dst=self.export_sources_folder)

def generate(self):
if not self.options.header_only:
tc = CMakeToolchain(self)
Expand Down Expand Up @@ -75,7 +76,8 @@ def package_id(self):
del self.info.options.with_fmt_alias

def source(self):
get(self, **self.conan_data["sources"][str(self.version)], strip_root=True)
get(self, **self.conan_data["sources"][str(self.version)],
destination=self.source_folder, strip_root=True)

def build(self):
apply_conandata_patches(self)
Expand All @@ -97,37 +99,30 @@ def package(self):
rmdir(self, os.path.join(self.package_folder, "share"))

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "fmt"
self.cpp_info.names["cmake_find_package_multi"] = "fmt"
self.cpp_info.names["pkg_config"] = "fmt"

target = "fmt-header-only" if self.options.header_only else "fmt"
self.cpp_info.set_property("cmake_target_name", "fmt::{}".format(target))
self.cpp_info.set_property("cmake_file_name", "fmt")
self.cpp_info.set_property("cmake_target_name", f"fmt::{target}")
self.cpp_info.set_property("pkg_config_name", "fmt")

# TODO: back to global scope in conan v2 once cmake_find_package* generators removed
self.cpp_info.components["_fmt"].includedirs.extend(["include"])
if self.options.with_fmt_alias:
self.cpp_info.components["_fmt"].defines.append("FMT_STRING_ALIAS=1")

if self.options.header_only:
self.cpp_info.components["_fmt"].defines.append("FMT_HEADER_ONLY=1")
if self.options.with_fmt_alias:
self.cpp_info.components["_fmt"].defines.append("FMT_STRING_ALIAS=1")
else:
postfix = "d" if self.settings.build_type == "Debug" else ""
libname = "fmt" + postfix
self.cpp_info.components["_fmt"].libs = [libname]
if self.settings.os == "Linux":
self.cpp_info.components["_fmt"].system_libs.extend(["m"])
# FIXME: remove when Conan 1.50 is used in c3i and update the Conan required version
# from that version components don't have empty libdirs by default
self.cpp_info.components["_fmt"].libdirs.extend(["lib"])
self.cpp_info.components["_fmt"].bindirs.extend(["bin"])
if self.options.with_fmt_alias:
self.cpp_info.components["_fmt"].defines.append("FMT_STRING_ALIAS=1")
if self.options.shared:
self.cpp_info.components["_fmt"].defines.append("FMT_SHARED")

# TODO: to remove in conan v2 once cmake_find_package* generators removed
self.cpp_info.names["cmake_find_package"] = "fmt"
self.cpp_info.names["cmake_find_package_multi"] = "fmt"
self.cpp_info.names["pkg_config"] = "fmt"
self.cpp_info.components["_fmt"].names["cmake_find_package"] = target
self.cpp_info.components["_fmt"].names["cmake_find_package_multi"] = target
self.cpp_info.components["_fmt"].set_property("cmake_target_name", "fmt::{}".format(target))
# FIXME: Remove as soon as Conan client provide a hotfix. See conan-io/conan-center-index#12149
self.cpp_info.components["_fmt"].builddirs = [""]
self.cpp_info.components["_fmt"].set_property("cmake_target_name", f"fmt::{target}")
1 change: 1 addition & 0 deletions recipes/fmt/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)
Expand Down
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 a7fba48

Please sign in to comment.