forked from mpusz/mp-units
Library updated to the latest cmake common tools
This commit is contained in:
+24
-17
@@ -21,15 +21,14 @@
|
||||
# SOFTWARE.
|
||||
|
||||
from conans import ConanFile, CMake, tools
|
||||
from conans.tools import load, Version
|
||||
from conans.tools import Version
|
||||
from conans.errors import ConanInvalidConfiguration
|
||||
import re
|
||||
import os
|
||||
|
||||
|
||||
def get_version():
|
||||
try:
|
||||
content = load("src/CMakeLists.txt")
|
||||
content = tools.load("src/CMakeLists.txt")
|
||||
version = re.search(r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content).group(1)
|
||||
return version.strip()
|
||||
except Exception:
|
||||
@@ -44,20 +43,32 @@ class UnitsConan(ConanFile):
|
||||
url = "https://github.com/mpusz/units"
|
||||
description = "Physical Units library for C++"
|
||||
exports = ["LICENSE.md"]
|
||||
exports_sources = ["src/*", "test/*", "cmake/*", "example/*","CMakeLists.txt"]
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
requires = (
|
||||
"fmt/6.1.0"
|
||||
)
|
||||
build_requires = (
|
||||
"Catch2/2.11.0@catchorg/stable"
|
||||
)
|
||||
scm = {
|
||||
"type": "git",
|
||||
"url": "auto",
|
||||
"revision": "auto",
|
||||
"submodule": "recursive"
|
||||
}
|
||||
generators = "cmake"
|
||||
|
||||
@property
|
||||
def _run_tests(self):
|
||||
return tools.get_env("CONAN_RUN_TESTS", False)
|
||||
|
||||
def _configure_cmake(self, folder="src"):
|
||||
cmake = CMake(self)
|
||||
if self._run_tests:
|
||||
# developer's mode (unit tests, examples, restrictive compilation warnings, ...)
|
||||
cmake.configure()
|
||||
else:
|
||||
# consumer's mode (library sources only)
|
||||
cmake.configure(source_folder=folder, build_folder=folder)
|
||||
return cmake
|
||||
|
||||
def configure(self):
|
||||
if self.settings.compiler != "gcc": # and self.settings.compiler != "clang":
|
||||
raise ConanInvalidConfiguration("Library works only with gcc") # and clang")
|
||||
@@ -68,23 +79,20 @@ class UnitsConan(ConanFile):
|
||||
if self.settings.compiler.cppstd not in ["20", "gnu20"]:
|
||||
raise ConanInvalidConfiguration("Library requires at least C++20 support")
|
||||
|
||||
def _configure_cmake(self, folder="src"):
|
||||
cmake = CMake(self)
|
||||
if self._run_tests:
|
||||
cmake.configure()
|
||||
else:
|
||||
cmake.configure(source_folder="src", build_folder="src")
|
||||
return cmake
|
||||
|
||||
def requirements(self):
|
||||
if self.settings.compiler == "clang" or Version(self.settings.compiler.version) < "10":
|
||||
self.requires("range-v3/0.10.0@ericniebler/stable")
|
||||
|
||||
def build_requirements(self):
|
||||
if self._run_tests:
|
||||
self.build_requires("Catch2/2.11.0@catchorg/stable")
|
||||
self.build_requires("linear_algebra/0.0.1@public-conan/testing")
|
||||
|
||||
def build(self):
|
||||
cmake = self._configure_cmake()
|
||||
cmake.build()
|
||||
if self._run_tests:
|
||||
self.run(os.path.join("bin", "unit_tests_runtime"), run_environment=True)
|
||||
self.run("ctest -VV -C %s" % cmake.build_type, run_environment=True)
|
||||
|
||||
def package(self):
|
||||
self.copy(pattern="LICENSE.md", dst="licenses")
|
||||
@@ -92,7 +100,6 @@ class UnitsConan(ConanFile):
|
||||
cmake.install()
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.includedirs = ['include']
|
||||
if self.settings.compiler == "gcc":
|
||||
self.cpp_info.cxxflags = [
|
||||
"-Wno-literal-suffix",
|
||||
|
||||
Reference in New Issue
Block a user