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

tinycolormap: new recipe #23887

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/tinycolormap/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"cci.20230223":
url: "https://github.com/yuki-koyama/tinycolormap/archive/0f62abbc269d9677829083d4d563643830ac7fb9.zip"
sha256: "f736d7b76ea07e43da6c6905d891bc58ef512a794bbc0ef3ba9b593b4c1e2d63"
64 changes: 64 additions & 0 deletions recipes/tinycolormap/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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")
8 changes: 8 additions & 0 deletions recipes/tinycolormap/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(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)
27 changes: 27 additions & 0 deletions recipes/tinycolormap/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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")
10 changes: 10 additions & 0 deletions recipes/tinycolormap/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <tinycolormap.hpp>

#include <iostream>

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;
}
3 changes: 3 additions & 0 deletions recipes/tinycolormap/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"cci.20230223":
folder: all
Loading