From 65d1d01ce4a0052ec5b4c416cf1833c5f91ca900 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 6 May 2024 18:14:10 +0300 Subject: [PATCH] tinycolormap: new recipe --- recipes/tinycolormap/all/conandata.yml | 4 ++ recipes/tinycolormap/all/conanfile.py | 64 +++++++++++++++++++ .../all/test_package/CMakeLists.txt | 8 +++ .../all/test_package/conanfile.py | 27 ++++++++ .../all/test_package/test_package.cpp | 10 +++ recipes/tinycolormap/config.yml | 3 + 6 files changed, 116 insertions(+) create mode 100644 recipes/tinycolormap/all/conandata.yml create mode 100644 recipes/tinycolormap/all/conanfile.py create mode 100644 recipes/tinycolormap/all/test_package/CMakeLists.txt create mode 100644 recipes/tinycolormap/all/test_package/conanfile.py create mode 100644 recipes/tinycolormap/all/test_package/test_package.cpp create mode 100644 recipes/tinycolormap/config.yml diff --git a/recipes/tinycolormap/all/conandata.yml b/recipes/tinycolormap/all/conandata.yml new file mode 100644 index 0000000000000..771edaa798dc0 --- /dev/null +++ b/recipes/tinycolormap/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20230223": + url: "https://github.com/yuki-koyama/tinycolormap/archive/0f62abbc269d9677829083d4d563643830ac7fb9.zip" + sha256: "f736d7b76ea07e43da6c6905d891bc58ef512a794bbc0ef3ba9b593b4c1e2d63" diff --git a/recipes/tinycolormap/all/conanfile.py b/recipes/tinycolormap/all/conanfile.py new file mode 100644 index 0000000000000..be4fc0dfc05d4 --- /dev/null +++ b/recipes/tinycolormap/all/conanfile.py @@ -0,0 +1,64 @@ +import os + +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout + +required_conan_version = ">=1.52.0" + + +class TinycolormapConan(ConanFile): + name = "tinycolormap" + description = "A header-only, single-file library for colormaps written in C++11" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/yuki-koyama/tinycolormap" + topics = ("color", "colormap", "visualization", "header-only") + package_type = "header-library" + + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + options = { + "with_eigen": [True, False], + "with_qt": [True, False], + } + default_options = { + "with_eigen": False, + "with_qt": False, + } + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def requirements(self): + if self.options.with_eigen: + self.requires("eigen/3.4.0") + if self.options.with_qt: + # Only Qt5 is supported + self.requires("qt/5.15.13") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def package(self): + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + copy(self, "*.hpp", os.path.join(self.source_folder, "include"), os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + + if self.options.with_eigen: + self.cpp_info.defines.append("TINYCOLORMAP_WITH_EIGEN") + self.cpp_info.requires.append("eigen::eigen") + if self.options.with_qt: + self.cpp_info.defines.append("TINYCOLORMAP_WITH_QT5") + self.cpp_info.requires.append("qt::qtGui") diff --git a/recipes/tinycolormap/all/test_package/CMakeLists.txt b/recipes/tinycolormap/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..cafa69c0c2ce2 --- /dev/null +++ b/recipes/tinycolormap/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(tinycolormap REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE tinycolormap::tinycolormap) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/tinycolormap/all/test_package/conanfile.py b/recipes/tinycolormap/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a808db45f245 --- /dev/null +++ b/recipes/tinycolormap/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +# It will become the standard on Conan 2.x +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") diff --git a/recipes/tinycolormap/all/test_package/test_package.cpp b/recipes/tinycolormap/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..fdc0a6b320ab7 --- /dev/null +++ b/recipes/tinycolormap/all/test_package/test_package.cpp @@ -0,0 +1,10 @@ +#include + +#include + +int main() { + double value = 0.75; + auto color = tinycolormap::GetColor(value, tinycolormap::ColormapType::Viridis); + std::cout << "Viridis RGB values at " << value << ": " + << (int)color.ri() << " " << (int)color.gi() << " " << (int)color.bi() << std::endl; +} diff --git a/recipes/tinycolormap/config.yml b/recipes/tinycolormap/config.yml new file mode 100644 index 0000000000000..5ebaf8fdf738e --- /dev/null +++ b/recipes/tinycolormap/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20230223": + folder: all