Skip to content

Commit

Permalink
(#23113) lielab: new package and v0.1.1
Browse files Browse the repository at this point in the history
* Adding Lielab v0.1.1

* Update recipes/lielab/all/conanfile.py

Co-authored-by: Martin Valgur <[email protected]>

* Update recipes/lielab/all/conanfile.py

Co-authored-by: Martin Valgur <[email protected]>

* Update recipes/lielab/all/conanfile.py

Co-authored-by: Uilian Ries <[email protected]>

* Update conanfile.py

* Adding test_package

* Changed lielab 0.1.1 to 0.4.0

- Hopefully clean up the relative file import path errors.

* Forgot to change config.yml to v0.4.0

* Updated hash for Lielab v0.4.0

* Endlines to pass linter

* test package requires C++20

---------

Co-authored-by: Martin Valgur <[email protected]>
Co-authored-by: Uilian Ries <[email protected]>
  • Loading branch information
3 people authored Jun 21, 2024
1 parent 4085239 commit 05de5ac
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/lielab/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.4.0":
url: "https://github.com/sandialabs/Lielab/archive/refs/tags/v0.4.0.tar.gz"
sha256: "5CABF2D31D7D38EEEF525ADEE5D22C0359E9C043884D4AB5FBA219D3CB217A5C"
83 changes: 83 additions & 0 deletions recipes/lielab/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake
from conan.tools.files import copy, get, rmdir
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.52.0"

class LielabConan(ConanFile):
name = "lielab"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/sandialabs/Lielab"
description = "Lielab is a C++ library for numerical Lie-theory: Lie groups," \
" Lie algebras, homogeneous manifolds, and various functions and algorithms" \
" on these spaces."
topics = ("Lie-theory", "Lie-group", "Lie-algebra", "numerical", "header-only")
package_type = "header-library"
license = "MIT"

settings = "os", "arch", "compiler", "build_type"

no_copy_source = True

def requirements(self):
self.requires("eigen/3.4.0")

@property
def _min_cppstd(self):
return 20

@property
def _compilers_minimum_version(self):
return {
"gcc": "11",
"clang": "12",
"apple-clang": "13.1",
"Visual Studio": "17",
"msvc": "193",
}

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.ref} requires C++{self._min_cppstd}, which your compiler does not support.")

def build_requirements(self):
self.tool_requires("cmake/[>=3.23 <4]")

def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["LIELAB_INSTALL_LIBRARY"] = True
tc.variables["LIELAB_BUILD_TESTS"] = False
tc.variables["LIELAB_BUILD_PYTHON"] = False
tc.generate()

def package(self):
copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.configure()
cmake.install()
rmdir(self, os.path.join(self.package_folder, "share"))

def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []

self.cpp_info.set_property("cmake_file_name", "Lielab")
self.cpp_info.set_property("cmake_target_name", "Lielab::Lielab")

self.cpp_info.names["cmake_find_package"] = "Lielab"
self.cpp_info.names["cmake_find_package_multi"] = "Lielab"

def package_id(self):
self.info.clear()

8 changes: 8 additions & 0 deletions recipes/lielab/all/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(test_package LANGUAGES CXX)

find_package(Lielab REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE Lielab::Lielab)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
26 changes: 26 additions & 0 deletions recipes/lielab/all/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", "VirtualRunEnv"
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()
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")
12 changes: 12 additions & 0 deletions recipes/lielab/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <cstdlib>
#include <iostream>
#include <Lielab.hpp>


int main(void) {
std::cout << "Lielab v" << Lielab::VERSION << std::endl;
std::cout << Lielab::AUTHOR << std::endl;
std::cout << Lielab::LOCATION << std::endl;

return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/lielab/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.4.0":
folder: "all"

0 comments on commit 05de5ac

Please sign in to comment.