[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,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("