From c160bac06bad87217a331626ea0968bfa6b19fb3 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 6 Sep 2024 18:07:17 +0200 Subject: [PATCH] add liblqr/0.4.3 --- recipes/liblqr/all/CMakeLists.txt | 44 +++++++ recipes/liblqr/all/conandata.yml | 4 + recipes/liblqr/all/conanfile.py | 123 ++++++++++++++++++ .../liblqr/all/test_package/CMakeLists.txt | 7 + recipes/liblqr/all/test_package/conanfile.py | 26 ++++ .../liblqr/all/test_package/test_package.c | 15 +++ recipes/liblqr/config.yml | 3 + 7 files changed, 222 insertions(+) create mode 100644 recipes/liblqr/all/CMakeLists.txt create mode 100644 recipes/liblqr/all/conandata.yml create mode 100644 recipes/liblqr/all/conanfile.py create mode 100644 recipes/liblqr/all/test_package/CMakeLists.txt create mode 100644 recipes/liblqr/all/test_package/conanfile.py create mode 100644 recipes/liblqr/all/test_package/test_package.c create mode 100644 recipes/liblqr/config.yml diff --git a/recipes/liblqr/all/CMakeLists.txt b/recipes/liblqr/all/CMakeLists.txt new file mode 100644 index 00000000000000..303355e779e6b2 --- /dev/null +++ b/recipes/liblqr/all/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.15) +project(liblqr LANGUAGES C) + +find_package(glib REQUIRED CONFIG) + +set(LQR_SRC_SUBDIR ${LQR_SRC_DIR}/lqr) + +file(GLOB LQR_SRCS_FILES ${LQR_SRC_SUBDIR}/*.c) + +add_library(lqr-1 ${LQR_SRCS_FILES}) +target_include_directories(lqr-1 PUBLIC ${LQR_SRC_DIR} ${LQR_SRC_SUBDIR}) +target_link_libraries(lqr-1 PUBLIC glib::glib-2.0) +if(WIN32) + if(BUILD_SHARED_LIBS) + target_compile_definitions(lqr-1 PRIVATE LQR_EXPORTS) + else() + target_compile_definitions(lqr-1 PUBLIC LQR_DISABLE_DECLSPEC) + endif() +endif() + +install(FILES ${LQR_SRC_SUBDIR}/lqr.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lqr-1) +install( + FILES + ${LQR_SRC_SUBDIR}/lqr_base.h + ${LQR_SRC_SUBDIR}/lqr_carver_bias_pub.h + ${LQR_SRC_SUBDIR}/lqr_carver_list_pub.h + ${LQR_SRC_SUBDIR}/lqr_carver_pub.h + ${LQR_SRC_SUBDIR}/lqr_carver_rigmask_pub.h + ${LQR_SRC_SUBDIR}/lqr_cursor_pub.h + ${LQR_SRC_SUBDIR}/lqr_energy_pub.h + ${LQR_SRC_SUBDIR}/lqr_gradient_pub.h + ${LQR_SRC_SUBDIR}/lqr_progress_pub.h + ${LQR_SRC_SUBDIR}/lqr_rwindow_pub.h + ${LQR_SRC_SUBDIR}/lqr_vmap_list_pub.h + ${LQR_SRC_SUBDIR}/lqr_vmap_pub.h + DESTINATION + ${CMAKE_INSTALL_INCLUDEDIR}/lqr-1/lqr +) +install( + TARGETS lqr-1 + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/recipes/liblqr/all/conandata.yml b/recipes/liblqr/all/conandata.yml new file mode 100644 index 00000000000000..d562db29a3a363 --- /dev/null +++ b/recipes/liblqr/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.4.3": + url: "http://liblqr.wdfiles.com/local--files/en:download-page/liblqr-1-0.4.3.tar.bz2" + sha256: "862fc5cecaa96d38d4d9279c8a6fbfc276393f0548909ee0912e41df59894471" diff --git a/recipes/liblqr/all/conanfile.py b/recipes/liblqr/all/conanfile.py new file mode 100644 index 00000000000000..bd859b29a63977 --- /dev/null +++ b/recipes/liblqr/all/conanfile.py @@ -0,0 +1,123 @@ +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.54.0" + + +class LibLqrConan(ConanFile): + name = "liblqr" + description = ( + "The LiquidRescale (lqr) library provides a C/C++ API for performing " + "non-uniform resizing of images by the seam-carving technique." + ) + license = ("LGPL-3.0", "GPL-3.0") + url = "https://github.com/conan-io/conan-center-index" + homepage = "http://liblqr.wikidot.com" + topics = ("image", "resizing", "seam-carving") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _is_cl_like(self): + return self.settings.compiler.get_safe("runtime") is not None + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + if self._is_cl_like: + cmake_layout(self, src_folder="src") + else: + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("glib/2.81.0", transitive_headers=True) + + def build_requirements(self): + if not self._is_cl_like: + if not self.conf.get("tools.gnu:pkg_config", check_type=str): + self.tool_requires("pkgconf/[>=2.2 <3]") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + if self._is_cl_like: + tc = CMakeToolchain(self) + tc.variables["LQR_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + deps = CMakeDeps(self) + deps.generate() + else: + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + tc.configure_args.append("--disable-install-man") + if self.settings.os == "Windows" and not self.options.shared: + tc.configure_args.append("--disable-declspec") + tc.generate() + + deps = PkgConfigDeps(self) + deps.generate() + + def build(self): + if self._is_cl_like: + cmake = CMake(self) + cmake.configure() + cmake.build() + else: + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + if self._is_cl_like: + cmake = CMake(self) + cmake.install() + else: + autotools = Autotools(self) + autotools.install() + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + fix_apple_shared_install_name(self) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "lqr-1") + self.cpp_info.includedirs = [os.path.join("include", "lqr-1")] + self.cpp_info.libs = ["lqr-1"] + if self.settings.os == "Windows" and not self.options.shared: + self.cpp_info.defines.append("LQR_DISABLE_DECLSPEC") diff --git a/recipes/liblqr/all/test_package/CMakeLists.txt b/recipes/liblqr/all/test_package/CMakeLists.txt new file mode 100644 index 00000000000000..fe1dadeb5b33a2 --- /dev/null +++ b/recipes/liblqr/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES C) + +find_package(liblqr REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE liblqr::liblqr) diff --git a/recipes/liblqr/all/test_package/conanfile.py b/recipes/liblqr/all/test_package/conanfile.py new file mode 100644 index 00000000000000..0a6bc68712d901 --- /dev/null +++ b/recipes/liblqr/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "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.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/liblqr/all/test_package/test_package.c b/recipes/liblqr/all/test_package/test_package.c new file mode 100644 index 00000000000000..890b1df50ef9cc --- /dev/null +++ b/recipes/liblqr/all/test_package/test_package.c @@ -0,0 +1,15 @@ +#include + +#include + +int main() { + gint channels = 3; + gint w = 100; + gint h = 100; + guchar *rgb_buffer = (guchar *) malloc(channels * w * h * sizeof(guchar)); + + LqrCarver *r = lqr_carver_new(rgb_buffer, w, h, channels); + lqr_carver_destroy(r); + + return 0; +} diff --git a/recipes/liblqr/config.yml b/recipes/liblqr/config.yml new file mode 100644 index 00000000000000..9be35d17501c4b --- /dev/null +++ b/recipes/liblqr/config.yml @@ -0,0 +1,3 @@ +versions: + "0.4.3": + folder: all