[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:
17
recipes/vorbis/all/conandata.yml
Normal file
17
recipes/vorbis/all/conandata.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
sources:
|
||||
"1.3.7":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/xiph/vorbis/archive/v1.3.7.tar.gz"
|
||||
sha256: "270c76933d0934e42c5ee0a54a36280e2d87af1de3cc3e584806357e237afd13"
|
||||
"1.3.6":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/xiph/vorbis/archive/v1.3.6.tar.gz"
|
||||
sha256: "43fc4bc34f13da15b8acfa72fd594678e214d1cab35fc51d3a54969a725464eb"
|
||||
patches:
|
||||
"1.3.7":
|
||||
- patch_file: "patches/1.3.7-0001-mingw-shared-def.patch"
|
||||
patch_description: "MinGW: fix .def file for shared lib"
|
||||
patch_type: "portability"
|
||||
patch_source: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/xiph/vorbis/pull/76"
|
||||
"1.3.6":
|
||||
- patch_file: "patches/1.3.6-0001-link-libm-find-package-ogg.patch"
|
||||
patch_description: "CMake: robust discovery and link of libm and Ogg"
|
||||
patch_type: "conan"
|
||||
114
recipes/vorbis/all/conanfile.py
Normal file
114
recipes/vorbis/all/conanfile.py
Normal file
@@ -0,0 +1,114 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
|
||||
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
|
||||
import os
|
||||
|
||||
required_conan_version = ">=1.54.0"
|
||||
|
||||
|
||||
class VorbisConan(ConanFile):
|
||||
name = "vorbis"
|
||||
description = "The VORBIS audio codec library"
|
||||
topics = ("audio", "codec")
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://xiph.org/vorbis/"
|
||||
license = "BSD-3-Clause"
|
||||
package_type = "library"
|
||||
settings = "os", "arch", "build_type", "compiler"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
}
|
||||
|
||||
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 requirements(self):
|
||||
self.requires("ogg/1.3.5", transitive_headers=True, transitive_libs=True)
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
# Relocatable shared lib on Macos
|
||||
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW"
|
||||
tc.generate()
|
||||
cd = CMakeDeps(self)
|
||||
cd.generate()
|
||||
|
||||
def build(self):
|
||||
apply_conandata_patches(self)
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def package(self):
|
||||
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
|
||||
cmake = CMake(self)
|
||||
cmake.install()
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_file_name", "Vorbis")
|
||||
# see https://github.com/conan-io/conan-center-index/pull/4173
|
||||
self.cpp_info.set_property("pkg_config_name", "vorbis-all-do-not-use")
|
||||
|
||||
# vorbis
|
||||
self.cpp_info.components["vorbismain"].set_property("cmake_target_name", "Vorbis::vorbis")
|
||||
self.cpp_info.components["vorbismain"].set_property("pkg_config_name", "vorbis")
|
||||
self.cpp_info.components["vorbismain"].libs = ["vorbis"]
|
||||
if self.settings.os in ["Linux", "FreeBSD"]:
|
||||
self.cpp_info.components["vorbismain"].system_libs.append("m")
|
||||
self.cpp_info.components["vorbismain"].requires = ["ogg::ogg"]
|
||||
|
||||
# TODO: Upstream VorbisConfig.cmake defines components 'Enc' and 'File',
|
||||
# which are related to imported targets Vorbis::vorbisenc and Vorbis::vorbisfile
|
||||
# Find a way to emulate this in CMakeDeps. See https://github.com/conan-io/conan/issues/10258
|
||||
|
||||
# vorbisenc
|
||||
self.cpp_info.components["vorbisenc"].set_property("cmake_target_name", "Vorbis::vorbisenc")
|
||||
self.cpp_info.components["vorbisenc"].set_property("pkg_config_name", "vorbisenc")
|
||||
self.cpp_info.components["vorbisenc"].libs = ["vorbisenc"]
|
||||
self.cpp_info.components["vorbisenc"].requires = ["vorbismain"]
|
||||
|
||||
# vorbisfile
|
||||
self.cpp_info.components["vorbisfile"].set_property("cmake_target_name", "Vorbis::vorbisfile")
|
||||
self.cpp_info.components["vorbisfile"].set_property("pkg_config_name", "vorbisfile")
|
||||
self.cpp_info.components["vorbisfile"].libs = ["vorbisfile"]
|
||||
self.cpp_info.components["vorbisfile"].requires = ["vorbismain"]
|
||||
|
||||
# TODO: to remove in conan v2 once cmake_find_package_* generators removed
|
||||
self.cpp_info.names["cmake_find_package"] = "Vorbis"
|
||||
self.cpp_info.names["cmake_find_package_multi"] = "Vorbis"
|
||||
self.cpp_info.names["pkg_config"] = "vorbis-all-do-not-use"
|
||||
self.cpp_info.components["vorbismain"].names["cmake_find_package"] = "vorbis"
|
||||
self.cpp_info.components["vorbismain"].names["cmake_find_package_multi"] = "vorbis"
|
||||
self.cpp_info.components["vorbisenc"].names["cmake_find_package"] = "vorbisenc"
|
||||
self.cpp_info.components["vorbisenc"].names["cmake_find_package_multi"] = "vorbisenc"
|
||||
self.cpp_info.components["vorbisfile"].names["cmake_find_package"] = "vorbisfile"
|
||||
self.cpp_info.components["vorbisfile"].names["cmake_find_package_multi"] = "vorbisfile"
|
||||
self.cpp_info.components["vorbisenc-alias"].names["cmake_find_package"] = "Enc"
|
||||
self.cpp_info.components["vorbisenc-alias"].names["cmake_find_package_multi"] = "Enc"
|
||||
self.cpp_info.components["vorbisenc-alias"].requires.append("vorbisenc")
|
||||
self.cpp_info.components["vorbisfile-alias"].names["cmake_find_package"] = "File"
|
||||
self.cpp_info.components["vorbisfile-alias"].names["cmake_find_package_multi"] = "File"
|
||||
self.cpp_info.components["vorbisfile-alias"].requires.append("vorbisfile")
|
||||
@@ -0,0 +1,56 @@
|
||||
Backport in 1.3.6 some build improvements of 1.3.7:
|
||||
* link to libm
|
||||
* usage of find_package to discover Ogg and link with Ogg:ogg target
|
||||
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -4,6 +4,7 @@ project(vorbis)
|
||||
# Required modules
|
||||
include(GNUInstallDirs)
|
||||
include(CheckIncludeFiles)
|
||||
+include(CheckLibraryExists)
|
||||
|
||||
# Build options
|
||||
option(BUILD_SHARED_LIBS "Build shared library" OFF)
|
||||
@@ -52,18 +53,12 @@ endfunction()
|
||||
|
||||
message(STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}")
|
||||
|
||||
+# Find math library
|
||||
+
|
||||
+check_library_exists(m floor "" HAVE_LIBM)
|
||||
+
|
||||
# Find ogg dependency
|
||||
-if(NOT OGG_ROOT)
|
||||
- find_package(PkgConfig QUIET)
|
||||
- pkg_check_modules(PC_OGG QUIET ogg)
|
||||
- find_path(OGG_INCLUDE_DIRS NAMES ogg/ogg.h HINTS ${PC_OGG_INCLUDE_DIRS} PATH_SUFFIXES ogg)
|
||||
- find_library(OGG_LIBRARIES NAMES ogg HINTS ${PC_OGG_LIBRARY_DIRS})
|
||||
-else()
|
||||
- find_path(OGG_INCLUDE_DIRS NAMES ogg/ogg.h HINTS ${OGG_ROOT}/include PATH_SUFFIXES ogg)
|
||||
- find_library(OGG_LIBRARIES NAMES ogg HINTS ${OGG_ROOT}/lib ${OGG_ROOT}/lib64)
|
||||
-endif()
|
||||
-include(FindPackageHandleStandardArgs)
|
||||
-find_package_handle_standard_args(OGG DEFAULT_MSG OGG_INCLUDE_DIRS OGG_LIBRARIES)
|
||||
+find_package(Ogg REQUIRED)
|
||||
|
||||
add_subdirectory(lib)
|
||||
|
||||
--- a/lib/CMakeLists.txt
|
||||
+++ b/lib/CMakeLists.txt
|
||||
@@ -83,9 +83,12 @@ if (NOT BUILD_FRAMEWORK)
|
||||
get_version_info(VORBISFILE_VERSION_INFO "VF_LIB_CURRENT" "VF_LIB_AGE" "VF_LIB_REVISION")
|
||||
set_target_properties(vorbisfile PROPERTIES SOVERSION ${VORBISFILE_VERSION_INFO})
|
||||
|
||||
- target_link_libraries(vorbis ${OGG_LIBRARIES})
|
||||
- target_link_libraries(vorbisenc ${OGG_LIBRARIES} vorbis)
|
||||
- target_link_libraries(vorbisfile ${OGG_LIBRARIES} vorbis)
|
||||
+ target_link_libraries(vorbis
|
||||
+ PUBLIC Ogg::ogg
|
||||
+ PRIVATE $<$<BOOL:${HAVE_LIBM}>:m>
|
||||
+ )
|
||||
+ target_link_libraries(vorbisenc PUBLIC vorbis)
|
||||
+ target_link_libraries(vorbisfile PUBLIC vorbis)
|
||||
|
||||
install(FILES ${VORBIS_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/vorbis)
|
||||
|
||||
29
recipes/vorbis/all/patches/1.3.7-0001-mingw-shared-def.patch
Normal file
29
recipes/vorbis/all/patches/1.3.7-0001-mingw-shared-def.patch
Normal file
@@ -0,0 +1,29 @@
|
||||
--- a/win32/vorbis.def
|
||||
+++ b/win32/vorbis.def
|
||||
@@ -1,6 +1,6 @@
|
||||
; vorbis.def
|
||||
;
|
||||
-LIBRARY
|
||||
+
|
||||
EXPORTS
|
||||
_floor_P
|
||||
_mapping_P
|
||||
--- a/win32/vorbisenc.def
|
||||
+++ b/win32/vorbisenc.def
|
||||
@@ -1,6 +1,5 @@
|
||||
; vorbisenc.def
|
||||
;
|
||||
-LIBRARY
|
||||
|
||||
EXPORTS
|
||||
vorbis_encode_init
|
||||
--- a/win32/vorbisfile.def
|
||||
+++ b/win32/vorbisfile.def
|
||||
@@ -1,6 +1,6 @@
|
||||
; vorbisfile.def
|
||||
;
|
||||
-LIBRARY
|
||||
+
|
||||
EXPORTS
|
||||
ov_clear
|
||||
ov_open
|
||||
7
recipes/vorbis/all/test_package/CMakeLists.txt
Normal file
7
recipes/vorbis/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
find_package(Vorbis REQUIRED Enc CONFIG)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Vorbis::vorbisenc)
|
||||
25
recipes/vorbis/all/test_package/conanfile.py
Normal file
25
recipes/vorbis/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import cross_building
|
||||
from conan.tools.cmake import CMake, cmake_layout
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if not cross_building(self):
|
||||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
|
||||
self.run(bin_path, env="conanrun")
|
||||
7
recipes/vorbis/all/test_package/test_package.c
Normal file
7
recipes/vorbis/all/test_package/test_package.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <vorbis/vorbisenc.h>
|
||||
|
||||
int main(){
|
||||
vorbis_comment vc;
|
||||
vorbis_comment_init(&vc);
|
||||
}
|
||||
5
recipes/vorbis/config.yml
Normal file
5
recipes/vorbis/config.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
versions:
|
||||
"1.3.7":
|
||||
folder: all
|
||||
"1.3.6":
|
||||
folder: all
|
||||
Reference in New Issue
Block a user