From f0441207c421af63e6f8015af583dd7f4a91b38a Mon Sep 17 00:00:00 2001 From: Dextinfire <> Date: Fri, 13 Dec 2024 17:32:20 -0800 Subject: [PATCH] build fix --- CMakeLists.txt | 15 +- avcpp.patch | 37 +++++ modules/FindFFMPEG.cmake | 190 ------------------------- src/audio/openal/ffmpegaudioplayer.cpp | 4 +- src/video/clock.h | 2 +- src/video/ffmpegplayer.cpp | 22 +-- src/video/ffmpegplayer.h | 4 +- src/video/ffmpegstream.h | 8 +- 8 files changed, 63 insertions(+), 219 deletions(-) create mode 100644 avcpp.patch delete mode 100644 modules/FindFFMPEG.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bc2e5bc..68f012f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1001,31 +1001,28 @@ if (NOT DEFINED IMPACTO_DISABLE_FFMPEG) ) if (NOT VCPKG_TOOLCHAIN) + set(AVCPP_PATCH git apply ${CMAKE_CURRENT_SOURCE_DIR}/avcpp.patch) FetchContent_Declare( avcpp GIT_REPOSITORY "https://github.com/h4tr3d/avcpp" GIT_TAG "v2.4.0" + PATCH_COMMAND ${AVCPP_PATCH} + UPDATE_DISCONNECTED 1 SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/avcpp SYSTEM - EXCLUDE_FROM_ALL ) - include(CMakePrintHelpers) - # Hack to get the header files to match vcpkg's dir structure - set(AVCPP_INCLUDE ${AvCpp_SOURCE_DIR}/inc/avcpp) FetchContent_MakeAvailable(avcpp) - file(GLOB_RECURSE AVCPP_HEADERS ${AvCpp_SOURCE_DIR}/src/*.h) - file(MAKE_DIRECTORY AVCPP_INCLUDE) - file(COPY ${AVCPP_HEADERS} DESTINATION ${AVCPP_INCLUDE}) - include_directories(${AVCPP_INCLUDE}/..) + list(APPEND Impacto_Libs - AvCpp + avcpp ) list(APPEND Impacto_Libs ${FFMPEG_LIBRARIES} ) include_directories(${FFMPEG_INCLUDE_DIRS}) + include_directories(${AvCpp_SOURCE_DIR}/src) else () find_package(avcpp CONFIG REQUIRED) diff --git a/avcpp.patch b/avcpp.patch new file mode 100644 index 00000000..01c343b0 --- /dev/null +++ b/avcpp.patch @@ -0,0 +1,37 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 732a4b2..d4a4ee1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -32,7 +32,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads) + + find_package(FFmpeg +- COMPONENTS AVCODEC AVFORMAT AVUTIL AVDEVICE AVFILTER SWSCALE SWRESAMPLE REQUIRED) ++ COMPONENTS AVCODEC AVFORMAT AVUTIL AVFILTER SWSCALE SWRESAMPLE REQUIRED) + + add_subdirectory(src) + +diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake +index 2746b39..91c9b56 100644 +--- a/cmake/FindFFmpeg.cmake ++++ b/cmake/FindFFmpeg.cmake +@@ -166,7 +166,6 @@ if (NOT FFMPEG_LIBRARIES) + # Check for all possible component. + find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h) + find_component(AVFORMAT libavformat avformat libavformat/avformat.h) +- find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h) + find_component(AVUTIL libavutil avutil libavutil/avutil.h) + find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h) + find_component(SWSCALE libswscale swscale libswscale/swscale.h) +diff --git a/src/ffmpeg.h b/src/ffmpeg.h +index 397204f..1bb9d10 100644 +--- a/src/ffmpeg.h ++++ b/src/ffmpeg.h +@@ -9,7 +9,6 @@ extern "C" + #include + #include + #include +-#include + #include + #include + #include diff --git a/modules/FindFFMPEG.cmake b/modules/FindFFMPEG.cmake deleted file mode 100644 index 2998dda1..00000000 --- a/modules/FindFFMPEG.cmake +++ /dev/null @@ -1,190 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. -# -#.rst: -# FindFFMPEG -# -------- -# -# Find the FFPMEG libraries -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# The following variables will be defined: -# -# ``FFMPEG_FOUND`` -# True if FFMPEG found on the local system -# -# ``FFMPEG_INCLUDE_DIRS`` -# Location of FFMPEG header files -# -# ``FFMPEG_LIBRARY_DIRS`` -# Location of FFMPEG libraries -# -# ``FFMPEG_LIBRARIES`` -# List of the FFMPEG libraries found -# -# - -include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) -include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake) -include(${CMAKE_ROOT}/Modules/CMakeFindDependencyMacro.cmake) - -set(FFMPEG_VERSION "4.2") - -find_dependency(Threads) - -if (OFF) - find_dependency(BZip2) - get_target_property(BZip2_LIBRARY_RELEASE BZip2::BZip2 IMPORTED_LOCATION_RELEASE) - get_target_property(BZip2_LIBRARY_DEBUG BZip2::BZip2 IMPORTED_LOCATION_DEBUG) - list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS "$<$:${BZip2_LIBRARY_DEBUG}>$<$:${BZip2_LIBRARY_RELEASE}>") -endif () - -if (OFF) - find_dependency(LibLZMA) - list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS "$<$:${LibLZMA_LIBRARY_DEBUG}>$<$:${LibLZMA_LIBRARY_RELEASE}>") -endif () - -# Platform dependent libraries required by FFMPEG -if (WIN32) - if (NOT CYGWIN) - list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS wsock32 ws2_32 Secur32 bcrypt) - endif () -else () - list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS m) -endif () - -if (NX) - find_dependency(BZip2) - get_target_property(BZip2_LIBRARY_RELEASE BZip2::BZip2 IMPORTED_LOCATION_RELEASE) - list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS "${BZip2_LIBRARY_RELEASE}") -endif () - -macro(FFMPEG_FIND varname shortname headername) - if (NOT FFMPEG_${varname}_INCLUDE_DIRS) - find_path(FFMPEG_${varname}_INCLUDE_DIRS NAMES lib${shortname}/${headername} ${headername} PATH_SUFFIXES ffmpeg) - endif () - if (NOT FFMPEG_${varname}_LIBRARY) - find_library(FFMPEG_${varname}_LIBRARY_RELEASE NAMES ${shortname} PATH_SUFFIXES ffmpeg ffmpeg/lib) - get_filename_component(FFMPEG_${varname}_LIBRARY_RELEASE_DIR ${FFMPEG_${varname}_LIBRARY_RELEASE} DIRECTORY) - find_library(FFMPEG_${varname}_LIBRARY_DEBUG NAMES ${shortname}d ${shortname} PATHS debug PATH_SUFFIXES ffmpeg ffmpeg/lib ffmpeg/debug/lib debug/ffmpeg/lib) - get_filename_component(FFMPEG_${varname}_LIBRARY_DEBUG_DIR ${FFMPEG_${varname}_LIBRARY_DEBUG} DIRECTORY) - select_library_configurations(FFMPEG_${varname}) - endif () - if (FFMPEG_${varname}_LIBRARY AND FFMPEG_${varname}_INCLUDE_DIRS) - set(FFMPEG_${varname}_FOUND 1) - list(APPEND FFMPEG_LIBRARY_DIRS ${FFMPEG_${varname}_LIBRARY_RELEASE_DIR} ${FFMPEG_${varname}_LIBRARY_DEBUG_DIR}) - endif () -endmacro(FFMPEG_FIND) - -macro(FFMPEG_FIND_GENEX varname shortname headername) - if (NOT FFMPEG_${varname}_INCLUDE_DIRS) - find_path(FFMPEG_${varname}_INCLUDE_DIRS NAMES lib${shortname}/${headername} ${headername} PATH_SUFFIXES ffmpeg) - endif () - if (NOT FFMPEG_${varname}_LIBRARY) - find_library(FFMPEG_${varname}_LIBRARY_RELEASE NAMES ${shortname} PATH_SUFFIXES ffmpeg ffmpeg/lib) - get_filename_component(FFMPEG_${varname}_LIBRARY_RELEASE_DIR ${FFMPEG_${varname}_LIBRARY_RELEASE} DIRECTORY) - find_library(FFMPEG_${varname}_LIBRARY_DEBUG NAMES ${shortname}d ${shortname} PATHS debug PATH_SUFFIXES ffmpeg ffmpeg/lib ffmpeg/debug/lib debug/ffmpeg/lib) - get_filename_component(FFMPEG_${varname}_LIBRARY_DEBUG_DIR ${FFMPEG_${varname}_LIBRARY_DEBUG} DIRECTORY) - set(FFMPEG_${varname}_LIBRARY "$<$:${FFMPEG_${varname}_LIBRARY_DEBUG}>$<$:${FFMPEG_${varname}_LIBRARY_RELEASE}>" CACHE STRING "") - set(FFMPEG_${varname}_LIBRARIES ${FFMPEG_${varname}_LIBRARY} CACHE STRING "") - endif () - if (FFMPEG_${varname}_LIBRARY AND FFMPEG_${varname}_INCLUDE_DIRS) - set(FFMPEG_${varname}_FOUND 1) - list(APPEND FFMPEG_LIBRARY_DIRS ${FFMPEG_${varname}_LIBRARY_RELEASE_DIR} ${FFMPEG_${varname}_LIBRARY_DEBUG_DIR}) - endif () -endmacro(FFMPEG_FIND_GENEX) - -if (WIN32) - FFMPEG_FIND_GENEX(libzlib zlib zlib.h) -else () - FFMPEG_FIND_GENEX(libzlib z zlib.h) -endif () - -if (APPLE) - find_library(VT_UNIT VideoToolbox) - if (NOT VT_UNIT) - message(FATAL_ERROR "VideoToolbox not found") - endif () - find_library(AT_UNIT AudioToolbox) - if (NOT AT_UNIT) - message(FATAL_ERROR "AudioToolbox not found") - endif () - find_library(SEC_UNIT Security) - if (NOT SEC_UNIT) - message(FATAL_ERROR "Security not found") - endif () - find_library(CF_UNIT CoreFoundation) - if (NOT CF_UNIT) - message(FATAL_ERROR "CoreFoundation not found") - endif () - find_library(CM_UNIT CoreMedia) - if (NOT CM_UNIT) - message(FATAL_ERROR "CoreMedia not found") - endif () - find_library(CV_UNIT CoreVideo) - if (NOT CV_UNIT) - message(FATAL_ERROR "CoreVideo not found") - endif () - find_package(Iconv QUIET) - list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${VT_UNIT} ${AT_UNIT} ${SEC_UNIT} ${CF_UNIT} ${CM_UNIT} ${CV_UNIT} ${Iconv_LIBRARIES}) -endif () - -FFMPEG_FIND(libavcodec avcodec avcodec.h) -FFMPEG_FIND(libavdevice avdevice avdevice.h) -FFMPEG_FIND(libavfilter avfilter avfilter.h) -FFMPEG_FIND(libavformat avformat avformat.h) -FFMPEG_FIND(libavresample avresample avresample.h) -FFMPEG_FIND(libavutil avutil avutil.h) -FFMPEG_FIND(libswresample swresample swresample.h) -FFMPEG_FIND(libswscale swscale swscale.h) - -if (FFMPEG_libavcodec_FOUND AND FFMPEG_libavfilter_FOUND AND FFMPEG_libavformat_FOUND AND FFMPEG_libavutil_FOUND AND FFMPEG_libswresample_FOUND AND FFMPEG_libswscale_FOUND AND FFMPEG_libzlib_FOUND) - list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_libavformat_INCLUDE_DIRS} ${FFMPEG_libavcodec_INCLUDE_DIRS} ${FFMPEG_libavutil_INCLUDE_DIRS} ${FFMPEG_libswscale_INCLUDE_DIRS}) - if (FFMPEG_libavdevice_FOUND) - list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_libavdevice_INCLUDE_DIRS}) - endif () - list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) - list(REMOVE_DUPLICATES FFMPEG_LIBRARY_DIRS) - - set(FFMPEG_libavcodec_VERSION "${FFMPEG_VERSION}" CACHE STRING "") - if (FFMPEG_libavdevice_FOUND) - set(FFMPEG_libavdevice_VERSION "${FFMPEG_VERSION}" CACHE STRING "") - endif () - set(FFMPEG_libavfilter_VERSION "${FFMPEG_VERSION}" CACHE STRING "") - set(FFMPEG_libavformat_VERSION "${FFMPEG_VERSION}" CACHE STRING "") - if (FFMPEG_libavresample_FOUND) - set(FFMPEG_libavresample_VERSION "${FFMPEG_VERSION}" CACHE STRING "") - endif () - set(FFMPEG_libavutil_VERSION "${FFMPEG_VERSION}" CACHE STRING "") - set(FFMPEG_libswresample_VERSION "${FFMPEG_VERSION}" CACHE STRING "") - set(FFMPEG_libswscale_VERSION "${FFMPEG_VERSION}" CACHE STRING "") - - if (FFMPEG_libavdevice_FOUND) - list(APPEND FFMPEG_LIBRARIES - ${FFMPEG_libavdevice_LIBRARY} - ) - endif () - list(APPEND FFMPEG_LIBRARIES - ${FFMPEG_libavfilter_LIBRARY} - ${FFMPEG_libavformat_LIBRARY} - ${FFMPEG_libswscale_LIBRARY} - ${FFMPEG_libavcodec_LIBRARY} - ${FFMPEG_libswresample_LIBRARY} - ${FFMPEG_libavutil_LIBRARY} - ${FFMPEG_libzlib_LIBRARY} - ${FFMPEG_PLATFORM_DEPENDENT_LIBS} - ) - if (FFMPEG_libavresample_FOUND) - list(APPEND FFMPEG_LIBRARIES - ${FFMPEG_libavresample_LIBRARY} - ) - endif () - set(FFMPEG_LIBRARY ${FFMPEG_LIBRARIES}) - - set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "") - set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "") - set(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBRARY_DIRS} CACHE STRING "") -endif () - -find_package_handle_standard_args(FFMPEG REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_LIBRARY_DIRS FFMPEG_INCLUDE_DIRS) diff --git a/src/audio/openal/ffmpegaudioplayer.cpp b/src/audio/openal/ffmpegaudioplayer.cpp index a26b98ac..43477a68 100644 --- a/src/audio/openal/ffmpegaudioplayer.cpp +++ b/src/audio/openal/ffmpegaudioplayer.cpp @@ -3,8 +3,8 @@ #include "../audiosystem.h" #include "al.h" #include -#include -#include +#include +#include extern "C" { #include diff --git a/src/video/clock.h b/src/video/clock.h index 417baa89..83e4d464 100644 --- a/src/video/clock.h +++ b/src/video/clock.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include namespace Impacto::Video { diff --git a/src/video/ffmpegplayer.cpp b/src/video/ffmpegplayer.cpp index e4e5c28d..4a2ddf40 100644 --- a/src/video/ffmpegplayer.cpp +++ b/src/video/ffmpegplayer.cpp @@ -1,16 +1,16 @@ #include "ffmpegplayer.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #include #include diff --git a/src/video/ffmpegplayer.h b/src/video/ffmpegplayer.h index 421fada4..ed6b9396 100644 --- a/src/video/ffmpegplayer.h +++ b/src/video/ffmpegplayer.h @@ -1,6 +1,6 @@ #pragma once -#include -#include +#include +#include #include #include #include diff --git a/src/video/ffmpegstream.h b/src/video/ffmpegstream.h index 1cc4d544..1fc94153 100644 --- a/src/video/ffmpegstream.h +++ b/src/video/ffmpegstream.h @@ -1,10 +1,10 @@ #pragma once #include -#include -#include -#include -#include +#include +#include +#include +#include #include "../impacto.h" #include "clock.h"