mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-05 13:14:29 +02:00
build: conanfile.py
cleanup
This commit is contained in:
26
conanfile.py
26
conanfile.py
@@ -28,7 +28,7 @@ import os, re
|
|||||||
|
|
||||||
required_conan_version = ">=1.44.0"
|
required_conan_version = ">=1.44.0"
|
||||||
|
|
||||||
class UnitsConan(ConanFile):
|
class MPUnitsConan(ConanFile):
|
||||||
name = "mp-units"
|
name = "mp-units"
|
||||||
homepage = "https://github.com/mpusz/units"
|
homepage = "https://github.com/mpusz/units"
|
||||||
description = "Physical Units library for C++"
|
description = "Physical Units library for C++"
|
||||||
@@ -49,12 +49,6 @@ class UnitsConan(ConanFile):
|
|||||||
}
|
}
|
||||||
exports = ["LICENSE.md"]
|
exports = ["LICENSE.md"]
|
||||||
exports_sources = ["docs/*", "src/*", "test/*", "cmake/*", "example/*","CMakeLists.txt"]
|
exports_sources = ["docs/*", "src/*", "test/*", "cmake/*", "example/*","CMakeLists.txt"]
|
||||||
# scm = {
|
|
||||||
# "type": "git",
|
|
||||||
# "url": "auto",
|
|
||||||
# "revision": "auto",
|
|
||||||
# "submodule": "recursive"
|
|
||||||
# }
|
|
||||||
generators = "cmake_paths"
|
generators = "cmake_paths"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -66,7 +60,7 @@ class UnitsConan(ConanFile):
|
|||||||
compiler = self.settings.compiler
|
compiler = self.settings.compiler
|
||||||
version = Version(self.settings.compiler.version)
|
version = Version(self.settings.compiler.version)
|
||||||
std_support = \
|
std_support = \
|
||||||
(compiler == "Visual Studio" and version >= "17" and compiler.cppstd == 23) or \
|
(compiler == "Visual Studio" and version >= 17 and compiler.cppstd == 23) or \
|
||||||
(compiler == "msvc" and version >= 193 and compiler.cppstd == 23)
|
(compiler == "msvc" and version >= 193 and compiler.cppstd == 23)
|
||||||
return not std_support
|
return not std_support
|
||||||
|
|
||||||
@@ -74,7 +68,7 @@ class UnitsConan(ConanFile):
|
|||||||
def _use_range_v3(self):
|
def _use_range_v3(self):
|
||||||
compiler = self.settings.compiler
|
compiler = self.settings.compiler
|
||||||
version = Version(self.settings.compiler.version)
|
version = Version(self.settings.compiler.version)
|
||||||
return ("clang" in compiler and compiler.libcxx == "libc++" and version < "14.0")
|
return ("clang" in compiler and compiler.libcxx == "libc++" and version < 14)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _msvc_version(self):
|
def _msvc_version(self):
|
||||||
@@ -107,23 +101,23 @@ class UnitsConan(ConanFile):
|
|||||||
compiler = self.settings.compiler
|
compiler = self.settings.compiler
|
||||||
version = Version(self.settings.compiler.version)
|
version = Version(self.settings.compiler.version)
|
||||||
if compiler == "gcc":
|
if compiler == "gcc":
|
||||||
if version < "10.0":
|
if version < 10:
|
||||||
raise ConanInvalidConfiguration("mp-units requires at least g++-10")
|
raise ConanInvalidConfiguration("mp-units requires at least g++-10")
|
||||||
elif compiler == "clang":
|
elif compiler == "clang":
|
||||||
if version < "12":
|
if version < 12:
|
||||||
raise ConanInvalidConfiguration("mp-units requires at least clang++-12")
|
raise ConanInvalidConfiguration("mp-units requires at least clang++-12")
|
||||||
elif compiler == "apple-clang":
|
elif compiler == "apple-clang":
|
||||||
if version < "13":
|
if version < 13:
|
||||||
raise ConanInvalidConfiguration("mp-units requires at least AppleClang 13")
|
raise ConanInvalidConfiguration("mp-units requires at least AppleClang 13")
|
||||||
elif compiler == "Visual Studio":
|
elif compiler == "Visual Studio":
|
||||||
if version < "16":
|
if version < 16:
|
||||||
raise ConanInvalidConfiguration("mp-units requires at least Visual Studio 16.9")
|
raise ConanInvalidConfiguration("mp-units requires at least Visual Studio 16.9")
|
||||||
elif compiler == "msvc":
|
elif compiler == "msvc":
|
||||||
if self._msvc_version < 1928:
|
if self._msvc_version < 1928:
|
||||||
raise ConanInvalidConfiguration("mp-units requires at least MSVC 19.28")
|
raise ConanInvalidConfiguration("mp-units requires at least MSVC 19.28")
|
||||||
else:
|
else:
|
||||||
raise ConanInvalidConfiguration("Unsupported compiler")
|
raise ConanInvalidConfiguration("Unsupported compiler")
|
||||||
check_min_cppstd(self, "20")
|
check_min_cppstd(self, 20)
|
||||||
|
|
||||||
# TODO Uncomment this when environment is supported in the Conan toolchain
|
# TODO Uncomment this when environment is supported in the Conan toolchain
|
||||||
# def config_options(self):
|
# def config_options(self):
|
||||||
@@ -135,7 +129,7 @@ class UnitsConan(ConanFile):
|
|||||||
tc = CMakeToolchain(self)
|
tc = CMakeToolchain(self)
|
||||||
tc.variables["UNITS_DOWNCAST_MODE"] = str(self.options.downcast_mode).upper()
|
tc.variables["UNITS_DOWNCAST_MODE"] = str(self.options.downcast_mode).upper()
|
||||||
# if self._run_tests: # TODO Enable this when environment is supported in the Conan toolchain
|
# if self._run_tests: # TODO Enable this when environment is supported in the Conan toolchain
|
||||||
tc.variables["UNITS_BUILD_DOCS"] = self.options.build_docs == "True"
|
tc.variables["UNITS_BUILD_DOCS"] = bool(self.options.build_docs)
|
||||||
tc.variables["UNITS_USE_LIBFMT"] = self._use_libfmt
|
tc.variables["UNITS_USE_LIBFMT"] = self._use_libfmt
|
||||||
tc.generate()
|
tc.generate()
|
||||||
deps = CMakeDeps(self)
|
deps = CMakeDeps(self)
|
||||||
@@ -152,7 +146,7 @@ class UnitsConan(ConanFile):
|
|||||||
self.info.header_only()
|
self.info.header_only()
|
||||||
|
|
||||||
def package(self):
|
def package(self):
|
||||||
self.copy(pattern="LICENSE.md", dst="licenses")
|
self.copy("LICENSE.md", dst="licenses")
|
||||||
cmake = CMake(self)
|
cmake = CMake(self)
|
||||||
cmake.install()
|
cmake.install()
|
||||||
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
|
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
|
||||||
|
Reference in New Issue
Block a user