Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmt: add version 11.0.0 #24482

Merged
merged 3 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions recipes/fmt/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"11.0.0":
url: "https://github.com/fmtlib/fmt/releases/download/11.0.0/fmt-11.0.0.zip"
sha256: "583ce480ef07fad76ef86e1e2a639fc231c3daa86c4aa6bcba524ce908f30699"
"10.2.1":
url: "https://github.com/fmtlib/fmt/releases/download/10.2.1/fmt-10.2.1.zip"
sha256: "312151a2d13c8327f5c9c586ac6cf7cddc1658e8f53edae0ec56509c8fa516c9"
Expand Down Expand Up @@ -36,5 +39,5 @@
url: "https://github.com/fmtlib/fmt/releases/download/5.3.0/fmt-5.3.0.zip"
sha256: "4c0741e10183f75d7d6f730b8708a99b329b2f942dad5a9da3385ab92bb4a15c"
patches:
"5.3.0":
- patch_file: "patches/fix-install-5.3.0.patch"

Check warning on line 43 in recipes/fmt/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description' not found in - patch_file: patches/fix-inst ... ^ (line: 43)
21 changes: 17 additions & 4 deletions recipes/fmt/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
from conan.tools.layout import basic_layout
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.tools.microsoft import is_msvc

required_conan_version = ">=1.53.0"


class FmtConan(ConanFile):
name = "fmt"
homepage = "https://github.com/fmtlib/fmt"
description = "A safe and fast alternative to printf and IOStreams."
topics = ("format", "iostream", "printf")
url = "https://github.com/conan-io/conan-center-index"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/fmtlib/fmt"
topics = ("format", "iostream", "printf")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
Expand All @@ -25,19 +26,25 @@ class FmtConan(ConanFile):
"fPIC": [True, False],
"with_fmt_alias": [True, False],
"with_os_api": [True, False],
"with_unicode": [True, False],
}
default_options = {
"header_only": False,
"shared": False,
"fPIC": True,
"with_fmt_alias": False,
"with_os_api": True,
"with_unicode": True,
}

@property
def _has_with_os_api_option(self):
return Version(self.version) >= "7.0.0"

@property
def _has_with_unicode_option(self):
return Version(self.version) >= "11.0.0"

def export_sources(self):
export_conandata_patches(self)

Expand All @@ -48,6 +55,8 @@ def config_options(self):
del self.options.with_os_api
elif str(self.settings.os) == "baremetal":
self.options.with_os_api = False
if not self._has_with_unicode_option:
del self.options.with_unicode

def configure(self):
if self.options.header_only:
Expand Down Expand Up @@ -85,6 +94,8 @@ def generate(self):
tc.cache_variables["FMT_LIB_DIR"] = "lib"
if self._has_with_os_api_option:
tc.cache_variables["FMT_OS"] = bool(self.options.with_os_api)
if self._has_with_unicode_option:
tc.cache_variables["FMT_UNICODE"] = bool(self.options.with_unicode)
tc.generate()

def build(self):
Expand Down Expand Up @@ -115,6 +126,9 @@ def package_info(self):
self.cpp_info.set_property("cmake_target_name", f"fmt::{target}")
self.cpp_info.set_property("pkg_config_name", "fmt")

if self.options.get_safe("with_unicode") and is_msvc(self):
self.cpp_info.components["_fmt"].cxxflags.append("/utf-8")

# TODO: back to global scope in conan v2 once cmake_find_package* generators removed
if self.options.with_fmt_alias:
self.cpp_info.components["_fmt"].defines.append("FMT_STRING_ALIAS=1")
Expand All @@ -123,7 +137,6 @@ def package_info(self):
self.cpp_info.components["_fmt"].defines.append("FMT_HEADER_ONLY=1")
self.cpp_info.components["_fmt"].libdirs = []
self.cpp_info.components["_fmt"].bindirs = []

else:
postfix = "d" if self.settings.build_type == "Debug" else ""
libname = "fmt" + postfix
Expand Down
1 change: 0 additions & 1 deletion recipes/fmt/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ namespace fmt {
int main() {
const std::string thing("World");
fmt::print("PRINT: Hello {}!\n", thing);
fmt::printf("PRINTF: Hello, %s!\n", thing);

const std::string formatted = fmt::format("{0}{1}{0}", "abra", "cad");
fmt::print("{}\n", formatted);
Expand Down
2 changes: 2 additions & 0 deletions recipes/fmt/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"11.0.0":
folder: all
"10.2.1":
folder: all
"10.2.0":
Expand Down
Loading