mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-01 03:14:29 +02:00
feat: use_fmtlib
Conan option added
This commit is contained in:
15
conanfile.py
15
conanfile.py
@@ -56,9 +56,11 @@ class MPUnitsConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"cxx_modules": [True, False],
|
||||
"use_fmtlib": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"cxx_modules": False,
|
||||
"use_fmtlib": True,
|
||||
}
|
||||
tool_requires = "cmake/[>=3.28.1]"
|
||||
exports = ["LICENSE.md"]
|
||||
@@ -94,13 +96,6 @@ class MPUnitsConan(ConanFile):
|
||||
def _skip_la(self):
|
||||
return bool(self.conf.get("user.build:skip_la", default=False))
|
||||
|
||||
@property
|
||||
def _use_libfmt(self):
|
||||
compiler = self.settings.compiler
|
||||
version = Version(self.settings.compiler.version)
|
||||
std_support = compiler == "msvc" and version >= 193 and compiler.cppstd == 23
|
||||
return not std_support
|
||||
|
||||
def set_version(self):
|
||||
content = load(self, os.path.join(self.recipe_folder, "src/CMakeLists.txt"))
|
||||
version = re.search(
|
||||
@@ -110,7 +105,7 @@ class MPUnitsConan(ConanFile):
|
||||
|
||||
def requirements(self):
|
||||
self.requires("gsl-lite/0.41.0")
|
||||
if self._use_libfmt:
|
||||
if self.options.use_fmtlib:
|
||||
self.requires("fmt/10.2.1")
|
||||
|
||||
def build_requirements(self):
|
||||
@@ -146,7 +141,7 @@ class MPUnitsConan(ConanFile):
|
||||
tc.variables["CMAKE_CXX_SCAN_FOR_MODULES"] = True
|
||||
tc.variables["MP_UNITS_BUILD_CXX_MODULES"] = True
|
||||
tc.variables["MP_UNITS_BUILD_LA"] = self._build_all and not self._skip_la
|
||||
tc.variables["MP_UNITS_USE_FMTLIB"] = self._use_libfmt
|
||||
tc.variables["MP_UNITS_USE_FMTLIB"] = bool(self.options.use_fmtlib)
|
||||
tc.generate()
|
||||
deps = CMakeDeps(self)
|
||||
deps.generate()
|
||||
@@ -176,7 +171,7 @@ class MPUnitsConan(ConanFile):
|
||||
def package_info(self):
|
||||
compiler = self.settings.compiler
|
||||
self.cpp_info.components["core"].requires = ["gsl-lite::gsl-lite"]
|
||||
if self._use_libfmt:
|
||||
if self.options.use_fmtlib:
|
||||
self.cpp_info.components["core"].requires.append("fmt::fmt")
|
||||
if compiler == "msvc":
|
||||
self.cpp_info.components["core"].cxxflags = ["/utf-8"]
|
||||
|
@@ -181,7 +181,16 @@ tools.build:compiler_executables={"c": "gcc-12", "cpp": "g++-12"}
|
||||
|
||||
Configures CMake to add C++ modules to the list of default targets.
|
||||
|
||||
[cxx modules support]: https://github.com/mpusz/mp-units/releases/tag/v2.2.0
|
||||
[cxx modules support]: https://github.com/mpusz/mp-units/releases/tag/v2.2.0
|
||||
|
||||
[use_fmtlib](#use_fmtlib){ #use_fmtlib }
|
||||
|
||||
: [:octicons-tag-24: 2.2.0][use fmtlib support] · :octicons-milestone-24: `True`/`False` (Default: `True`)
|
||||
|
||||
Forces usage of [{fmt}](https://github.com/fmtlib/fmt) library instead of the C++20 Standard
|
||||
Library features.
|
||||
|
||||
[use fmtlib support]: https://github.com/mpusz/mp-units/releases/tag/v2.2.0
|
||||
|
||||
### Conan configuration properties
|
||||
|
||||
@@ -195,7 +204,7 @@ tools.build:compiler_executables={"c": "gcc-12", "cpp": "g++-12"}
|
||||
[`tools.build:skip_test`](https://docs.conan.io/2/reference/commands/config.html?highlight=tools.build:skip_test#conan-config-list)
|
||||
configuration property is set to `True`).
|
||||
|
||||
[build all support]: https://github.com/mpusz/mp-units/releases/tag/v0.8.0
|
||||
[build all support]: https://github.com/mpusz/mp-units/releases/tag/v0.8.0
|
||||
|
||||
|
||||
[`user.build:skip_la`](#user-skip-la){ #user-skip-la }
|
||||
|
@@ -32,13 +32,6 @@ class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeDeps"
|
||||
|
||||
@property
|
||||
def _use_libfmt(self):
|
||||
compiler = self.settings.compiler
|
||||
version = Version(self.settings.compiler.version)
|
||||
std_support = compiler == "msvc" and version >= 193 and compiler.cppstd == 23
|
||||
return not std_support
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
@@ -47,7 +40,9 @@ class TestPackageConan(ConanFile):
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.variables["MP_UNITS_USE_FMTLIB"] = self._use_libfmt
|
||||
tc.variables["MP_UNITS_USE_FMTLIB"] = bool(
|
||||
self.dependencies["mp-units"].options.use_fmtlib
|
||||
)
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
|
Reference in New Issue
Block a user