Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lielab: new package and v0.1.1 #23113

Merged
merged 11 commits into from
Jun 21, 2024
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")

msparapa marked this conversation as resolved.
Show resolved Hide resolved
msparapa marked this conversation as resolved.
Show resolved Hide resolved
@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"
Loading