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

libmediainfo: add v23.11, simplify patching #21961

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
42 changes: 3 additions & 39 deletions recipes/libmediainfo/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"23.11":
url: "https://mediaarea.net/download/source/libmediainfo/23.11/libmediainfo_23.11.tar.xz"
sha256: "197e54fcc79e3c0d5df44a8f58dc4e018bc2f85d13fa3bed54af3dc56d5e853d"
"22.03":
url: "https://mediaarea.net/download/source/libmediainfo/22.03/libmediainfo_22.03.tar.xz"
sha256: "fc50babb628e9cfba655288dae06d5c342b0d7e6941a32d64fbbb113248c80b9"
Expand All @@ -8,42 +11,3 @@ sources:
"21.03":
url: "https://mediaarea.net/download/source/libmediainfo/21.03/libmediainfo_21.03.tar.xz"
sha256: "56b7e9abf80cba48032165cd7a46fd8d43dd63e3af35765f66c3f134caaca4ca"
"20.03":
url: "https://mediaarea.net/download/source/libmediainfo/20.03/libmediainfo_20.03.tar.xz"
sha256: "6848310eb7050efe7f90f18191dacfcc220c924390b8088fdf0d553274917f72"
patches:
"22.03":
- patch_file: "patches/21.09-0001-cmake-get-property-location.patch"
patch_description: "CMake: remove use of LOCATION property"
patch_type: "portability"
patch_source: "https://github.com/MediaArea/MediaInfoLib/pull/1526"
- patch_file: "patches/21.09-0002-cmake-handle-dependencies.patch"
patch_description: "CMake: robust discovery and link of dependencies"
patch_type: "conan"
"21.09":
- patch_file: "patches/21.09-0001-cmake-get-property-location.patch"
patch_description: "CMake: remove use of LOCATION property"
patch_type: "portability"
patch_source: "https://github.com/MediaArea/MediaInfoLib/pull/1526"
- patch_file: "patches/21.09-0002-cmake-handle-dependencies.patch"
patch_description: "CMake: robust discovery and link of dependencies"
patch_type: "conan"
"21.03":
- patch_file: "patches/21.03-0001-cmake-get-property-location.patch"
patch_description: "CMake: remove use of LOCATION property"
patch_type: "portability"
patch_source: "https://github.com/MediaArea/MediaInfoLib/pull/1526"
- patch_file: "patches/21.03-0002-cmake-handle-dependencies.patch"
patch_description: "CMake: robust discovery and link of dependencies"
patch_type: "conan"
"20.03":
- patch_file: "patches/20.03-0001-cmake-get-property-location.patch"
patch_description: "CMake: remove use of LOCATION property"
patch_type: "portability"
patch_source: "https://github.com/MediaArea/MediaInfoLib/pull/1526"
- patch_file: "patches/20.03-0002-cmake-handle-dependencies.patch"
patch_description: "CMake: robust discovery and link of dependencies"
patch_type: "conan"
- patch_file: "patches/20.03-0003-cmake-minimum-required.patch"
patch_description: "CMake: fix cmake_minimum_required()"
patch_type: "conan"
39 changes: 29 additions & 10 deletions recipes/libmediainfo/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import is_apple_os
from conan.tools.build import check_min_cppstd, valid_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import (
apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file,
rm, rmdir, save
)
from conan.tools.files import copy, get, replace_in_file, rm, rmdir, save
from conan.tools.scm import Version
import os
import textwrap
Expand Down Expand Up @@ -34,8 +32,12 @@ class LibmediainfoConan(ConanFile):
"fPIC": True,
}

def export_sources(self):
export_conandata_patches(self)
@property
def _min_cppstd(self):
if Version(self.version) >= "23.11":
# https://github.com/MediaArea/MediaInfoLib/commit/3bc1fa4c1ea4f15abe053d620b6b585cd8c01998
return 11
return None

def config_options(self):
if self.settings.os == "Windows":
Expand All @@ -50,11 +52,13 @@ def layout(self):

def requirements(self):
self.requires("libcurl/[>=7.78.0 <9]")
self.requires("libzen/0.4.38", transitive_headers=True, transitive_libs=True)
self.requires("tinyxml2/9.0.0")
self.requires("libzen/0.4.41", transitive_headers=True, transitive_libs=True)
self.requires("tinyxml2/10.0.0")
self.requires("zlib/[>=1.2.11 <2]")

def validate(self):
if self.settings.compiler.cppstd and self._min_cppstd:
check_min_cppstd(self, self._min_cppstd)
if not self.dependencies["libzen"].options.enable_unicode:
raise ConanInvalidConfiguration("This package requires libzen with unicode support")

Expand All @@ -63,18 +67,23 @@ def source(self):

def generate(self):
tc = CMakeToolchain(self)
if self._min_cppstd and not valid_min_cppstd(self, self._min_cppstd):
tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd
tc.variables["BUILD_ZENLIB"] = False
tc.variables["BUILD_ZLIB"] = False
tc.variables["ZenLib_LIBRARY"] = "zen::zen"
if Version(self.version) < "22.03":
# Generate a relocatable shared lib on Macos
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW"
# Allow non-cache_variables
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
tc.generate()
deps = CMakeDeps(self)
deps.set_property("tinyxml2", "cmake_file_name", "TinyXML")
deps.set_property("libzen", "cmake_target_name", "zen::zen")
deps.generate()

def _patch_sources(self):
apply_conandata_patches(self)

# TODO: move this to a patch (see how https://github.com/MediaArea/MediaInfoLib/issues/1408 is addressed by upstream)
postfix = ""
if self.settings.build_type == "Debug":
Expand All @@ -86,6 +95,12 @@ def _patch_sources(self):
replace_in_file(self, mediainfodll_h, "MediaInfo.dll", f"MediaInfo{postfix}.dll")
replace_in_file(self, mediainfodll_h, "libmediainfo.0.dylib", f"libmediainfo{postfix}.0.dylib")

replace_in_file(self, os.path.join(self.source_folder, "Project", "CMake", "CMakeLists.txt"),
"if(MSVC AND BUILD_SHARED_LIBS)", "if(0)")
# CMake: remove use of LOCATION property"
replace_in_file(self, os.path.join(self.source_folder, "Project", "CMake", "CMakeLists.txt"),
"set(ZLIB_LIBRARIES", "# set(ZLIB_LIBRARIES")

def build(self):
self._patch_sources()
cmake = CMake(self)
Expand Down Expand Up @@ -127,6 +142,7 @@ def package_info(self):
self.cpp_info.set_property("cmake_file_name", "MediaInfoLib")
self.cpp_info.set_property("cmake_target_name", "mediainfo")
self.cpp_info.set_property("pkg_config_name", "libmediainfo")

postfix = ""
if self.settings.build_type == "Debug":
if self.settings.os == "Windows":
Expand All @@ -137,6 +153,9 @@ def package_info(self):
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.extend(["dl", "m", "pthread"])

if self.options.shared:
self.cpp_info.defines.append("LIBMEDIAINFO_SHARED")

# TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed
self.cpp_info.names["cmake_find_package"] = "MediaInfoLib"
self.cpp_info.names["cmake_find_package_multi"] = "MediaInfoLib"
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading