[DO-971] ffmpeg recipe with requirements (!9)

Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/9
This commit is contained in:
Aleksandr Vodyanov
2024-12-25 17:47:28 +03:00
parent e58f90de0e
commit 39afe6a1dd
212 changed files with 9263 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
sources:
"1.4.0":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-storage_googleapis_com/downloads.webmproject.org/releases/webp/libwebp-1.4.0.tar.gz"
sha256: "61f873ec69e3be1b99535634340d5bde750b2e4447caa1db9f61be3fd49ab1e5"
"1.3.2":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-storage_googleapis_com/downloads.webmproject.org/releases/webp/libwebp-1.3.2.tar.gz"
sha256: "2a499607df669e40258e53d0ade8035ba4ec0175244869d1025d460562aa09b4"
"1.3.1":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-storage_googleapis_com/downloads.webmproject.org/releases/webp/libwebp-1.3.1.tar.gz"
sha256: "b3779627c2dfd31e3d8c4485962c2efe17785ef975e2be5c8c0c9e6cd3c4ef66"
"1.2.4":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-storage_googleapis_com/downloads.webmproject.org/releases/webp/libwebp-1.2.4.tar.gz"
sha256: "7bf5a8a28cc69bcfa8cb214f2c3095703c6b73ac5fba4d5480c205331d9494df"
"1.1.0":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-storage_googleapis_com/downloads.webmproject.org/releases/webp/libwebp-1.1.0.tar.gz"
sha256: "98a052268cc4d5ece27f76572a7f50293f439c17a98e67c4ea0c7ed6f50ef043"
patches:
"1.4.0":
- patch_file: "patches/1.4.0-0001-fix-cmake.patch"
patch_description: "disable PIC, disable prefix library name on MSVC"
patch_type: "conan"
"1.3.2":
- patch_file: "patches/1.3.1-0001-fix-cmake.patch"
patch_description: "disable PIC, disable prefix library name on MSVC"
patch_type: "conan"
"1.3.1":
- patch_file: "patches/1.3.1-0001-fix-cmake.patch"
patch_description: "disable PIC, disable prefix library name on MSVC"
patch_type: "conan"
"1.2.4":
- patch_file: "patches/1.1.0-0001-fix-dll-export.patch"
patch_description: "define WEBP_EXTERN for windows shared build"
patch_type: "portability"
"1.1.0":
- patch_file: "patches/1.1.0-0001-fix-dll-export.patch"
patch_description: "define WEBP_EXTERN for windows shared build"
patch_type: "portability"
- patch_file: "patches/1.1.0-0002-qnx.patch"
patch_description: "work around cmake bug on QNX"
patch_type: "conan"
patch_source: "https://chromium-review.googlesource.com/c/webm/libwebp/+/2637274"
- patch_file: "patches/1.1.0-0003-build-libwebpmux.patch"
patch_description: "always build libwebpmux"
patch_type: "conan"

View File

@@ -0,0 +1,141 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
from conan.tools.microsoft import is_msvc
from conan.tools.scm import Version
import os
required_conan_version = ">=1.53.0"
class LibwebpConan(ConanFile):
name = "libwebp"
description = "Library to encode and decode images in WebP format"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://chromium.googlesource.com/webm/libwebp"
topics = ("image", "libwebp", "webp", "decoding", "encoding")
license = "BSD-3-Clause"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_simd": [True, False],
"near_lossless": [True, False],
"swap_16bit_csp": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_simd": True,
"near_lossless": True,
"swap_16bit_csp": False,
}
def export_sources(self):
export_conandata_patches(self)
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):
cmake_layout(self, src_folder="src")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
tc = CMakeToolchain(self)
# should be an option but it doesn't work yet
tc.variables["WEBP_ENABLE_SIMD"] = self.options.with_simd
tc.variables["WEBP_NEAR_LOSSLESS"] = self.options.near_lossless
tc.variables["WEBP_ENABLE_SWAP_16BIT_CSP"] = self.options.swap_16bit_csp
# avoid finding system libs
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_GIF"] = True
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_PNG"] = True
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_TIFF"] = True
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_JPEG"] = True
tc.variables["WEBP_BUILD_ANIM_UTILS"] = False
tc.variables["WEBP_BUILD_CWEBP"] = False
tc.variables["WEBP_BUILD_DWEBP"] = False
tc.variables["WEBP_BUILD_IMG2WEBP"] = False
tc.variables["WEBP_BUILD_GIF2WEBP"] = False
tc.variables["WEBP_BUILD_VWEBP"] = False
tc.variables["WEBP_BUILD_EXTRAS"] = False
tc.variables["WEBP_BUILD_WEBPINFO"] = False
if Version(self.version) >= "1.2.1":
tc.variables["WEBP_BUILD_LIBWEBPMUX"] = True
tc.variables["WEBP_BUILD_WEBPMUX"] = False
if self.options.shared and is_msvc(self):
# Building a dll (see fix-dll-export patch)
tc.preprocessor_definitions["WEBP_DLL"] = 1
tc.generate()
def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "WebP")
self.cpp_info.set_property("pkg_config_name", "libwebp-all-do-not-use")
# webpdecoder
self.cpp_info.components["webpdecoder"].set_property("cmake_target_name", "WebP::webpdecoder")
self.cpp_info.components["webpdecoder"].set_property("pkg_config_name", "libwebpdecoder")
self.cpp_info.components["webpdecoder"].libs = ["webpdecoder"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["webpdecoder"].system_libs = ["m", "pthread"]
# webp
self.cpp_info.components["webp"].set_property("cmake_target_name", "WebP::webp")
self.cpp_info.components["webp"].set_property("pkg_config_name", "libwebp")
self.cpp_info.components["webp"].libs = ["webp"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["webp"].system_libs = ["m", "pthread"]
if Version(self.version) >= "1.3.0":
# sharpyuv
self.cpp_info.components["sharpyuv"].set_property("cmake_target_name", "WebP::sharpyuv")
self.cpp_info.components["sharpyuv"].set_property("pkg_config_name", "libsharpyuv")
self.cpp_info.components["sharpyuv"].libs = ["sharpyuv"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["sharpyuv"].system_libs = ["m", "pthread"]
# note: webp now depends on sharpyuv
self.cpp_info.components["webp"].requires = ["sharpyuv"]
# webpdemux
self.cpp_info.components["webpdemux"].set_property("cmake_target_name", "WebP::webpdemux")
self.cpp_info.components["webpdemux"].set_property("pkg_config_name", "libwebpdemux")
self.cpp_info.components["webpdemux"].libs = ["webpdemux"]
self.cpp_info.components["webpdemux"].requires = ["webp"]
# webpmux
self.cpp_info.components["webpmux"].set_property("cmake_target_name", "WebP::libwebpmux")
self.cpp_info.components["webpmux"].set_property("pkg_config_name", "libwebpmux")
self.cpp_info.components["webpmux"].libs = ["webpmux"]
self.cpp_info.components["webpmux"].requires = ["webp"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["webpmux"].system_libs = ["m"]
# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.names["cmake_find_package"] = "WebP"
self.cpp_info.names["cmake_find_package_multi"] = "WebP"
self.cpp_info.names["pkg_config"] = "libwebp-all-do-not-use"
self.cpp_info.components["webpmux"].names["cmake_find_package"] = "libwebpmux"
self.cpp_info.components["webpmux"].names["cmake_find_package_multi"] = "libwebpmux"

View File

@@ -0,0 +1,15 @@
diff --git a/src/webp/types.h b/src/webp/types.h
index 0ce2622..69f7e89 100644
--- a/src/webp/types.h
+++ b/src/webp/types.h
@@ -39,7 +39,9 @@ typedef long long int int64_t;
#ifndef WEBP_EXTERN
// This explicitly marks library functions and allows for changing the
// signature for e.g., Windows DLL builds.
-# if defined(__GNUC__) && __GNUC__ >= 4
+# if defined(_MSC_VER) && defined(WEBP_DLL)
+# define WEBP_EXTERN __declspec(dllexport)
+# elif defined(__GNUC__) && __GNUC__ >= 4
# define WEBP_EXTERN extern __attribute__ ((visibility ("default")))
# else
# define WEBP_EXTERN extern

View File

@@ -0,0 +1,14 @@
diff --git a/cmake/deps.cmake b/cmake/deps.cmake
index f19c0378..7b2d7cd7 100644
--- a/cmake/deps.cmake
+++ b/cmake/deps.cmake
@@ -24,7 +24,8 @@ check_c_source_compiles("
# Check for libraries.
find_package(Threads)
if(Threads_FOUND)
- if(CMAKE_USE_PTHREADS_INIT)
+ # work around cmake bug on QNX (https://chromium-review.googlesource.com/c/webm/libwebp/+/2637274)
+ if(CMAKE_USE_PTHREADS_INIT AND NOT CMAKE_SYSTEM_NAME STREQUAL "QNX")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
endif()
foreach(PTHREAD_TEST HAVE_PTHREAD_PRIO_INHERIT PTHREAD_CREATE_UNDETACHED)

View File

@@ -0,0 +1,11 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -402,7 +402,7 @@ if(WEBP_BUILD_CWEBP)
install(TARGETS cwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
-if(WEBP_BUILD_GIF2WEBP OR WEBP_BUILD_IMG2WEBP)
+if(1)
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/src/mux "WEBP_MUX_SRCS" "")
add_library(libwebpmux ${WEBP_MUX_SRCS})
target_link_libraries(libwebpmux webp)

View File

@@ -0,0 +1,21 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad5e14c3..89c836f3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,7 +58,6 @@ if(WEBP_LINK_STATIC)
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
- set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# vwebp does not compile on Ubuntu with static libraries so disabling it for
# now.
set(WEBP_BUILD_VWEBP OFF)
@@ -153,7 +152,7 @@ endif()
set(PTHREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
set(INSTALLED_LIBRARIES)
-if(MSVC)
+if(0)
# match the naming convention used by nmake
set(webp_libname_prefix "lib")
set(CMAKE_SHARED_LIBRARY_PREFIX "${webp_libname_prefix}")

View File

@@ -0,0 +1,21 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad5e14c3..89c836f3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,7 +60,6 @@ if(WEBP_LINK_STATIC)
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
- set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# vwebp does not compile on Ubuntu with static libraries so disabling it for
# now.
set(WEBP_BUILD_VWEBP OFF)
@@ -155,7 +154,7 @@ endif()
set(PTHREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
set(INSTALLED_LIBRARIES)
-if(MSVC)
+if(0)
# match the naming convention used by nmake
set(webp_libname_prefix "lib")
set(CMAKE_SHARED_LIBRARY_PREFIX "${webp_libname_prefix}")

View File

@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)
find_package(WebP REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE WebP::webp)

View File

@@ -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")

View File

@@ -0,0 +1,10 @@
#include <stdio.h>
#include <webp/decode.h>
int main(void)
{
int version = WebPGetDecoderVersion();
printf("Webp Decoder version: %d\n", version);
return 0;
}

View File

@@ -0,0 +1,11 @@
versions:
"1.4.0":
folder: all
"1.3.2":
folder: all
"1.3.1":
folder: all
"1.2.4":
folder: all
"1.1.0":
folder: all