[libyuv]Build corresponding type library according to BUILD_SHARED_LIBS. (#8769)

* [libyuv]Build corresponding type library according to BUILD_SHARED_LIBS.

* [libyuv]Always use static build.
This commit is contained in:
JackBoosY 2019-10-30 14:05:27 +08:00 committed by Victor Romero
parent cd42fba998
commit be99ba1f5a
3 changed files with 58 additions and 33 deletions

View File

@ -1,4 +1,4 @@
Source: libyuv
Version: fec9121
Version: fec9121-1
Build-Depends: libjpeg-turbo
Description: libyuv is an open source project that includes YUV scaling and conversion functionality.

View File

@ -0,0 +1,53 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 097434b..8f8864f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,21 +28,25 @@ LIST ( SORT ly_unittest_sources )
INCLUDE_DIRECTORIES( BEFORE ${ly_inc_dir} )
# this creates the static library (.a)
+if (NOT BUILD_SHARED_LIBS)
ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} )
SET_TARGET_PROPERTIES( ${ly_lib_static} PROPERTIES PUBLIC_HEADER include/libyuv.h )
-
+else()
# 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" )
-
+endif()
# this creates the conversion tool
ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc )
-TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} )
-
+if (BUILD_SHARED_LIBS)
+ TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_shared} )
+else()
+ TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} )
+endif()
INCLUDE ( FindJPEG )
-if (JPEG_FOUND)
+if (JPEG_FOUND AND BUILD_SHARED_LIBS)
include_directories( ${JPEG_INCLUDE_DIR} )
target_link_libraries( ${ly_lib_shared} PUBLIC ${JPEG_LIBRARY} )
target_link_libraries( yuvconvert ${JPEG_LIBRARY} )
@@ -88,11 +92,13 @@ endif()
# install the conversion tool, .so, .a, and all the header files
-INSTALL ( TARGETS yuvconvert DESTINATION bin )
+INSTALL ( TARGETS yuvconvert DESTINATION tools )
INSTALL ( FILES ${ly_include_files} DESTINATION include/libyuv )
-INSTALL ( TARGETS ${ly_lib_static} EXPORT libyuv-export DESTINATION lib INCLUDES DESTINATION include PUBLIC_HEADER DESTINATION include )
-INSTALL ( TARGETS ${ly_lib_shared} EXPORT libyuv-export LIBRARY DESTINATION lib RUNTIME DESTINATION bin )
-
+if (NOT BUILD_SHARED_LIBS)
+ INSTALL ( TARGETS ${ly_lib_static} EXPORT libyuv-export DESTINATION lib INCLUDES DESTINATION include PUBLIC_HEADER DESTINATION include )
+else()
+ INSTALL ( TARGETS ${ly_lib_shared} EXPORT libyuv-export LIBRARY DESTINATION lib RUNTIME DESTINATION bin )
+endif()
INSTALL( EXPORT libyuv-export FILE libyuv-config.cmake DESTINATION share/cmake/libyuv/ EXPORT_LINK_INTERFACE_LIBRARIES )
# create the .deb and .rpm packages using cpack

View File

@ -1,4 +1,3 @@
include(vcpkg_common_functions)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_git(
@ -7,6 +6,7 @@ vcpkg_from_git(
REF fec9121b676eccd9acea2460aec7d6ae219701b9
PATCHES
fix_cmakelists.patch
fix-build-type.patch
)
set(POSTFIX d)
@ -18,38 +18,10 @@ vcpkg_configure_cmake(
)
vcpkg_install_cmake()
vcpkg_copy_pdbs()
set(YUVCONVERT_FNAME yuvconvert.exe)
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux" OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(YUVCONVERT_FNAME yuvconvert)
endif()
vcpkg_fixup_cmake_targets(CONFIG_PATH share/cmake/libyuv)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/tools/yuv)
file(RENAME ${CURRENT_PACKAGES_DIR}/bin/${YUVCONVERT_FNAME} ${CURRENT_PACKAGES_DIR}/tools/yuv/${YUVCONVERT_FNAME})
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin/${YUVCONVERT_FNAME})
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
endif()
set(LIBRARY_TYPE SHARED)
set(IMPORT_TYPE IMPLIB)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(LIBRARY_TYPE STATIC)
set(IMPORT_TYPE LOCATION)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin/libyuv.dll)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin/libyuv.dylib)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin)
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin/libyuvd.dll)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin/libyuvd.dylib)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin)
endif()
endif()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libyuv RENAME copyright)