2019-04-04 10:34:58 +02:00
|
|
|
# The MIT License (MIT)
|
|
|
|
#
|
|
|
|
# Copyright (c) 2018 Mateusz Pusz
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
|
|
# copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
# SOFTWARE.
|
|
|
|
|
2022-05-12 14:00:18 +02:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
|
2022-05-05 09:46:35 +02:00
|
|
|
from conan import ConanFile
|
2023-05-26 13:53:52 +02:00
|
|
|
from conan.errors import ConanInvalidConfiguration
|
2024-04-16 21:48:36 +01:00
|
|
|
from conan.tools.build import can_run, default_cppstd, valid_min_cppstd
|
2022-08-01 18:29:03 +02:00
|
|
|
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
|
2022-05-05 19:18:19 +02:00
|
|
|
from conan.tools.files import copy, load, rmdir
|
2024-06-20 14:56:54 +02:00
|
|
|
from conan.tools.scm import Version
|
2022-05-12 17:10:11 +02:00
|
|
|
|
2024-07-24 22:44:51 +02:00
|
|
|
required_conan_version = ">=2.0.15"
|
2019-04-10 17:12:24 +01:00
|
|
|
|
2022-04-15 16:56:48 +02:00
|
|
|
|
2022-03-14 19:26:43 +01:00
|
|
|
class MPUnitsConan(ConanFile):
|
2019-04-07 08:33:13 +02:00
|
|
|
name = "mp-units"
|
2023-06-16 09:39:49 +03:00
|
|
|
homepage = "https://github.com/mpusz/mp-units"
|
2024-01-03 17:54:57 +01:00
|
|
|
description = "The quantities and units library for C++"
|
2022-04-15 16:56:48 +02:00
|
|
|
topics = (
|
|
|
|
"units",
|
|
|
|
"dimensions",
|
|
|
|
"quantities",
|
|
|
|
"dimensional-analysis",
|
|
|
|
"physical-quantities",
|
|
|
|
"physical-units",
|
|
|
|
"system-of-units",
|
2023-05-26 13:53:52 +02:00
|
|
|
"system-of-quantities",
|
|
|
|
"isq",
|
|
|
|
"si",
|
2022-04-15 16:56:48 +02:00
|
|
|
"library",
|
|
|
|
"quantity-manipulation",
|
|
|
|
)
|
2020-09-06 00:00:06 +02:00
|
|
|
license = "MIT"
|
2023-06-16 09:39:49 +03:00
|
|
|
url = "https://github.com/mpusz/mp-units"
|
2023-05-26 13:53:52 +02:00
|
|
|
settings = "os", "arch", "compiler", "build_type"
|
2024-01-06 08:51:01 +01:00
|
|
|
options = {
|
2024-07-03 18:45:19 +01:00
|
|
|
"cxx_modules": [True, False],
|
2024-07-16 17:36:00 +02:00
|
|
|
"import_std": [True, False],
|
2024-07-03 18:45:19 +01:00
|
|
|
"std_format": [True, False],
|
|
|
|
"no_crtp": [True, False],
|
2024-05-30 12:23:14 +02:00
|
|
|
"contracts": ["none", "gsl-lite", "ms-gsl"],
|
2024-05-30 19:50:02 +02:00
|
|
|
"freestanding": [True, False],
|
2024-01-06 08:51:01 +01:00
|
|
|
}
|
|
|
|
default_options = {
|
2024-07-03 18:45:19 +01:00
|
|
|
# "cxx_modules" default set in config_options()
|
2024-07-16 17:36:00 +02:00
|
|
|
# "import_std" default set in config_options()
|
2024-07-03 18:45:19 +01:00
|
|
|
# "std_format" default set in config_options()
|
|
|
|
# "no_crtp" default set in config_options()
|
2024-05-30 12:23:14 +02:00
|
|
|
"contracts": "gsl-lite",
|
2024-06-20 14:56:54 +02:00
|
|
|
"freestanding": False,
|
2024-01-06 08:51:01 +01:00
|
|
|
}
|
2024-09-27 12:12:26 +02:00
|
|
|
implements = ["auto_header_only"]
|
2024-02-17 23:02:00 +01:00
|
|
|
exports = "LICENSE.md"
|
|
|
|
exports_sources = (
|
2022-05-12 13:58:32 +02:00
|
|
|
"docs/*",
|
|
|
|
"src/*",
|
|
|
|
"test/*",
|
|
|
|
"cmake/*",
|
|
|
|
"example/*",
|
|
|
|
"CMakeLists.txt",
|
2024-02-17 23:02:00 +01:00
|
|
|
)
|
2022-05-05 11:54:23 +02:00
|
|
|
no_copy_source = True
|
2023-05-26 13:53:52 +02:00
|
|
|
|
|
|
|
@property
|
2024-04-16 21:48:36 +01:00
|
|
|
def _feature_compatibility(self):
|
2023-08-26 20:05:09 +02:00
|
|
|
return {
|
2024-04-16 21:48:36 +01:00
|
|
|
"minimum_support": {
|
2024-07-03 18:45:19 +01:00
|
|
|
"min_cppstd": "20",
|
2024-04-16 21:48:36 +01:00
|
|
|
"compiler": {
|
|
|
|
"gcc": "12",
|
|
|
|
"clang": "16",
|
|
|
|
"apple-clang": "15",
|
2024-08-30 13:42:28 +02:00
|
|
|
"msvc": "194",
|
2024-04-16 21:48:36 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"std_format": {
|
2024-07-03 18:45:19 +01:00
|
|
|
"min_cppstd": "20",
|
2024-04-16 21:48:36 +01:00
|
|
|
"compiler": {
|
|
|
|
"gcc": "13",
|
|
|
|
"clang": "17",
|
2024-12-19 11:47:00 -05:00
|
|
|
"apple-clang": "16",
|
2024-09-17 20:14:57 -06:00
|
|
|
"msvc": "194",
|
2024-04-16 21:48:36 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"cxx_modules": {
|
2024-07-03 18:45:19 +01:00
|
|
|
"min_cppstd": "20",
|
2024-06-20 14:56:54 +02:00
|
|
|
"compiler": {"gcc": "", "clang": "17", "apple-clang": "", "msvc": ""},
|
2024-04-16 21:48:36 +01:00
|
|
|
},
|
2024-07-16 17:36:00 +02:00
|
|
|
"import_std": {
|
|
|
|
"min_cppstd": "23",
|
|
|
|
"compiler": {"gcc": "", "clang": "18", "apple-clang": "", "msvc": ""},
|
|
|
|
},
|
2024-04-16 21:48:36 +01:00
|
|
|
"explicit_this": {
|
2024-07-03 18:45:19 +01:00
|
|
|
"min_cppstd": "23",
|
2024-04-16 21:48:36 +01:00
|
|
|
"compiler": {
|
|
|
|
"gcc": "14",
|
|
|
|
"clang": "18",
|
|
|
|
"apple-clang": "",
|
|
|
|
"msvc": "",
|
|
|
|
},
|
|
|
|
},
|
2023-08-26 20:05:09 +02:00
|
|
|
}
|
2018-08-22 12:11:19 +02:00
|
|
|
|
2024-01-23 23:08:14 +01:00
|
|
|
@property
|
2024-04-16 21:48:36 +01:00
|
|
|
def _option_feature_map(self):
|
2024-01-23 23:08:14 +01:00
|
|
|
return {
|
2024-04-16 21:48:36 +01:00
|
|
|
"std_format": "std_format",
|
|
|
|
"cxx_modules": "cxx_modules",
|
2024-07-16 17:36:00 +02:00
|
|
|
"import_std": "import_std",
|
2024-04-16 21:48:36 +01:00
|
|
|
"no_crtp": "explicit_this",
|
2024-01-23 23:08:14 +01:00
|
|
|
}
|
|
|
|
|
2024-07-03 18:45:19 +01:00
|
|
|
def _set_default_option(self, name):
|
|
|
|
compiler = self.settings.compiler
|
|
|
|
feature_name = self._option_feature_map[name]
|
|
|
|
feature = self._feature_compatibility[feature_name]
|
|
|
|
min_version = feature["compiler"].get(str(compiler))
|
|
|
|
setattr(
|
|
|
|
self.options,
|
|
|
|
name,
|
|
|
|
bool(
|
|
|
|
min_version
|
|
|
|
and Version(compiler.version) >= min_version
|
|
|
|
and valid_min_cppstd(self, feature["min_cppstd"])
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2024-04-16 21:48:36 +01:00
|
|
|
def _check_feature_supported(self, name, feature_name=name):
|
|
|
|
compiler = self.settings.compiler
|
|
|
|
cppstd = compiler.get_safe("cppstd", default_cppstd(self))
|
|
|
|
feature = self._feature_compatibility[feature_name]
|
|
|
|
|
|
|
|
# check C++ version
|
2024-07-03 18:45:19 +01:00
|
|
|
if not valid_min_cppstd(self, feature["min_cppstd"]):
|
2024-04-16 21:48:36 +01:00
|
|
|
raise ConanInvalidConfiguration(
|
2024-07-03 18:45:19 +01:00
|
|
|
f"'{name}' requires at least cppstd={feature['min_cppstd']} ({cppstd} in use)",
|
2024-04-16 21:48:36 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
# check compiler version
|
|
|
|
min_version = feature["compiler"].get(str(compiler))
|
2024-04-17 11:40:24 +01:00
|
|
|
if min_version == None:
|
2024-04-16 21:48:36 +01:00
|
|
|
# not tested compiler being used - use at your own risk
|
|
|
|
return
|
|
|
|
if min_version == "":
|
|
|
|
raise ConanInvalidConfiguration(
|
2024-07-03 18:45:19 +01:00
|
|
|
f"'{name}' is not yet supported by any known {compiler} version"
|
2024-04-16 21:48:36 +01:00
|
|
|
)
|
2024-06-20 14:56:54 +02:00
|
|
|
if Version(compiler.version) < min_version:
|
2024-04-16 21:48:36 +01:00
|
|
|
raise ConanInvalidConfiguration(
|
|
|
|
f"'{name}' requires at least {compiler}-{min_version} ({compiler}-{compiler.version} in use)"
|
|
|
|
)
|
|
|
|
|
2019-11-20 16:33:50 -03:00
|
|
|
@property
|
2022-08-02 17:09:05 +02:00
|
|
|
def _build_all(self):
|
2024-02-10 12:19:44 +01:00
|
|
|
return bool(self.conf.get("user.mp-units.build:all", default=False))
|
2023-05-26 13:53:52 +02:00
|
|
|
|
|
|
|
@property
|
|
|
|
def _skip_la(self):
|
2024-07-11 19:18:28 +02:00
|
|
|
# broken until https://github.com/BobSteagall/wg21/issues/77 is fixed
|
|
|
|
return bool(self.conf.get("user.mp-units.build:skip_la", default=True))
|
2022-08-02 17:09:05 +02:00
|
|
|
|
2024-05-30 15:00:25 +02:00
|
|
|
@property
|
|
|
|
def _run_clang_tidy(self):
|
|
|
|
return bool(self.conf.get("user.mp-units.analyze:clang-tidy", default=False))
|
|
|
|
|
2021-03-05 12:14:42 +01:00
|
|
|
def set_version(self):
|
2022-05-05 09:46:35 +02:00
|
|
|
content = load(self, os.path.join(self.recipe_folder, "src/CMakeLists.txt"))
|
2022-05-12 13:58:32 +02:00
|
|
|
version = re.search(
|
|
|
|
r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content
|
|
|
|
).group(1)
|
2021-03-05 12:14:42 +01:00
|
|
|
self.version = version.strip()
|
|
|
|
|
2024-07-03 18:45:19 +01:00
|
|
|
def config_options(self):
|
|
|
|
for key in self._option_feature_map.keys():
|
|
|
|
self._set_default_option(key)
|
2024-09-27 12:53:23 +02:00
|
|
|
# TODO mixing of `import std;` and regular header files includes does not work for now
|
|
|
|
if self.options.import_std:
|
|
|
|
self.options.contracts = "none"
|
2024-07-03 18:45:19 +01:00
|
|
|
|
2024-06-20 14:56:54 +02:00
|
|
|
def configure(self):
|
2024-09-27 07:53:13 +02:00
|
|
|
if self.options.cxx_modules:
|
|
|
|
self.package_type = "static-library"
|
|
|
|
else:
|
|
|
|
self.package_type = "header-library"
|
2024-06-20 14:56:54 +02:00
|
|
|
if self.options.freestanding:
|
|
|
|
self.options.rm_safe("std_format")
|
|
|
|
|
2021-04-29 08:35:58 +02:00
|
|
|
def requirements(self):
|
2024-06-10 22:06:06 +02:00
|
|
|
if not self.options.freestanding:
|
|
|
|
if self.options.contracts == "gsl-lite":
|
2025-04-29 13:03:04 +02:00
|
|
|
self.requires("gsl-lite/0.42.0", transitive_headers=True)
|
2024-06-10 22:06:06 +02:00
|
|
|
elif self.options.contracts == "ms-gsl":
|
2025-04-29 13:03:04 +02:00
|
|
|
self.requires("ms-gsl/4.1.0", transitive_headers=True)
|
2024-07-03 18:45:19 +01:00
|
|
|
if not self.options.std_format:
|
2025-04-29 13:03:04 +02:00
|
|
|
self.requires("fmt/11.1.4", transitive_headers=True)
|
2021-04-29 08:35:58 +02:00
|
|
|
|
|
|
|
def build_requirements(self):
|
2024-11-18 14:45:27 +01:00
|
|
|
self.tool_requires("cmake/[>=3.31 <4]")
|
2022-08-02 17:09:05 +02:00
|
|
|
if self._build_all:
|
2024-05-30 20:14:11 +02:00
|
|
|
if not self.options.freestanding:
|
2025-04-29 13:03:04 +02:00
|
|
|
self.test_requires("catch2/3.8.0")
|
2023-05-26 13:53:52 +02:00
|
|
|
if not self._skip_la:
|
|
|
|
self.test_requires("wg21-linear_algebra/0.7.3")
|
2021-04-29 08:35:58 +02:00
|
|
|
|
2023-05-26 13:53:52 +02:00
|
|
|
def validate(self):
|
2025-04-03 08:09:17 +01:00
|
|
|
compiler = self.settings.compiler
|
|
|
|
if compiler == "clang" and Version(compiler.version).major == 19:
|
|
|
|
raise ConanInvalidConfiguration(
|
|
|
|
"clang-19 does not build mp-units because of an unfixable bug in the compiler."
|
|
|
|
)
|
|
|
|
|
2024-04-16 21:48:36 +01:00
|
|
|
self._check_feature_supported("mp-units", "minimum_support")
|
|
|
|
for key, value in self._option_feature_map.items():
|
2024-04-17 11:40:24 +01:00
|
|
|
if self.options.get_safe(key) == True:
|
2024-04-16 21:48:36 +01:00
|
|
|
self._check_feature_supported(key, value)
|
2024-05-30 19:50:02 +02:00
|
|
|
if self.options.freestanding and self.options.contracts != "none":
|
|
|
|
raise ConanInvalidConfiguration(
|
|
|
|
"'contracts' should be set to 'none' for a freestanding build"
|
|
|
|
)
|
2024-09-27 12:53:23 +02:00
|
|
|
# TODO mixing of `import std;` and regular header files includes does not work for now
|
2024-07-16 17:36:00 +02:00
|
|
|
if self.options.import_std:
|
|
|
|
if self.options.contracts != "none":
|
|
|
|
raise ConanInvalidConfiguration(
|
|
|
|
"'contracts' should be set to 'none' to use `import std;`"
|
|
|
|
)
|
2024-07-29 10:25:09 +02:00
|
|
|
if not self.options.get_safe("std_format", default=True):
|
2024-07-16 17:36:00 +02:00
|
|
|
raise ConanInvalidConfiguration(
|
|
|
|
"'std_format' should be enabled to use `import std;`"
|
|
|
|
)
|
2019-04-10 17:19:55 +01:00
|
|
|
|
2022-08-01 18:29:03 +02:00
|
|
|
def layout(self):
|
|
|
|
cmake_layout(self)
|
|
|
|
|
2020-12-21 22:38:27 +01:00
|
|
|
def generate(self):
|
2024-09-27 12:53:23 +02:00
|
|
|
opt = self.options
|
2021-09-09 09:01:05 +02:00
|
|
|
tc = CMakeToolchain(self)
|
2024-05-24 09:39:15 +02:00
|
|
|
tc.absolute_paths = True # only needed for CMake CI
|
2024-01-12 12:30:57 +01:00
|
|
|
if self._build_all:
|
2024-05-08 12:16:37 +02:00
|
|
|
tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
|
2024-12-28 14:02:22 +01:00
|
|
|
tc.cache_variables["CMAKE_VERIFY_INTERFACE_HEADER_SETS"] = (
|
|
|
|
not opt.import_std
|
|
|
|
)
|
2024-04-16 21:48:36 +01:00
|
|
|
tc.cache_variables["MP_UNITS_DEV_BUILD_LA"] = not self._skip_la
|
2024-05-30 15:00:25 +02:00
|
|
|
if self._run_clang_tidy:
|
|
|
|
tc.cache_variables["MP_UNITS_DEV_CLANG_TIDY"] = True
|
2024-09-27 12:53:23 +02:00
|
|
|
if opt.cxx_modules:
|
2024-02-17 22:46:24 +01:00
|
|
|
tc.cache_variables["CMAKE_CXX_SCAN_FOR_MODULES"] = True
|
2024-07-03 18:45:19 +01:00
|
|
|
tc.cache_variables["MP_UNITS_BUILD_CXX_MODULES"] = True
|
2024-09-27 12:53:23 +02:00
|
|
|
if opt.import_std:
|
2024-07-16 17:36:00 +02:00
|
|
|
tc.cache_variables["CMAKE_CXX_MODULE_STD"] = True
|
|
|
|
# Current experimental support according to `Help/dev/experimental.rst`
|
2024-12-28 14:02:22 +01:00
|
|
|
tc.cache_variables["CMAKE_EXPERIMENTAL_CXX_IMPORT_STD"] = (
|
|
|
|
"0e5b6991-d74f-4b3d-a41c-cf096e0b2508"
|
|
|
|
)
|
2024-09-27 12:53:23 +02:00
|
|
|
|
|
|
|
# TODO remove the below when Conan will learn to handle C++ modules
|
|
|
|
if opt.freestanding:
|
2024-06-10 22:06:06 +02:00
|
|
|
tc.cache_variables["MP_UNITS_API_FREESTANDING"] = True
|
|
|
|
else:
|
2024-09-27 12:53:23 +02:00
|
|
|
tc.cache_variables["MP_UNITS_API_STD_FORMAT"] = opt.std_format
|
|
|
|
tc.cache_variables["MP_UNITS_API_NO_CRTP"] = opt.no_crtp
|
|
|
|
tc.cache_variables["MP_UNITS_API_CONTRACTS"] = str(opt.contracts).upper()
|
|
|
|
|
2020-12-21 22:38:27 +01:00
|
|
|
tc.generate()
|
2021-01-28 18:51:48 +01:00
|
|
|
deps = CMakeDeps(self)
|
|
|
|
deps.generate()
|
2020-12-21 22:38:27 +01:00
|
|
|
|
2019-05-08 09:52:46 -06:00
|
|
|
def build(self):
|
2021-04-29 08:35:58 +02:00
|
|
|
cmake = CMake(self)
|
2022-08-02 17:09:05 +02:00
|
|
|
cmake.configure(build_script_folder=None if self._build_all else "src")
|
2024-07-03 18:45:19 +01:00
|
|
|
if self._build_all or self.options.cxx_modules:
|
2024-06-20 14:56:54 +02:00
|
|
|
cmake.build()
|
2022-08-02 17:09:05 +02:00
|
|
|
if self._build_all:
|
2024-07-29 11:20:15 +02:00
|
|
|
if not self.options.import_std:
|
|
|
|
cmake.build(target="all_verify_interface_header_sets")
|
2024-02-17 22:47:46 +01:00
|
|
|
if can_run(self):
|
2024-02-27 09:46:22 +01:00
|
|
|
cmake.ctest(cli_args=["--output-on-failure"])
|
2022-03-10 18:55:40 +01:00
|
|
|
|
2019-04-06 23:25:35 +02:00
|
|
|
def package(self):
|
2022-05-12 13:58:32 +02:00
|
|
|
copy(
|
|
|
|
self,
|
|
|
|
"LICENSE.md",
|
|
|
|
self.source_folder,
|
|
|
|
os.path.join(self.package_folder, "licenses"),
|
|
|
|
)
|
2021-04-29 08:35:58 +02:00
|
|
|
cmake = CMake(self)
|
2019-05-08 09:52:46 -06:00
|
|
|
cmake.install()
|
2024-09-27 12:53:23 +02:00
|
|
|
# TODO remove the below when Conan will learn to handle C++ modules
|
2024-09-27 12:12:26 +02:00
|
|
|
if not self.options.cxx_modules:
|
|
|
|
# We have to preserve those files for C++ modules build as Conan
|
|
|
|
# can't generate such CMake targets for now
|
|
|
|
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
|
2020-09-06 00:00:06 +02:00
|
|
|
|
2018-08-22 12:11:19 +02:00
|
|
|
def package_info(self):
|
2020-09-06 00:00:06 +02:00
|
|
|
compiler = self.settings.compiler
|
2024-09-27 12:53:23 +02:00
|
|
|
# TODO remove the branch when Conan will learn to handle C++ modules
|
2024-09-27 12:12:26 +02:00
|
|
|
if self.options.cxx_modules:
|
|
|
|
# CMakeDeps does not generate C++ modules definitions for now
|
|
|
|
# Skip the Conan-generated files and use the mp-unitsConfig.cmake bundled with mp-units
|
|
|
|
self.cpp_info.set_property("cmake_find_mode", "none")
|
|
|
|
self.cpp_info.builddirs = ["."]
|
|
|
|
else:
|
|
|
|
# handle contracts
|
|
|
|
if self.options.contracts == "none":
|
|
|
|
self.cpp_info.components["core"].defines.append(
|
|
|
|
"MP_UNITS_API_CONTRACTS=0"
|
|
|
|
)
|
|
|
|
elif self.options.contracts == "gsl-lite":
|
|
|
|
self.cpp_info.components["core"].requires.append("gsl-lite::gsl-lite")
|
|
|
|
self.cpp_info.components["core"].defines.append(
|
|
|
|
"MP_UNITS_API_CONTRACTS=2"
|
|
|
|
)
|
|
|
|
elif self.options.contracts == "ms-gsl":
|
|
|
|
self.cpp_info.components["core"].requires.append("ms-gsl::ms-gsl")
|
|
|
|
self.cpp_info.components["core"].defines.append(
|
|
|
|
"MP_UNITS_API_CONTRACTS=3"
|
|
|
|
)
|
2024-06-10 22:06:48 +02:00
|
|
|
|
2024-09-27 12:12:26 +02:00
|
|
|
# handle API options
|
|
|
|
self.cpp_info.components["core"].defines.append(
|
|
|
|
"MP_UNITS_API_NO_CRTP=" + str(int(self.options.no_crtp == True))
|
|
|
|
)
|
|
|
|
self.cpp_info.components["core"].defines.append(
|
|
|
|
"MP_UNITS_API_STD_FORMAT=" + str(int(self.options.std_format == True))
|
|
|
|
)
|
|
|
|
if not self.options.std_format:
|
|
|
|
self.cpp_info.components["core"].requires.append("fmt::fmt")
|
2024-06-10 22:06:48 +02:00
|
|
|
|
2024-09-27 12:12:26 +02:00
|
|
|
# handle hosted configuration
|
|
|
|
if not self.options.freestanding:
|
|
|
|
self.cpp_info.components["core"].defines.append("MP_UNITS_HOSTED=1")
|
2024-06-10 22:06:48 +02:00
|
|
|
|
2024-09-27 12:12:26 +02:00
|
|
|
# handle import std
|
|
|
|
if self.options.import_std:
|
|
|
|
self.cpp_info.components["core"].defines.append("MP_UNITS_IMPORT_STD")
|
|
|
|
if compiler == "clang" and Version(compiler.version) < 19:
|
|
|
|
self.cpp_info.components["core"].cxxflags.append(
|
|
|
|
"-Wno-deprecated-declarations"
|
|
|
|
)
|
2024-06-10 22:06:48 +02:00
|
|
|
|
2024-09-27 12:12:26 +02:00
|
|
|
if compiler == "msvc":
|
|
|
|
self.cpp_info.components["core"].cxxflags.append("/utf-8")
|
2024-06-10 22:06:48 +02:00
|
|
|
|
2024-09-27 12:12:26 +02:00
|
|
|
self.cpp_info.components["systems"].requires = ["core"]
|
2025-04-03 08:10:02 +01:00
|
|
|
|
|
|
|
# https://github.com/llvm/llvm-project/issues/131410
|
|
|
|
if (
|
|
|
|
compiler == "clang"
|
|
|
|
and Version(compiler.version).major == 20
|
|
|
|
and Version(compiler.version).minor == 1
|
|
|
|
):
|
|
|
|
self.cpp_info.components["core"].cxxflags.append("-Wno-unused-result")
|