mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Vendor overlay port for libyuv to support clang windows build
This commit is contained in:
parent
b9e399f269
commit
9d6f9c704e
5 changed files with 197 additions and 0 deletions
63
thirdparty/overlay-ports/libyuv/cmake.diff
vendored
Normal file
63
thirdparty/overlay-ports/libyuv/cmake.diff
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 9a20941d..d161326c 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -4,8 +4,9 @@
|
||||
|
||||
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( BUILD_TOOLS "Build tools" OFF )
|
||||
option( UNIT_TEST "Built unit tests" OFF )
|
||||
|
||||
set ( ly_base_dir ${PROJECT_SOURCE_DIR} )
|
||||
@@ -149,6 +150,8 @@ if(WIN32)
|
||||
set_target_properties( ${ly_lib_shared} PROPERTIES IMPORT_PREFIX "lib" )
|
||||
endif()
|
||||
|
||||
+if (BUILD_TOOLS)
|
||||
+
|
||||
# this creates the cpuid tool
|
||||
add_executable ( cpuid ${ly_base_dir}/util/cpuid.c )
|
||||
target_link_libraries ( cpuid ${ly_lib_static} )
|
||||
@@ -161,10 +164,13 @@ target_link_libraries ( yuvconvert ${ly_lib_static} )
|
||||
add_executable ( yuvconstants ${ly_base_dir}/util/yuvconstants.c )
|
||||
target_link_libraries ( yuvconstants ${ly_lib_static} )
|
||||
|
||||
+endif()
|
||||
+
|
||||
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 +217,20 @@ endif()
|
||||
|
||||
|
||||
# install the conversion tool, .so, .a, and all the header files
|
||||
-install ( TARGETS yuvconvert DESTINATION bin )
|
||||
-install ( TARGETS ${ly_lib_static} DESTINATION lib )
|
||||
-install ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib )
|
||||
+if (BUILD_TOOLS)
|
||||
+ install(TARGETS yuvconvert yuvconstants)
|
||||
+endif()
|
||||
+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
|
||||
5
thirdparty/overlay-ports/libyuv/libyuv-config.cmake
vendored
Normal file
5
thirdparty/overlay-ports/libyuv/libyuv-config.cmake
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(JPEG)
|
||||
|
||||
set(libyuv_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/../../include")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/libyuv-targets.cmake")
|
||||
95
thirdparty/overlay-ports/libyuv/portfile.cmake
vendored
Normal file
95
thirdparty/overlay-ports/libyuv/portfile.cmake
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
vcpkg_from_git(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
URL https://chromium.googlesource.com/libyuv/libyuv
|
||||
REF a37e6bc81b52d39cdcfd0f1428f5d6c2b2bc9861 # 1896 Fixes build error on macOS Homebrew LLVM 19
|
||||
# Check https://chromium.googlesource.com/libyuv/libyuv/+/refs/heads/main/include/libyuv/version.h for a version!
|
||||
PATCHES
|
||||
cmake.diff
|
||||
)
|
||||
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
FEATURES
|
||||
tools BUILD_TOOLS
|
||||
)
|
||||
|
||||
# BEGIN CLANG-CL HACK FOR MSVC
|
||||
vcpkg_cmake_get_vars(cmake_vars_file)
|
||||
include("${cmake_vars_file}")
|
||||
if (VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND NOT VCPKG_TARGET_IS_UWP)
|
||||
# Most of libyuv accelerated features need to be compiled by clang/gcc, so force use clang-cl, otherwise the performance is too poor.
|
||||
# Manually build the port with clang-cl when using MSVC as compiler
|
||||
|
||||
message(STATUS "Set compiler to clang-cl when using MSVC")
|
||||
|
||||
# https://github.com/microsoft/vcpkg/pull/10398
|
||||
set(VCPKG_POLICY_SKIP_ARCHITECTURE_CHECK enabled)
|
||||
|
||||
vcpkg_find_acquire_program(CLANG)
|
||||
if (CLANG MATCHES "-NOTFOUND")
|
||||
message(FATAL_ERROR "Clang is required.")
|
||||
endif ()
|
||||
get_filename_component(CLANG "${CLANG}" DIRECTORY)
|
||||
|
||||
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
|
||||
set(CLANG_TARGET "arm")
|
||||
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
|
||||
set(CLANG_TARGET "aarch64")
|
||||
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
|
||||
set(CLANG_TARGET "i686")
|
||||
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
|
||||
set(CLANG_TARGET "x86_64")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported target architecture")
|
||||
endif()
|
||||
|
||||
set(CLANG_TARGET "${CLANG_TARGET}-pc-windows-msvc")
|
||||
|
||||
message(STATUS "Using clang target ${CLANG_TARGET}")
|
||||
string(APPEND VCPKG_DETECTED_CMAKE_CXX_FLAGS --target=${CLANG_TARGET})
|
||||
string(APPEND VCPKG_DETECTED_CMAKE_C_FLAGS --target=${CLANG_TARGET})
|
||||
|
||||
set(BUILD_OPTIONS
|
||||
-DCMAKE_CXX_COMPILER=${CLANG}/clang-cl.exe
|
||||
-DCMAKE_C_COMPILER=${CLANG}/clang-cl.exe
|
||||
-DCMAKE_CXX_FLAGS=${VCPKG_DETECTED_CMAKE_CXX_FLAGS}
|
||||
-DCMAKE_C_FLAGS=${VCPKG_DETECTED_CMAKE_C_FLAGS})
|
||||
endif ()
|
||||
# END CLANG-CL HACK FOR MSVC
|
||||
|
||||
vcpkg_cmake_configure(
|
||||
SOURCE_PATH "${SOURCE_PATH}"
|
||||
OPTIONS
|
||||
${FEATURE_OPTIONS}
|
||||
OPTIONS_DEBUG
|
||||
-DBUILD_TOOLS=OFF
|
||||
)
|
||||
|
||||
vcpkg_cmake_install()
|
||||
vcpkg_cmake_config_fixup()
|
||||
if("tools" IN_LIST FEATURES)
|
||||
vcpkg_copy_tools(TOOL_NAMES yuvconvert yuvconstants AUTO_CLEAN)
|
||||
endif()
|
||||
|
||||
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")
|
||||
|
||||
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")
|
||||
# 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")
|
||||
5
thirdparty/overlay-ports/libyuv/usage
vendored
Normal file
5
thirdparty/overlay-ports/libyuv/usage
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
libyuv provides CMake targets:
|
||||
|
||||
# Unofficial config package and target from vcpkg
|
||||
find_package(libyuv CONFIG REQUIRED)
|
||||
target_link_libraries(main PRIVATE yuv)
|
||||
29
thirdparty/overlay-ports/libyuv/vcpkg.json
vendored
Normal file
29
thirdparty/overlay-ports/libyuv/vcpkg.json
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "libyuv",
|
||||
"version": "1896",
|
||||
"port-version": 1,
|
||||
"description": "libyuv is an open source project that includes YUV scaling and conversion functionality",
|
||||
"homepage": "https://chromium.googlesource.com/libyuv/libyuv",
|
||||
"license": null,
|
||||
"dependencies": [
|
||||
"libjpeg-turbo",
|
||||
{
|
||||
"name": "vcpkg-cmake",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake-config",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake-get-vars",
|
||||
"host": true
|
||||
}
|
||||
],
|
||||
"features": {
|
||||
"tools": {
|
||||
"description": "build command line tool",
|
||||
"supports": "!android & !ios & !xbox & !wasm32"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue