-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libyuv] Update, enable shared lib (#40549)
- Loading branch information
Showing
12 changed files
with
106 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 9a20941..945c5a4 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -4,8 +4,8 @@ | ||
|
||
include(CheckCSourceCompiles) | ||
|
||
+cmake_minimum_required(VERSION 3.12) | ||
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} ) | ||
@@ -164,7 +164,8 @@ target_link_libraries ( yuvconstants ${ly_lib_static} ) | ||
find_package ( JPEG ) | ||
if (JPEG_FOUND) | ||
include_directories( ${JPEG_INCLUDE_DIR} ) | ||
- target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} ) | ||
+ target_link_libraries( ${ly_lib_static} PRIVATE JPEG::JPEG ) | ||
+ target_link_libraries( ${ly_lib_shared} PRIVATE JPEG::JPEG ) | ||
add_definitions( -DHAVE_JPEG ) | ||
endif() | ||
|
||
@@ -211,9 +212,18 @@ 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) | ||
+if(BUILD_SHARED_LIBS) | ||
+ target_include_directories(${ly_lib_shared} PUBLIC $<INSTALL_INTERFACE:include>) | ||
+ install(TARGETS ${ly_lib_shared} EXPORT libyuv-targets) | ||
+ set_target_properties(${ly_lib_shared} PROPERTIES EXPORT_NAME "${ly_lib_static}") # vcpkg legacy | ||
+ add_definitions(-DLIBYUV_BUILDING_SHARED_LIBRARY) | ||
+else() | ||
+ target_include_directories(${ly_lib_static} PUBLIC $<INSTALL_INTERFACE:include>) | ||
+ install(TARGETS ${ly_lib_static} EXPORT libyuv-targets) | ||
+ set_target_properties(${ly_lib_shared} PROPERTIES EXCLUDE_FROM_ALL 1) | ||
+endif() | ||
+install(EXPORT libyuv-targets DESTINATION share/libyuv) | ||
install ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include ) | ||
|
||
# create the .deb and .rpm packages using cpack |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,41 @@ | ||
vcpkg_check_linkage(ONLY_STATIC_LIBRARY) | ||
|
||
vcpkg_from_git( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
URL https://chromium.googlesource.com/libyuv/libyuv | ||
REF 0faf8dd0e004520a61a603a4d2996d5ecc80dc3f | ||
REF c21dda06dd8d19b6e50168c28c324c1f32e94407 # 6 commits after switch to 1895, reason: CMake changes | ||
# Check https://chromium.googlesource.com/libyuv/libyuv/+/refs/heads/main/include/libyuv/version.h for a version! | ||
PATCHES | ||
fix-cmakelists.patch | ||
cmake.diff | ||
) | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH ${SOURCE_PATH} | ||
OPTIONS | ||
${BUILD_OPTIONS} | ||
OPTIONS_DEBUG | ||
-DCMAKE_DEBUG_POSTFIX=d | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
) | ||
|
||
vcpkg_cmake_install() | ||
vcpkg_cmake_config_fixup() | ||
vcpkg_copy_pdbs() | ||
|
||
vcpkg_cmake_config_fixup(CONFIG_PATH share/cmake/libyuv) | ||
vcpkg_copy_tools(TOOL_NAMES yuvconvert AUTO_CLEAN) | ||
|
||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) | ||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) | ||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") | ||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libyuv/basic_types.h" "defined(LIBYUV_USING_SHARED_LIBRARY)" "1") | ||
endif() | ||
|
||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") | ||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") | ||
|
||
configure_file(${CMAKE_CURRENT_LIST_DIR}/libyuv-config.cmake ${CURRENT_PACKAGES_DIR}/share/${PORT} COPYONLY) | ||
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) | ||
file(COPY "${CMAKE_CURRENT_LIST_DIR}/libyuv-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") | ||
file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") | ||
|
||
vcpkg_cmake_get_vars(cmake_vars_file) | ||
include("${cmake_vars_file}") | ||
if (VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
message(WARNING "Use MSVC to compile libyuv results in a very slow library. (https://github.com/microsoft/vcpkg/issues/28446)") | ||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage-msvc" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME "usage") | ||
else () | ||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") | ||
endif () | ||
if(VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
file(APPEND "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" [[ | ||
|
||
Attention: | ||
You are using MSVC to compile libyuv. This build won't compile any | ||
of the acceleration codes, which results in a very slow library. | ||
See workarounds: https://github.com/microsoft/vcpkg/issues/28446 | ||
]]) | ||
endif() | ||
|
||
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
libyuv provides CMake targets: | ||
|
||
find_package(libyuv CONFIG REQUIRED) | ||
target_link_libraries(main PRIVATE yuv) | ||
# Unofficial config package and target from vcpkg | ||
find_package(libyuv CONFIG REQUIRED) | ||
target_link_libraries(main PRIVATE yuv) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters