mirror of
https://github.com/conan-io/conan-center-index.git
synced 2025-08-09 15:59:39 +00:00
(#16119) simdjson: modernize more for conan v2
This commit is contained in:
@@ -7,7 +7,7 @@ from conan.tools.microsoft import is_msvc
|
||||
from conan.tools.scm import Version
|
||||
import os
|
||||
|
||||
required_conan_version = ">=1.53"
|
||||
required_conan_version = ">=1.53.0"
|
||||
|
||||
|
||||
class SimdjsonConan(ConanFile):
|
||||
@@ -18,6 +18,7 @@ class SimdjsonConan(ConanFile):
|
||||
homepage = "https://github.com/lemire/simdjson"
|
||||
topics = ("json", "parser", "simd", "format")
|
||||
|
||||
package_type = "library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
@@ -30,6 +31,10 @@ class SimdjsonConan(ConanFile):
|
||||
"threads": True,
|
||||
}
|
||||
|
||||
@property
|
||||
def _min_cppstd(self):
|
||||
return "17"
|
||||
|
||||
@property
|
||||
def _compilers_minimum_version(self):
|
||||
return {
|
||||
@@ -48,9 +53,12 @@ class SimdjsonConan(ConanFile):
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self, src_folder="src")
|
||||
|
||||
def validate(self):
|
||||
if self.info.settings.compiler.cppstd:
|
||||
check_min_cppstd(self, "17")
|
||||
if self.settings.compiler.get_safe("cppstd"):
|
||||
check_min_cppstd(self, self._min_cppstd)
|
||||
|
||||
def loose_lt_semver(v1, v2):
|
||||
lv1 = [int(v) for v in v1.split(".")]
|
||||
@@ -58,26 +66,22 @@ class SimdjsonConan(ConanFile):
|
||||
min_length = min(len(lv1), len(lv2))
|
||||
return lv1[:min_length] < lv2[:min_length]
|
||||
|
||||
minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False)
|
||||
if not minimum_version:
|
||||
self.output.warn(f"{self.ref} requires C++17. Your compiler is unknown. Assuming it supports C++17.")
|
||||
elif loose_lt_semver(str(self.info.settings.compiler.version), minimum_version):
|
||||
raise ConanInvalidConfiguration(f"{self.ref} requires C++17, which your compiler does not fully support.")
|
||||
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
|
||||
if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version):
|
||||
raise ConanInvalidConfiguration(
|
||||
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not fully support."
|
||||
)
|
||||
|
||||
if Version(self.version) >= "2.0.0" and \
|
||||
self.info.settings.compiler == "gcc" and \
|
||||
Version(self.info.settings.compiler.version).major == "9":
|
||||
self.settings.compiler == "gcc" and \
|
||||
Version(self.settings.compiler.version).major == "9":
|
||||
if self.settings.compiler.get_safe("libcxx") == "libstdc++11":
|
||||
raise ConanInvalidConfiguration(f"{self.ref} doesn't support GCC 9 with libstdc++11.")
|
||||
if self.info.settings.build_type == "Debug":
|
||||
if self.settings.build_type == "Debug":
|
||||
raise ConanInvalidConfiguration(f"{self.ref} doesn't support GCC 9 with Debug build type.")
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self, src_folder="src")
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version],
|
||||
destination=self.source_folder, strip_root=True)
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
@@ -120,8 +124,7 @@ class SimdjsonConan(ConanFile):
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_file_name", "simdjson")
|
||||
self.cpp_info.set_property("cmake_target_name", "simdjson::simdjson")
|
||||
if Version(self.version) >= "2.2.3":
|
||||
self.cpp_info.set_property("pkg_config_name", "simdjson")
|
||||
self.cpp_info.set_property("pkg_config_name", "simdjson")
|
||||
|
||||
self.cpp_info.libs = ["simdjson"]
|
||||
if self.settings.os in ["Linux", "FreeBSD"]:
|
||||
|
@@ -7,13 +7,14 @@ import os
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
test_type = "explicit"
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
|
Reference in New Issue
Block a user