Skip to content

Commit

Permalink
build: conanfile updated after review on ConanCenter
Browse files Browse the repository at this point in the history
  • Loading branch information
mpusz committed Jun 20, 2024
1 parent 579b658 commit 3e863b2
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,11 @@
from conan.tools.build import can_run, default_cppstd, valid_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, load, rmdir
from conan.tools.scm import Version

required_conan_version = ">=2.0.0"


def loose_lt_semver(v1, v2):
lv1 = [int(v) for v in v1.split(".")]
lv2 = [int(v) for v in v2.split(".")]
min_length = min(len(lv1), len(lv2))
return lv1[:min_length] < lv2[:min_length]


class MPUnitsConan(ConanFile):
name = "mp-units"
homepage = "https://github.com/mpusz/mp-units"
Expand Down Expand Up @@ -74,7 +68,7 @@ class MPUnitsConan(ConanFile):
"string_view_ret": "auto",
"no_crtp": "auto",
"contracts": "gsl-lite",
"freestanding": "False",
"freestanding": False,
}
tool_requires = "cmake/[>=3.29]"
implements = "auto_header_only"
Expand Down Expand Up @@ -113,7 +107,7 @@ def _feature_compatibility(self):
},
"cxx_modules": {
"std": "20",
"compiler": {"gcc": "14", "clang": "17", "apple-clang": "", "msvc": ""},
"compiler": {"gcc": "", "clang": "17", "apple-clang": "", "msvc": ""},
},
"static_constexpr_vars_in_constexpr_func": {
"std": "23",
Expand Down Expand Up @@ -159,7 +153,7 @@ def _check_feature_supported(self, name, feature_name=name):
raise ConanInvalidConfiguration(
f"'{name}' is not yet supported by any known {compiler} compiler"
)
if loose_lt_semver(str(compiler.version), min_version):
if Version(compiler.version) < min_version:
raise ConanInvalidConfiguration(
f"'{name}' requires at least {compiler}-{min_version} ({compiler}-{compiler.version} in use)"
)
Expand All @@ -175,7 +169,7 @@ def _is_feature_enabled(self, name):
or (
opt == "auto"
and min_version
and not loose_lt_semver(str(compiler.version), min_version)
and Version(compiler.version) >= min_version
)
)

Expand Down Expand Up @@ -206,6 +200,10 @@ def set_version(self):
).group(1)
self.version = version.strip()

def configure(self):
if self.options.freestanding:
self.options.rm_safe("std_format")

def requirements(self):
if not self.options.freestanding:
if self.options.contracts == "gsl-lite":
Expand Down Expand Up @@ -269,7 +267,8 @@ def generate(self):
def build(self):
cmake = CMake(self)
cmake.configure(build_script_folder=None if self._build_all else "src")
cmake.build()
if self._build_all or self._build_cxx_modules:
cmake.build()
if self._build_all:
cmake.build(target="all_verify_interface_header_sets")
if can_run(self):
Expand Down

0 comments on commit 3e863b2

Please sign in to comment.