From c890f1fb8dcf2d70998bc439fcffc1033d9d95e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kardos?= Date: Wed, 18 Sep 2024 14:40:34 +0200 Subject: [PATCH 1/4] added new version mathter/2.0.0 --- recipes/mathter/1.x.x/conandata.yml | 13 +++ recipes/mathter/1.x.x/conanfile.py | 84 +++++++++++++++++++ .../mathter/1.x.x/test_package/CMakeLists.txt | 8 ++ .../mathter/1.x.x/test_package/conanfile.py | 26 ++++++ .../1.x.x/test_package/test_package.cpp | 16 ++++ .../test_v1_package/CMakeLists.txt | 0 .../test_v1_package/conanfile.py | 0 recipes/mathter/all/conandata.yml | 15 +--- recipes/mathter/all/conanfile.py | 50 ++++++----- .../mathter/all/test_package/test_package.cpp | 34 ++++++-- recipes/mathter/config.yml | 10 ++- 11 files changed, 212 insertions(+), 44 deletions(-) create mode 100644 recipes/mathter/1.x.x/conandata.yml create mode 100644 recipes/mathter/1.x.x/conanfile.py create mode 100644 recipes/mathter/1.x.x/test_package/CMakeLists.txt create mode 100644 recipes/mathter/1.x.x/test_package/conanfile.py create mode 100644 recipes/mathter/1.x.x/test_package/test_package.cpp rename recipes/mathter/{all => 1.x.x}/test_v1_package/CMakeLists.txt (100%) rename recipes/mathter/{all => 1.x.x}/test_v1_package/conanfile.py (100%) diff --git a/recipes/mathter/1.x.x/conandata.yml b/recipes/mathter/1.x.x/conandata.yml new file mode 100644 index 0000000000000..f12b02f2c9224 --- /dev/null +++ b/recipes/mathter/1.x.x/conandata.yml @@ -0,0 +1,13 @@ +sources: + "1.1.1": + url: "https://github.com/petiaccja/Mathter/archive/v1.1.1.tar.gz" + sha256: "510e6aa198cd7b207a44d319e4471021f207cba8c4d2d7e40086f1f042fe13ab" + "1.1.0": + url: "https://github.com/petiaccja/Mathter/archive/v1.1.0.tar.gz" + sha256: "a9a82126ecd80112854098a5646d38f72f0af03e9655b28ab8fa38b4c03b0870" + "1.0.1": + url: "https://github.com/petiaccja/Mathter/archive/v1.0.1.tar.gz" + sha256: "ab90736abfa8774103b53fe2b8962981c5f117dc582b01698c18d66cd2398b8c" + "1.0.0": + url: "https://github.com/petiaccja/Mathter/archive/v1.0.0.tar.gz" + sha256: "c75cca8d8aec627935250908f2c0f9f1839561e7596a4199bcf80e12b0e6c53b" diff --git a/recipes/mathter/1.x.x/conanfile.py b/recipes/mathter/1.x.x/conanfile.py new file mode 100644 index 0000000000000..82cdb44fbd38a --- /dev/null +++ b/recipes/mathter/1.x.x/conanfile.py @@ -0,0 +1,84 @@ +import os + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version + +required_conan_version = ">=1.52.0" + + +class MathterConan(ConanFile): + name = "mathter" + description = "Powerful 3D math and small-matrix linear algebra library for games and science." + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/petiaccja/Mathter" + topics = ("game-dev", "linear-algebra", "vector-math", "matrix-library", "header-only") + + package_type = "header-library" + settings = "os", "arch", "compiler", "build_type" + options = { + "with_xsimd": [True, False] # XSimd is optionally used for hand-rolled vectorization. + } + default_options = { + "with_xsimd": True + } + no_copy_source = True + + @property + def _min_cppstd(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "apple-clang": 10, + "clang": 6, + "gcc": 7, + "Visual Studio": 16, + } + + def config_options(self): + if Version(self.version) < "1.1": + del self.options.with_xsimd + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration(f"{self.name} requires C++{self._min_cppstd}, " + "which your compiler does not support.") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def requirements(self): + if self.options.get_safe("with_xsimd"): + self.requires("xsimd/11.1.0") + + def package(self): + if self.version == "1.0.0": + copy(self, "LICENCE", self.source_folder, os.path.join(self.package_folder, "licenses")) + include_dir = os.path.join(self.source_folder, "Mathter") + else: + copy(self, "LICENCE.md", self.source_folder, os.path.join(self.package_folder, "licenses")) + include_dir = os.path.join(self.source_folder, "include", "Mathter") + copy(self, "*.hpp", include_dir, os.path.join(self.package_folder, "include", "Mathter")) + copy(self, "*.natvis", include_dir, os.path.join(self.package_folder, "include", "Mathter")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + if self.options.get_safe("with_xsimd"): + self.cpp_info.defines = ["MATHTER_USE_XSIMD=1"] diff --git a/recipes/mathter/1.x.x/test_package/CMakeLists.txt b/recipes/mathter/1.x.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e6eb2612386c1 --- /dev/null +++ b/recipes/mathter/1.x.x/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(TestPackage CXX) + +find_package(mathter REQUIRED CONFIG) + +add_executable(test_package test_package.cpp) +target_link_libraries(test_package PRIVATE mathter::mathter) +target_compile_features(test_package PRIVATE cxx_std_17) diff --git a/recipes/mathter/1.x.x/test_package/conanfile.py b/recipes/mathter/1.x.x/test_package/conanfile.py new file mode 100644 index 0000000000000..fae501d0afb9e --- /dev/null +++ b/recipes/mathter/1.x.x/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mathter/1.x.x/test_package/test_package.cpp b/recipes/mathter/1.x.x/test_package/test_package.cpp new file mode 100644 index 0000000000000..c46788d9d6a1c --- /dev/null +++ b/recipes/mathter/1.x.x/test_package/test_package.cpp @@ -0,0 +1,16 @@ +#include +#include + +int main() { + using Vec3 = mathter::Vector; + Vec3 v1 = {1, 0, 3}; + Vec3 v2 = {2, 5, 3}; + auto r = v1 + v2; + std::cout << "Mathter installation works." << std::endl; +#ifdef MATHTER_USE_XSIMD + std::cout << "XSimd enabled." << std::endl; +#else + std::cout << "XSimd disabled." << std::endl; +#endif + return 0; +} diff --git a/recipes/mathter/all/test_v1_package/CMakeLists.txt b/recipes/mathter/1.x.x/test_v1_package/CMakeLists.txt similarity index 100% rename from recipes/mathter/all/test_v1_package/CMakeLists.txt rename to recipes/mathter/1.x.x/test_v1_package/CMakeLists.txt diff --git a/recipes/mathter/all/test_v1_package/conanfile.py b/recipes/mathter/1.x.x/test_v1_package/conanfile.py similarity index 100% rename from recipes/mathter/all/test_v1_package/conanfile.py rename to recipes/mathter/1.x.x/test_v1_package/conanfile.py diff --git a/recipes/mathter/all/conandata.yml b/recipes/mathter/all/conandata.yml index f12b02f2c9224..72315af7bccd3 100644 --- a/recipes/mathter/all/conandata.yml +++ b/recipes/mathter/all/conandata.yml @@ -1,13 +1,4 @@ sources: - "1.1.1": - url: "https://github.com/petiaccja/Mathter/archive/v1.1.1.tar.gz" - sha256: "510e6aa198cd7b207a44d319e4471021f207cba8c4d2d7e40086f1f042fe13ab" - "1.1.0": - url: "https://github.com/petiaccja/Mathter/archive/v1.1.0.tar.gz" - sha256: "a9a82126ecd80112854098a5646d38f72f0af03e9655b28ab8fa38b4c03b0870" - "1.0.1": - url: "https://github.com/petiaccja/Mathter/archive/v1.0.1.tar.gz" - sha256: "ab90736abfa8774103b53fe2b8962981c5f117dc582b01698c18d66cd2398b8c" - "1.0.0": - url: "https://github.com/petiaccja/Mathter/archive/v1.0.0.tar.gz" - sha256: "c75cca8d8aec627935250908f2c0f9f1839561e7596a4199bcf80e12b0e6c53b" + "2.0.0": + url: "https://github.com/petiaccja/Mathter/archive/v2.0.0.tar.gz" + sha256: "cec8472d3a56613d4815d1a14e5bf42976884177cc5283c5ad5aba0710cc4bab" \ No newline at end of file diff --git a/recipes/mathter/all/conanfile.py b/recipes/mathter/all/conanfile.py index 82cdb44fbd38a..ea4242223e7b2 100644 --- a/recipes/mathter/all/conanfile.py +++ b/recipes/mathter/all/conanfile.py @@ -3,11 +3,12 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv from conan.tools.files import copy, get -from conan.tools.layout import basic_layout from conan.tools.scm import Version -required_conan_version = ">=1.52.0" +required_conan_version = ">=2.0.0" class MathterConan(ConanFile): @@ -40,13 +41,9 @@ def _compilers_minimum_version(self): "gcc": 7, "Visual Studio": 16, } - - def config_options(self): - if Version(self.version) < "1.1": - del self.options.with_xsimd def layout(self): - basic_layout(self, src_folder="src") + cmake_layout(self, src_folder="src") def package_id(self): self.info.clear() @@ -60,25 +57,40 @@ def validate(self): raise ConanInvalidConfiguration(f"{self.name} requires C++{self._min_cppstd}, " "which your compiler does not support.") + def requirements(self): + if self.options.get_safe("with_xsimd"): + self.requires("xsimd/13.0.0") + + def build_requirements(self): + self.tool_requires("cmake/[>=3.25 <4]") + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) - def requirements(self): - if self.options.get_safe("with_xsimd"): - self.requires("xsimd/11.1.0") + def generate(self): + tc = CMakeToolchain(self) + tc.variables["MATHTER_BUILD_TESTS"] = "OFF" + tc.variables["MATHTER_BUILD_BENCHMARKS"] = "OFF" + tc.variables["MATHTER_BUILD_EXAMPLES"] = "OFF" + tc.variables["MATHTER_ENABLE_SIMD"] = "ON" if self.options.get_safe("with_xsimd") else "OFF" + tc.generate() + cmake_deps = CMakeDeps(self) + cmake_deps.generate() + venv = VirtualBuildEnv(self) + venv.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() def package(self): - if self.version == "1.0.0": - copy(self, "LICENCE", self.source_folder, os.path.join(self.package_folder, "licenses")) - include_dir = os.path.join(self.source_folder, "Mathter") - else: - copy(self, "LICENCE.md", self.source_folder, os.path.join(self.package_folder, "licenses")) - include_dir = os.path.join(self.source_folder, "include", "Mathter") - copy(self, "*.hpp", include_dir, os.path.join(self.package_folder, "include", "Mathter")) - copy(self, "*.natvis", include_dir, os.path.join(self.package_folder, "include", "Mathter")) + copy(self, "LICENSE.md", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() def package_info(self): self.cpp_info.bindirs = [] self.cpp_info.libdirs = [] if self.options.get_safe("with_xsimd"): - self.cpp_info.defines = ["MATHTER_USE_XSIMD=1"] + self.cpp_info.defines = ["MATHTER_ENABLE_SIMD=1"] diff --git a/recipes/mathter/all/test_package/test_package.cpp b/recipes/mathter/all/test_package/test_package.cpp index c46788d9d6a1c..d451c56acac71 100644 --- a/recipes/mathter/all/test_package/test_package.cpp +++ b/recipes/mathter/all/test_package/test_package.cpp @@ -1,16 +1,32 @@ +#include +#include +#include +#include +#include +#include #include + #include +using namespace mathter; + + int main() { - using Vec3 = mathter::Vector; - Vec3 v1 = {1, 0, 3}; - Vec3 v2 = {2, 5, 3}; - auto r = v1 + v2; - std::cout << "Mathter installation works." << std::endl; -#ifdef MATHTER_USE_XSIMD - std::cout << "XSimd enabled." << std::endl; + const auto u = Vector(1, 2, 3); + const auto v = Vector(4, 6, 8); + const auto r = u + v; + if (r[0] != 5) { + std::cout << "Mathter installation failing." << std::endl; + return 1; + } + else { + std::cout << "Mathter installation works." << std::endl; + std::cout << "Options:" << std::endl; +#ifdef MATHTER_ENABLE_SIMD + std::cout << " with_xsimd = True" << std::endl; #else - std::cout << "XSimd disabled." << std::endl; + std::cout << " with_xsimd = False" << std::endl; #endif - return 0; + return 0; + } } diff --git a/recipes/mathter/config.yml b/recipes/mathter/config.yml index e685e077396ef..64c627fda4753 100644 --- a/recipes/mathter/config.yml +++ b/recipes/mathter/config.yml @@ -1,9 +1,11 @@ versions: - "1.1.1": + "2.0.0": folder: all + "1.1.1": + folder: 1.x.x "1.1.0": - folder: all + folder: 1.x.x "1.0.1": - folder: all + folder: 1.x.x "1.0.0": - folder: all + folder: 1.x.x From 4a2b8fb951b1a1f0f37bf4ba3f2e528966b66e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kardos?= Date: Wed, 18 Sep 2024 16:43:12 +0200 Subject: [PATCH 2/4] include conan 1.x --- recipes/mathter/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/mathter/all/conanfile.py b/recipes/mathter/all/conanfile.py index ea4242223e7b2..dba701fec10fc 100644 --- a/recipes/mathter/all/conanfile.py +++ b/recipes/mathter/all/conanfile.py @@ -8,7 +8,7 @@ from conan.tools.files import copy, get from conan.tools.scm import Version -required_conan_version = ">=2.0.0" +required_conan_version = ">=1.52.0" class MathterConan(ConanFile): From a6b62c7904f3b040c57bd868710ade1a7f9159a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kardos?= Date: Wed, 18 Sep 2024 17:15:39 +0200 Subject: [PATCH 3/4] fix license and cmake config --- recipes/mathter/all/conanfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/mathter/all/conanfile.py b/recipes/mathter/all/conanfile.py index dba701fec10fc..80da2d1eaa7fe 100644 --- a/recipes/mathter/all/conanfile.py +++ b/recipes/mathter/all/conanfile.py @@ -5,7 +5,7 @@ from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.env import VirtualBuildEnv -from conan.tools.files import copy, get +from conan.tools.files import copy, get, rmdir from conan.tools.scm import Version required_conan_version = ">=1.52.0" @@ -85,9 +85,10 @@ def build(self): cmake.build() def package(self): - copy(self, "LICENSE.md", self.source_folder, os.path.join(self.package_folder, "licenses")) cmake = CMake(self) cmake.install() + copy(self, "LICENCE.md", self.source_folder, os.path.join(self.package_folder, "licenses")) + rmdir(self, os.path.join(self.package_folder, "lib")) def package_info(self): self.cpp_info.bindirs = [] From d12c2b2065fab705152f61e4689906683317fe38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kardos?= Date: Thu, 19 Sep 2024 11:45:10 +0200 Subject: [PATCH 4/4] require gcc 9 as older ones don't have c++17 std::reduce --- recipes/mathter/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/mathter/all/conanfile.py b/recipes/mathter/all/conanfile.py index 80da2d1eaa7fe..ec3643caaab0d 100644 --- a/recipes/mathter/all/conanfile.py +++ b/recipes/mathter/all/conanfile.py @@ -38,7 +38,7 @@ def _compilers_minimum_version(self): return { "apple-clang": 10, "clang": 6, - "gcc": 7, + "gcc": 9, "Visual Studio": 16, }