diff --git a/recipes/plutovg/all/CMakeLists.txt b/recipes/plutovg/all/CMakeLists.txt new file mode 100644 index 0000000000000..5c311fb812b13 --- /dev/null +++ b/recipes/plutovg/all/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.4) +project(cmake_wrapper LANGUAGES C) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory(source_subfolder) diff --git a/recipes/plutovg/all/conandata.yml b/recipes/plutovg/all/conandata.yml new file mode 100644 index 0000000000000..a27d529c6106c --- /dev/null +++ b/recipes/plutovg/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20220103": + url: "https://github.com/sammycage/plutovg/archive/51f1a79e04fbb42ec9e93499a18869eea06f3054.tar.gz" + sha256: "c2ce39b8085e0a8795263666f62af15239c36964330865fd54b9db25c67e063b" diff --git a/recipes/plutovg/all/conanfile.py b/recipes/plutovg/all/conanfile.py new file mode 100644 index 0000000000000..31d141acec985 --- /dev/null +++ b/recipes/plutovg/all/conanfile.py @@ -0,0 +1,74 @@ +from conans import ConanFile, CMake, tools +import os + +required_conan_version = ">=1.43.0" + +class PlutoVGConan(ConanFile): + name = "plutovg" + description = "Tiny 2D vector graphics library in C" + topics = ("vector", "graphics", ) + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/sammycage/plutovg" + license = "MIT", + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + exports_sources = ["CMakeLists.txt"] + generators = "cmake" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.configure() + return self._cmake + + def build(self): + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + "add_library(plutovg STATIC)", "add_library(plutovg)") + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + "add_subdirectory(example)", "") + + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + self.copy(pattern="*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) + self.copy(pattern="*.a", dst="lib", src="lib", keep_path=False) + self.copy(pattern="*.so", dst="lib", src="lib", keep_path=False) + self.copy(pattern="*.lib", dst="lib", src="lib", keep_path=False) + self.copy(pattern="*.dll", dst="bin", src="bin", keep_path=False) + self.copy(pattern="*.dylib", dst="lib", src="lib", keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["plutovg"] + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.system_libs = ["m"] diff --git a/recipes/plutovg/all/test_package/CMakeLists.txt b/recipes/plutovg/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..98f8122ae693b --- /dev/null +++ b/recipes/plutovg/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(plutovg REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} plutovg::plutovg) diff --git a/recipes/plutovg/all/test_package/conanfile.py b/recipes/plutovg/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a500b98343c74 --- /dev/null +++ b/recipes/plutovg/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/plutovg/all/test_package/test_package.c b/recipes/plutovg/all/test_package/test_package.c new file mode 100644 index 0000000000000..528e8031367ec --- /dev/null +++ b/recipes/plutovg/all/test_package/test_package.c @@ -0,0 +1,14 @@ +#include "plutovg.h" + +int main(void) { + const int width = 150; + const int height = 150; + + plutovg_surface_t* surface = plutovg_surface_create(width, height); + plutovg_t* pluto = plutovg_create(surface); + + plutovg_surface_destroy(surface); + plutovg_destroy(pluto); + + return 0; +} diff --git a/recipes/plutovg/config.yml b/recipes/plutovg/config.yml new file mode 100644 index 0000000000000..d334d7a80bf72 --- /dev/null +++ b/recipes/plutovg/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20220103": + folder: all