[DO-977] add libyuv package (!12)

Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/12
This commit is contained in:
Aleksandr Vodyanov
2024-12-26 13:56:22 +03:00
parent 28d4363c15
commit 0d5cfacb2e
13 changed files with 584 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
# Versions from LIBYUV_VERSION definition in include/libyuv/version.h
# Pay attention to package commits incrementing this definition
sources:
"1857":
url: "ssh://git@git.avroid.tech:2222/Mirrors/libyuv"
branch: "d5aa3d4a76"
patches:
"1892":
- patch_file: "patches/1892-0001-fix-cmake.patch"
patch_description: "Fix CMake to be more robust & predictable"
patch_type: "conan"
- patch_file: "patches/1892-0002-check-arm-sve.patch"
patch_description: "Check if -march=armv9-a+sve2 is supported"
patch_type: "conan"
"1880":
- patch_file: "patches/1880-0001-fix-cmake.patch"
patch_description: "Fix CMake to be more robust & predictable"
patch_type: "conan"
"1857":
- patch_file: "patches/1854-0001-fix-cmake.patch"
patch_description: "Fix CMake to be more robust & predictable"
patch_type: "conan"
"1854":
- patch_file: "patches/1854-0001-fix-cmake.patch"
patch_description: "Fix CMake to be more robust & predictable"
patch_type: "conan"
"1845":
- patch_file: "patches/1841-0001-fix-cmake.patch"
patch_description: "Fix CMake to be more robust & predictable"
patch_type: "conan"
"1841":
- patch_file: "patches/1841-0001-fix-cmake.patch"
patch_description: "Fix CMake to be more robust & predictable"
patch_type: "conan"
"1768":
- patch_file: "patches/1768-0001-fix-cmake.patch"
patch_description: "Fix CMake to be more robust & predictable"
patch_type: "conan"

View File

@@ -0,0 +1,100 @@
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, replace_in_file, chdir
from conan.tools.microsoft import is_msvc
from conan.tools.scm import Version, Git
import os
required_conan_version = ">=2.1"
class LibyuvConan(ConanFile):
name = "libyuv"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://chromium.googlesource.com/libyuv/libyuv/"
description = "libyuv is an open source project that includes YUV scaling and conversion functionality."
topics = ["YUV", "libyuv", "google", "chromium"]
license = "BSD-3-Clause"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_jpeg": [False, "libjpeg", "libjpeg-turbo", "mozjpeg"],
}
default_options = {
"shared": False,
"fPIC": True,
"with_jpeg": "libjpeg",
}
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 is_msvc(self):
# Only static for msvc
# Injecting CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS is not sufficient since there are global symbols
del self.options.shared
self.package_type = "static-library"
if self.options.get_safe("shared"):
self.options.rm_safe("fPIC")
def layout(self):
cmake_layout(self, src_folder="src")
def requirements(self):
if self.options.with_jpeg == "libjpeg":
self.requires("libjpeg/9e")
elif self.options.with_jpeg == "libjpeg-turbo":
self.requires("libjpeg-turbo/[>=3.0.3 <4]")
elif self.options.with_jpeg == "mozjpeg":
self.requires("mozjpeg/4.1.5")
def source(self):
# get(self, **self.conan_data["sources"][self.version])
git = Git(self)
sources = self.conan_data["sources"][self.version]
git.clone(url=sources["url"], target=self.source_folder)
with chdir(self, self.source_folder):
git.checkout(sources["branch"])
apply_conandata_patches(self)
def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["TEST"] = False
tc.cache_variables["LIBYUV_WITH_JPEG"] = bool(self.options.with_jpeg)
if self.options.get_safe("shared"):
# Force FPIC for shared, Conan does not set it
tc.cache_variables["CMAKE_POSITION_INDEPENDENT_CODE"] = True
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
def package_info(self):
self.cpp_info.libs = ["yuv"]
self.cpp_info.requires = []
if self.settings.compiler == "msvc":
self.cpp_info.defines.append("_CRT_SECURE_NO_WARNINGS")
if self.options.with_jpeg == "libjpeg":
self.cpp_info.requires.append("libjpeg::libjpeg")
elif self.options.with_jpeg == "libjpeg-turbo":
self.cpp_info.requires.append("libjpeg-turbo::jpeg")
elif self.options.with_jpeg == "mozjpeg":
self.cpp_info.requires.append("mozjpeg::libjpeg")
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")

Submodule recipes/libyuv/all/libyuv added at d5aa3d4a76

View File

@@ -0,0 +1,58 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,8 +2,8 @@
# Originally created for "roxlu build system" to compile libyuv on windows
# Run with -DTEST=ON to build unit tests
+CMAKE_MINIMUM_REQUIRED( VERSION 3.8 )
PROJECT ( YUV C CXX ) # "C" is required even for C++ projects
-CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
OPTION( TEST "Built unit tests" OFF )
SET ( ly_base_dir ${PROJECT_SOURCE_DIR} )
@@ -23,23 +23,22 @@ LIST ( SORT ly_unittest_sources )
INCLUDE_DIRECTORIES( BEFORE ${ly_inc_dir} )
# this creates the static library (.a)
-ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} )
+ADD_LIBRARY ( ${ly_lib_static} ${ly_source_files} )
+target_compile_features(${ly_lib_static} PUBLIC cxx_std_11)
# this creates the shared library (.so)
-ADD_LIBRARY ( ${ly_lib_shared} SHARED ${ly_source_files} )
-SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" )
-SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES PREFIX "lib" )
# this creates the conversion tool
ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc )
TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} )
-INCLUDE ( FindJPEG )
-if (JPEG_FOUND)
- include_directories( ${JPEG_INCLUDE_DIR} )
- target_link_libraries( yuvconvert ${JPEG_LIBRARY} )
- add_definitions( -DHAVE_JPEG )
+option(LIBYUV_WITH_JPEG "Build libyuv with jpeg" ON)
+if (LIBYUV_WITH_JPEG)
+ find_package(JPEG REQUIRED)
+ target_link_libraries(${ly_lib_static} JPEG::JPEG )
+ target_compile_definitions(${ly_lib_static} PRIVATE HAVE_JPEG)
+ target_compile_definitions(yuvconvert PRIVATE HAVE_JPEG)
endif()
if(TEST)
@@ -81,11 +81,9 @@ endif()
# install the conversion tool, .so, .a, and all the header files
-INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin )
-INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib )
-INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin )
+INSTALL ( TARGETS yuvconvert DESTINATION bin)
+INSTALL ( TARGETS ${ly_lib_static} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include )
# create the .deb and .rpm packages using cpack
-INCLUDE ( CM_linux_packages.cmake )

View File

@@ -0,0 +1,61 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,8 +2,8 @@
# Originally created for "roxlu build system" to compile libyuv on windows
# Run with -DTEST=ON to build unit tests
+CMAKE_MINIMUM_REQUIRED( VERSION 3.8 )
PROJECT ( YUV C CXX ) # "C" is required even for C++ projects
-CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 )
OPTION( TEST "Built unit tests" OFF )
SET ( ly_base_dir ${PROJECT_SOURCE_DIR} )
@@ -27,26 +27,22 @@ if(MSVC)
endif()
# this creates the static library (.a)
-ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} )
+ADD_LIBRARY ( ${ly_lib_static} ${ly_source_files} )
+target_compile_features(${ly_lib_static} PUBLIC cxx_std_11)
# this creates the shared library (.so)
-ADD_LIBRARY ( ${ly_lib_shared} SHARED ${ly_source_files} )
-SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" )
-SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES PREFIX "lib" )
-if(WIN32)
- SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES IMPORT_PREFIX "lib" )
-endif()
# this creates the conversion tool
ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc )
TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} )
-INCLUDE ( FindJPEG )
-if (JPEG_FOUND)
- include_directories( ${JPEG_INCLUDE_DIR} )
- target_link_libraries( yuvconvert ${JPEG_LIBRARY} )
- add_definitions( -DHAVE_JPEG )
+option(LIBYUV_WITH_JPEG "Build libyuv with jpeg" ON)
+if (LIBYUV_WITH_JPEG)
+ find_package(JPEG REQUIRED)
+ target_link_libraries(${ly_lib_static} JPEG::JPEG )
+ target_compile_definitions(${ly_lib_static} PRIVATE HAVE_JPEG)
+ target_compile_definitions(yuvconvert PRIVATE HAVE_JPEG)
endif()
if(TEST)
@@ -82,11 +79,9 @@ endif()
# install the conversion tool, .so, .a, and all the header files
-INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin )
-INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib )
-INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin )
+INSTALL ( TARGETS yuvconvert DESTINATION bin)
+INSTALL ( TARGETS ${ly_lib_static} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include )
# create the .deb and .rpm packages using cpack
-INCLUDE ( CM_linux_packages.cmake )

View File

@@ -0,0 +1,68 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,8 +2,8 @@
# Originally created for "roxlu build system" to compile libyuv on windows
# Run with -DTEST=ON to build unit tests
+CMAKE_MINIMUM_REQUIRED( VERSION 3.8 )
PROJECT ( YUV C CXX ) # "C" is required even for C++ projects
-CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 )
OPTION( TEST "Built unit tests" OFF )
SET ( ly_base_dir ${PROJECT_SOURCE_DIR} )
@@ -27,15 +27,10 @@ if(MSVC)
endif()
# this creates the static library (.a)
-ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} )
+ADD_LIBRARY ( ${ly_lib_static} ${ly_source_files} )
+target_compile_features(${ly_lib_static} PUBLIC cxx_std_11)
# this creates the shared library (.so)
-ADD_LIBRARY ( ${ly_lib_shared} SHARED ${ly_source_files} )
-SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" )
-SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES PREFIX "lib" )
-if(WIN32)
- SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES IMPORT_PREFIX "lib" )
-endif()
# this creates the conversion tool
ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc )
@@ -44,12 +40,18 @@ TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} )
# this creates the yuvconstants tool
ADD_EXECUTABLE ( yuvconstants ${ly_base_dir}/util/yuvconstants.c )
TARGET_LINK_LIBRARIES ( yuvconstants ${ly_lib_static} )
+include(CheckFunctionExists)
+check_function_exists(round HAVE_MATH_SYSTEM)
+if(NOT HAVE_MATH_SYSTEM)
+ target_link_libraries(yuvconstants m)
+endif()
-find_package ( JPEG )
-if (JPEG_FOUND)
- include_directories( ${JPEG_INCLUDE_DIR} )
- target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} )
- add_definitions( -DHAVE_JPEG )
+option(LIBYUV_WITH_JPEG "Build libyuv with jpeg" ON)
+if (LIBYUV_WITH_JPEG)
+ find_package(JPEG REQUIRED)
+ target_link_libraries(${ly_lib_static} JPEG::JPEG )
+ target_compile_definitions(${ly_lib_static} PRIVATE HAVE_JPEG)
+ target_compile_definitions(yuvconvert PRIVATE HAVE_JPEG)
endif()
if(TEST)
@@ -91,11 +93,9 @@ endif()
# install the conversion tool, .so, .a, and all the header files
-INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin )
-INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib )
-INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin )
+INSTALL ( TARGETS yuvconvert yuvconstants DESTINATION bin)
+INSTALL ( TARGETS ${ly_lib_static} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include )
# create the .deb and .rpm packages using cpack
-INCLUDE ( CM_linux_packages.cmake )

View File

@@ -0,0 +1,68 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,8 +2,8 @@
# Originally created for "roxlu build system" to compile libyuv on windows
# Run with -DTEST=ON to build unit tests
+CMAKE_MINIMUM_REQUIRED( VERSION 3.8 )
PROJECT ( YUV C CXX ) # "C" is required even for C++ projects
-CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 )
OPTION( UNIT_TEST "Built unit tests" OFF )
SET ( ly_base_dir ${PROJECT_SOURCE_DIR} )
@@ -27,15 +27,10 @@ if(MSVC)
endif()
# this creates the static library (.a)
-ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} )
+ADD_LIBRARY ( ${ly_lib_static} ${ly_source_files} )
+target_compile_features(${ly_lib_static} PUBLIC cxx_std_11)
# this creates the shared library (.so)
-ADD_LIBRARY ( ${ly_lib_shared} SHARED ${ly_source_files} )
-SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" )
-SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES PREFIX "lib" )
-if(WIN32)
- SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES IMPORT_PREFIX "lib" )
-endif()
# this creates the conversion tool
ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc )
@@ -44,12 +39,18 @@ TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} )
# this creates the yuvconstants tool
ADD_EXECUTABLE ( yuvconstants ${ly_base_dir}/util/yuvconstants.c )
TARGET_LINK_LIBRARIES ( yuvconstants ${ly_lib_static} )
+include(CheckFunctionExists)
+check_function_exists(round HAVE_MATH_SYSTEM)
+if(NOT HAVE_MATH_SYSTEM)
+ target_link_libraries(yuvconstants m)
+endif()
-find_package ( JPEG )
-if (JPEG_FOUND)
- include_directories( ${JPEG_INCLUDE_DIR} )
- target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} )
- add_definitions( -DHAVE_JPEG )
+option(LIBYUV_WITH_JPEG "Build libyuv with jpeg" ON)
+if (LIBYUV_WITH_JPEG)
+ find_package(JPEG REQUIRED)
+ target_link_libraries(${ly_lib_static} JPEG::JPEG )
+ target_compile_definitions(${ly_lib_static} PRIVATE HAVE_JPEG)
+ target_compile_definitions(yuvconvert PRIVATE HAVE_JPEG)
endif()
if(UNIT_TEST)
@@ -94,11 +95,9 @@ endif()
# install the conversion tool, .so, .a, and all the header files
-INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin )
-INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib )
-INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin )
+INSTALL ( TARGETS yuvconvert yuvconstants DESTINATION bin)
+INSTALL ( TARGETS ${ly_lib_static} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include )
# create the .deb and .rpm packages using cpack
-INCLUDE ( CM_linux_packages.cmake )

View File

@@ -0,0 +1,81 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a021623..e0e25db 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,8 +4,8 @@
include(CheckCSourceCompiles)
+CMAKE_MINIMUM_REQUIRED( VERSION 3.8 )
PROJECT ( YUV C CXX ) # "C" is required even for C++ projects
-CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 )
OPTION( UNIT_TEST "Built unit tests" OFF )
SET ( ly_base_dir ${PROJECT_SOURCE_DIR} )
@@ -74,8 +74,6 @@ if(MSVC)
ADD_DEFINITIONS ( -D_CRT_SECURE_NO_WARNINGS )
endif()
-# Need to set PIC to allow creating shared libraries from object file libraries.
-SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Build the set of objects that do not need to be compiled with flags to enable
# particular architecture features.
@@ -139,15 +137,10 @@ int main(void) { return 0; }
endif()
# this creates the static library (.a)
-ADD_LIBRARY( ${ly_lib_static} STATIC ${ly_lib_parts})
+ADD_LIBRARY( ${ly_lib_static} ${ly_lib_parts})
+target_compile_features(${ly_lib_static} PUBLIC cxx_std_11)
# this creates the shared library (.so)
-ADD_LIBRARY( ${ly_lib_shared} SHARED ${ly_lib_parts})
-SET_TARGET_PROPERTIES( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" )
-SET_TARGET_PROPERTIES( ${ly_lib_shared} PROPERTIES PREFIX "lib" )
-if(WIN32)
- SET_TARGET_PROPERTIES( ${ly_lib_shared} PROPERTIES IMPORT_PREFIX "lib" )
-endif()
# this creates the cpuid tool
ADD_EXECUTABLE ( cpuid ${ly_base_dir}/util/cpuid.c )
@@ -160,12 +153,20 @@ TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} )
# this creates the yuvconstants tool
ADD_EXECUTABLE ( yuvconstants ${ly_base_dir}/util/yuvconstants.c )
TARGET_LINK_LIBRARIES ( yuvconstants ${ly_lib_static} )
+include(CheckFunctionExists)
+check_function_exists(round HAVE_MATH_SYSTEM)
+if(NOT HAVE_MATH_SYSTEM)
+ target_link_libraries(yuvconstants m)
+endif()
-find_package ( JPEG )
-if (JPEG_FOUND)
- include_directories( ${JPEG_INCLUDE_DIR} )
- target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} )
- add_definitions( -DHAVE_JPEG )
+option(LIBYUV_WITH_JPEG "Build libyuv with jpeg" ON)
+if (LIBYUV_WITH_JPEG)
+ find_package(JPEG REQUIRED)
+ target_link_libraries(${ly_lib_static} JPEG::JPEG )
+ target_link_libraries(${ly_lib_name}_common_objects JPEG::JPEG )
+ target_compile_definitions(${ly_lib_static} PRIVATE HAVE_JPEG)
+ target_compile_definitions(yuvconvert PRIVATE HAVE_JPEG)
+ target_compile_definitions(${ly_lib_name}_common_objects PRIVATE HAVE_JPEG)
endif()
if(UNIT_TEST)
@@ -211,11 +212,9 @@ endif()
# install the conversion tool, .so, .a, and all the header files
-INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin )
-INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib )
-INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin )
+INSTALL ( TARGETS yuvconvert yuvconstants DESTINATION bin)
+INSTALL ( TARGETS ${ly_lib_static} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include )
# create the .deb and .rpm packages using cpack
-INCLUDE ( CM_linux_packages.cmake )

View File

@@ -0,0 +1,40 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e0e25db..c0d9399 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -105,16 +105,28 @@ if(NOT MSVC)
TARGET_COMPILE_OPTIONS(${ly_lib_name}_neon64 PRIVATE -march=armv8-a+dotprod+i8mm)
LIST(APPEND ly_lib_parts $<TARGET_OBJECTS:${ly_lib_name}_neon64>)
- # Enable AArch64 SVE kernels.
- ADD_LIBRARY(${ly_lib_name}_sve OBJECT
- ${ly_src_dir}/row_sve.cc)
- TARGET_COMPILE_OPTIONS(${ly_lib_name}_sve PRIVATE -march=armv9-a+sve2)
- LIST(APPEND ly_lib_parts $<TARGET_OBJECTS:${ly_lib_name}_sve>)
-
set(OLD_CMAKE_REQURED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(OLD_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
- set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -march=armv9-a+sme")
+
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -march=armv9-a+sve2")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+ # Check whether the compiler can compile SVE functions; this fails
+ # with Clang for macOS.
+ check_c_source_compiles("
+int main(void) { return 0; }
+ " CAN_COMPILE_SVE)
+
+ if (CAN_COMPILE_SVE)
+ # Enable AArch64 SVE kernels.
+ ADD_LIBRARY(${ly_lib_name}_sve OBJECT
+ ${ly_src_dir}/row_sve.cc)
+ TARGET_COMPILE_OPTIONS(${ly_lib_name}_sve PRIVATE -march=armv9-a+sve2)
+ LIST(APPEND ly_lib_parts $<TARGET_OBJECTS:${ly_lib_name}_sve>)
+ else()
+ ADD_DEFINITIONS(-DLIBYUV_DISABLE_SVE)
+ endif()
+
+ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQURED_FLAGS} -march=armv9-a+sme)
# Check whether the compiler can compile SME functions; this fails
# with Clang for Windows.
check_c_source_compiles("

View File

@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)
find_package(libyuv REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE libyuv::libyuv)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)

View File

@@ -0,0 +1,31 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires(self.tested_reference_str)
def generate(self):
tc = CMakeToolchain(self)
tc.preprocessor_definitions["HAS_JPEG"] = bool(self.dependencies[self.tested_reference_str].options.with_jpeg)
tc.generate()
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,17 @@
#include "libyuv.h"
#if HAS_JPEG
#include "libyuv/mjpeg_decoder.h"
#endif
int main() {
uint8_t in[16] = {};
uint8_t out[16] = {};
libyuv::ConvertToARGB(in, 16, out, 0, 0, 0, 1, 1, 0, 0,
libyuv::RotationMode::kRotate0, 0);
#if HAS_JPEG
// Test jpeg implementaiton is correctly linked
libyuv::MJpegDecoder decoder;
decoder.LoadFrame(in, 0);
#endif
return 0;
}

13
recipes/libyuv/config.yml Normal file
View File

@@ -0,0 +1,13 @@
versions:
"1892":
folder: all
"1880":
folder: all
"1854":
folder: all
"1845":
folder: all
"1841":
folder: all
"1768":
folder: all