-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#5517) mp-units 0.7.0 support added
* mp-units 0.7.0 added * Conan recipes "oldfashionized" + `all` renamed to `0.7.0`
- Loading branch information
Showing
6 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"0.7.0": | ||
url: https://github.com/mpusz/units/archive/v0.7.0.tar.gz | ||
sha256: 7ff4bc3537e1bd09630fefae513796686a3f97e509283ad658e1ae81fe49de67 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from conans import ConanFile, CMake, tools | ||
from conans.tools import Version, check_min_cppstd | ||
from conans.errors import ConanInvalidConfiguration | ||
import os | ||
|
||
required_conan_version = ">=1.33.0" | ||
|
||
class MPUnitsConan(ConanFile): | ||
name = "mp-units" | ||
homepage = "https://github.com/mpusz/units" | ||
description = "Physical Units library for C++" | ||
topics = ("units", "dimensions", "quantities", "dimensional-analysis", "physical-quantities", "physical-units", "system-of-units", "cpp23", "cpp20", "library", "quantity-manipulation") | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "cmake_find_package_multi" | ||
no_copy_source = True | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
def requirements(self): | ||
compiler = self.settings.compiler | ||
self.requires("fmt/7.1.3") | ||
self.requires("gsl-lite/0.38.0") | ||
if compiler == "clang" and compiler.libcxx == "libc++": | ||
self.requires("range-v3/0.11.0") | ||
|
||
def validate(self): | ||
compiler = self.settings.compiler | ||
version = Version(self.settings.compiler.version) | ||
if compiler == "gcc": | ||
if version < "10.0": | ||
raise ConanInvalidConfiguration("mp-units requires at least g++-10") | ||
elif compiler == "clang": | ||
if version < "12": | ||
raise ConanInvalidConfiguration("mp-units requires at least clang++-12") | ||
elif compiler == "Visual Studio": | ||
if version < "16": | ||
raise ConanInvalidConfiguration("mp-units requires at least Visual Studio 16.9") | ||
else: | ||
raise ConanInvalidConfiguration("Unsupported compiler") | ||
if compiler.get_safe("cppstd"): | ||
check_min_cppstd(self, "20") | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) | ||
|
||
def package(self): | ||
self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) | ||
cmake = CMake(self) | ||
cmake.configure(source_folder=os.path.join(self._source_subfolder, "src")) | ||
cmake.install() | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) | ||
|
||
def package_id(self): | ||
self.info.header_only() | ||
|
||
def package_info(self): | ||
compiler = self.settings.compiler | ||
|
||
# core | ||
self.cpp_info.components["core"].requires = ["gsl-lite::gsl-lite"] | ||
if compiler == "Visual Studio": | ||
self.cpp_info.components["core"].cxxflags = ["/utf-8"] | ||
elif compiler == "clang" and compiler.libcxx == "libc++": | ||
self.cpp_info.components["core"].requires.append("range-v3::range-v3") | ||
|
||
# rest | ||
self.cpp_info.components["core-io"].requires = ["core"] | ||
self.cpp_info.components["core-fmt"].requires = ["core", "fmt::fmt"] | ||
self.cpp_info.components["isq"].requires = ["core"] | ||
self.cpp_info.components["isq-natural"].requires = ["isq"] | ||
self.cpp_info.components["si"].requires = ["isq"] | ||
self.cpp_info.components["si-cgs"].requires = ["si"] | ||
self.cpp_info.components["si-fps"].requires = ["si"] | ||
self.cpp_info.components["si-iau"].requires = ["si"] | ||
self.cpp_info.components["si-imperial"].requires = ["si"] | ||
self.cpp_info.components["si-international"].requires = ["si"] | ||
self.cpp_info.components["si-typographic"].requires = ["si"] | ||
self.cpp_info.components["si-uscs"].requires = ["si"] | ||
self.cpp_info.components["isq-iec80000"].requires = ["si"] | ||
self.cpp_info.components["systems"].requires = ["isq", "isq-natural", "si", "si-cgs", "si-fps", "si-iau", "si-imperial", "si-international", "si-typographic", "si-uscs", "isq-iec80000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(test_package | ||
LANGUAGES CXX | ||
) | ||
|
||
find_package(mp-units CONFIG REQUIRED) | ||
|
||
add_executable(test_package test_package.cpp) | ||
target_link_libraries(test_package PRIVATE mp-units::mp-units) | ||
target_compile_features(test_package PUBLIC cxx_std_20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from conans import ConanFile, CMake, tools | ||
from conans.tools import Version | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake_find_package_multi" | ||
|
||
# TODO remove when https://github.com/conan-io/conan/issues/7680 is solved (or VS2019 is updated to at least 16.9) | ||
def _skip_check(self): | ||
return self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) <= "16" | ||
|
||
def build(self): | ||
if self._skip_check(): | ||
return | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if self._skip_check(): | ||
return | ||
if not tools.cross_building(self.settings): | ||
self.run("test_package", run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <units/isq/si/length.h> | ||
#include <units/isq/si/speed.h> | ||
#include <units/isq/si/time.h> | ||
#include <units/quantity_io.h> | ||
#include <iostream> | ||
|
||
using namespace units; | ||
|
||
template<isq::Length Length, isq::Time Time> | ||
constexpr auto avg_speed(Length d, Time t) | ||
{ | ||
return d / t; | ||
} | ||
|
||
int main() | ||
{ | ||
using namespace units::isq::si::references; | ||
std::cout << "Average speed = " << avg_speed(240 * km, 2 * h) << '\n'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
versions: | ||
"0.7.0": | ||
folder: all | ||
"0.6.0": | ||
folder: 0.6.0 |