Skip to content

Commit

Permalink
(#25307) mathter: add new version 2.0.0
Browse files Browse the repository at this point in the history
* added new version mathter/2.0.0

* include conan 1.x

* fix license and cmake config

* require gcc 9 as older ones don't have c++17 std::reduce
  • Loading branch information
petiaccja authored Oct 1, 2024
1 parent 19be0c9 commit c1a43e1
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 45 deletions.
13 changes: 13 additions & 0 deletions recipes/mathter/1.x.x/conandata.yml
Original file line number Diff line number Diff line change
@@ -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"
84 changes: 84 additions & 0 deletions recipes/mathter/1.x.x/conanfile.py
Original file line number Diff line number Diff line change
@@ -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"]
8 changes: 8 additions & 0 deletions recipes/mathter/1.x.x/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
26 changes: 26 additions & 0 deletions recipes/mathter/1.x.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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")
16 changes: 16 additions & 0 deletions recipes/mathter/1.x.x/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <Mathter/Vector.hpp>
#include <iostream>

int main() {
using Vec3 = mathter::Vector<float, 3>;
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;
}
15 changes: 3 additions & 12 deletions recipes/mathter/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -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"
53 changes: 33 additions & 20 deletions recipes/mathter/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
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.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import copy, get, rmdir
from conan.tools.scm import Version

required_conan_version = ">=1.52.0"
Expand Down Expand Up @@ -37,16 +38,12 @@ def _compilers_minimum_version(self):
return {
"apple-clang": 10,
"clang": 6,
"gcc": 7,
"gcc": 9,
"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()
Expand All @@ -60,25 +57,41 @@ 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"))
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 = []
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"]
34 changes: 25 additions & 9 deletions recipes/mathter/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
#include <Mathter/Geometry.hpp>
#include <Mathter/IoStream.hpp>
#include <Mathter/Matrix.hpp>
#include <Mathter/Quaternion.hpp>
#include <Mathter/Transforms.hpp>
#include <Mathter/Utility.hpp>
#include <Mathter/Vector.hpp>

#include <iostream>

using namespace mathter;


int main() {
using Vec3 = mathter::Vector<float, 3>;
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;
}
}
10 changes: 6 additions & 4 deletions recipes/mathter/config.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c1a43e1

Please sign in to comment.