Skip to content

Commit

Permalink
add liblqr/0.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceIm committed Sep 6, 2024
1 parent 9c735da commit c160bac
Show file tree
Hide file tree
Showing 7 changed files with 222 additions and 0 deletions.
44 changes: 44 additions & 0 deletions recipes/liblqr/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}
)
4 changes: 4 additions & 0 deletions recipes/liblqr/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -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"
123 changes: 123 additions & 0 deletions recipes/liblqr/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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")
7 changes: 7 additions & 0 deletions recipes/liblqr/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
26 changes: 26 additions & 0 deletions recipes/liblqr/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, 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")
15 changes: 15 additions & 0 deletions recipes/liblqr/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <lqr.h>

#include <stdlib.h>

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

0 comments on commit c160bac

Please sign in to comment.