mirror of
https://github.com/panda3d/panda3d.git
synced 2026-02-07 07:38:55 -06:00
cmake: Add FFMPEG compilation support.
This commit is contained in:
93
cmake/modules/FindFFMPEG.cmake
Normal file
93
cmake/modules/FindFFMPEG.cmake
Normal file
@@ -0,0 +1,93 @@
|
||||
# Filename: FindFFMPEG.cmake
|
||||
# Author: CFSworks (10 Apr, 2014)
|
||||
#
|
||||
# Usage:
|
||||
# find_package(FFMPEG [REQUIRED] [QUIET])
|
||||
#
|
||||
# Once done this will define:
|
||||
# FFMPEG_FOUND - system has ffmpeg
|
||||
# FFMPEG_INCLUDE_DIR - the ffmpeg include directory
|
||||
# FFMPEG_LIBRARIES - the path to the library binary
|
||||
#
|
||||
# FFMPEG_LIBAVCODEC - the path to the libavcodec library binary
|
||||
# FFMPEG_LIBAVFORMAT - the path to the libavformat library binary
|
||||
# FFMPEG_LIBAVUTIL - the path to the libavutil library binary
|
||||
#
|
||||
|
||||
if(NOT FFMPEG_INCLUDE_DIR OR NOT FFMPEG_LIBRARY_DIR)
|
||||
# Find the libffmpeg include files
|
||||
find_path(FFMPEG_INCLUDE_DIR
|
||||
NAMES "libavcodec/avcodec.h"
|
||||
PATHS "/usr/include"
|
||||
"/usr/local/include"
|
||||
"/sw/include"
|
||||
"/opt/include"
|
||||
"/opt/local/include"
|
||||
"/opt/csw/include"
|
||||
PATH_SUFFIXES "libav" "ffmpeg"
|
||||
)
|
||||
|
||||
# Find the libavcodec library
|
||||
find_library(FFMPEG_LIBAVCODEC
|
||||
NAMES "avcodec"
|
||||
PATHS "/usr"
|
||||
"/usr/local"
|
||||
"/usr/freeware"
|
||||
"/sw"
|
||||
"/opt"
|
||||
"/opt/csw"
|
||||
PATH_SUFFIXES "lib" "lib32" "lib64"
|
||||
)
|
||||
|
||||
# Find the libavformat library
|
||||
find_library(FFMPEG_LIBAVFORMAT
|
||||
NAMES "avformat"
|
||||
PATHS "/usr"
|
||||
"/usr/local"
|
||||
"/usr/freeware"
|
||||
"/sw"
|
||||
"/opt"
|
||||
"/opt/csw"
|
||||
PATH_SUFFIXES "lib" "lib32" "lib64"
|
||||
)
|
||||
|
||||
# Find the libavutil library
|
||||
find_library(FFMPEG_LIBAVUTIL
|
||||
NAMES "avutil"
|
||||
PATHS "/usr"
|
||||
"/usr/local"
|
||||
"/usr/freeware"
|
||||
"/sw"
|
||||
"/opt"
|
||||
"/opt/csw"
|
||||
PATH_SUFFIXES "lib" "lib32" "lib64"
|
||||
)
|
||||
|
||||
mark_as_advanced(FFMPEG_INCLUDE_DIR)
|
||||
mark_as_advanced(FFMPEG_LIBAVCODEC)
|
||||
mark_as_advanced(FFMPEG_LIBAVFORMAT)
|
||||
mark_as_advanced(FFMPEG_LIBAVUTIL)
|
||||
endif()
|
||||
|
||||
# Translate library into library directory
|
||||
if(FFMPEG_LIBAVCODEC)
|
||||
unset(FFMPEG_LIBRARY_DIR CACHE)
|
||||
get_filename_component(FFMPEG_LIBRARY_DIR "${FFMPEG_LIBAVCODEC}" PATH)
|
||||
set(FFMPEG_LIBRARY_DIR "${FFMPEG_LIBRARY_DIR}" CACHE PATH "The path to libffmpeg's library directory.") # Library path
|
||||
endif()
|
||||
|
||||
set(FFMPEG_LIBRARIES)
|
||||
if(FFMPEG_LIBAVCODEC)
|
||||
list(APPEND FFMPEG_LIBRARIES "${FFMPEG_LIBAVCODEC}")
|
||||
endif()
|
||||
if(FFMPEG_LIBAVFORMAT)
|
||||
list(APPEND FFMPEG_LIBRARIES "${FFMPEG_LIBAVFORMAT}")
|
||||
endif()
|
||||
if(FFMPEG_LIBAVUTIL)
|
||||
list(APPEND FFMPEG_LIBRARIES "${FFMPEG_LIBAVUTIL}")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(FFMPEG_LIBRARY_DIR)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(FFMPEG DEFAULT_MSG FFMPEG_LIBRARIES FFMPEG_LIBAVCODEC FFMPEG_LIBAVFORMAT FFMPEG_LIBAVUTIL FFMPEG_INCLUDE_DIR FFMPEG_LIBRARY_DIR)
|
||||
52
cmake/modules/FindSWResample.cmake
Normal file
52
cmake/modules/FindSWResample.cmake
Normal file
@@ -0,0 +1,52 @@
|
||||
# Filename: FindSWResample.cmake
|
||||
# Author: CFSworks (10 Apr, 2014)
|
||||
#
|
||||
# Usage:
|
||||
# find_package(SWResample [REQUIRED] [QUIET])
|
||||
#
|
||||
# Once done this will define:
|
||||
# SWRESAMPLE_FOUND - system has ffmpeg's libswresample
|
||||
# SWRESAMPLE_INCLUDE_DIR - the libswresample include directory
|
||||
# SWRESAMPLE_LIBRARY - the path to the library binary
|
||||
#
|
||||
|
||||
if(NOT SWRESAMPLE_INCLUDE_DIR OR NOT SWRESAMPLE_LIBRARY)
|
||||
# Find the libswresample include files
|
||||
find_path(SWRESAMPLE_INCLUDE_DIR
|
||||
NAMES "libswresample/swresample.h"
|
||||
PATHS "/usr/include"
|
||||
"/usr/local/include"
|
||||
"/sw/include"
|
||||
"/opt/include"
|
||||
"/opt/local/include"
|
||||
"/opt/csw/include"
|
||||
PATH_SUFFIXES "libav" "ffmpeg"
|
||||
)
|
||||
|
||||
# Find the libswresample library
|
||||
find_library(SWRESAMPLE_LIBRARY
|
||||
NAMES "swresample"
|
||||
PATHS "/usr"
|
||||
"/usr/local"
|
||||
"/usr/freeware"
|
||||
"/sw"
|
||||
"/opt"
|
||||
"/opt/csw"
|
||||
PATH_SUFFIXES "lib" "lib32" "lib64"
|
||||
)
|
||||
|
||||
mark_as_advanced(SWRESAMPLE_INCLUDE_DIR)
|
||||
mark_as_advanced(SWRESAMPLE_LIBRARY)
|
||||
endif()
|
||||
|
||||
# Translate library into library directory
|
||||
if(SWRESAMPLE_LIBRARY)
|
||||
unset(SWRESAMPLE_LIBRARY_DIR CACHE)
|
||||
get_filename_component(SWRESAMPLE_LIBRARY_DIR "${SWRESAMPLE_LIBRARY}" PATH)
|
||||
set(SWRESAMPLE_LIBRARY_DIR "${SWRESAMPLE_LIBRARY_DIR}" CACHE PATH "The path to libffmpeg's library directory.") # Library path
|
||||
endif()
|
||||
|
||||
mark_as_advanced(SWRESAMPLE_LIBRARY_DIR)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SWResample DEFAULT_MSG SWRESAMPLE_LIBRARY SWRESAMPLE_INCLUDE_DIR SWRESAMPLE_LIBRARY_DIR)
|
||||
52
cmake/modules/FindSWScale.cmake
Normal file
52
cmake/modules/FindSWScale.cmake
Normal file
@@ -0,0 +1,52 @@
|
||||
# Filename: FindSWScale.cmake
|
||||
# Author: CFSworks (10 Apr, 2014)
|
||||
#
|
||||
# Usage:
|
||||
# find_package(SWScale [REQUIRED] [QUIET])
|
||||
#
|
||||
# Once done this will define:
|
||||
# SWSCALE_FOUND - system has ffmpeg's libswscale
|
||||
# SWSCALE_INCLUDE_DIR - the libswscale include directory
|
||||
# SWSCALE_LIBRARY - the path to the library binary
|
||||
#
|
||||
|
||||
if(NOT SWSCALE_INCLUDE_DIR OR NOT SWSCALE_LIBRARY)
|
||||
# Find the libswscale include files
|
||||
find_path(SWSCALE_INCLUDE_DIR
|
||||
NAMES "libswscale/swscale.h"
|
||||
PATHS "/usr/include"
|
||||
"/usr/local/include"
|
||||
"/sw/include"
|
||||
"/opt/include"
|
||||
"/opt/local/include"
|
||||
"/opt/csw/include"
|
||||
PATH_SUFFIXES "libav" "ffmpeg"
|
||||
)
|
||||
|
||||
# Find the libswscale library
|
||||
find_library(SWSCALE_LIBRARY
|
||||
NAMES "swscale"
|
||||
PATHS "/usr"
|
||||
"/usr/local"
|
||||
"/usr/freeware"
|
||||
"/sw"
|
||||
"/opt"
|
||||
"/opt/csw"
|
||||
PATH_SUFFIXES "lib" "lib32" "lib64"
|
||||
)
|
||||
|
||||
mark_as_advanced(SWSCALE_INCLUDE_DIR)
|
||||
mark_as_advanced(SWSCALE_LIBRARY)
|
||||
endif()
|
||||
|
||||
# Translate library into library directory
|
||||
if(SWSCALE_LIBRARY)
|
||||
unset(SWSCALE_LIBRARY_DIR CACHE)
|
||||
get_filename_component(SWSCALE_LIBRARY_DIR "${SWSCALE_LIBRARY}" PATH)
|
||||
set(SWSCALE_LIBRARY_DIR "${SWSCALE_LIBRARY_DIR}" CACHE PATH "The path to libffmpeg's library directory.") # Library path
|
||||
endif()
|
||||
|
||||
mark_as_advanced(SWSCALE_LIBRARY_DIR)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SWSCALE DEFAULT_MSG SWSCALE_LIBRARY SWSCALE_INCLUDE_DIR SWSCALE_LIBRARY_DIR)
|
||||
@@ -591,6 +591,18 @@ find_package(ZLIB)
|
||||
package_option(ZLIB DEFAULT ON
|
||||
"Enables support for compression of Panda assets.")
|
||||
|
||||
# Is FFMPEG installed, and where?
|
||||
find_package(FFMPEG)
|
||||
find_package(SWScale)
|
||||
find_package(SWResample)
|
||||
|
||||
package_option(FFMPEG DEFAULT ON
|
||||
"Enables support for audio- and video-decoding using the FFMPEG library.")
|
||||
package_option(SWSCALE DEFAULT ON
|
||||
"Enables support for FFMPEG's libswscale for video rescaling.")
|
||||
package_option(SWRESAMPLE DEFAULT ON
|
||||
"Enables support for FFMPEG's libresample for audio resampling.")
|
||||
|
||||
# Is ODE installed, and where?
|
||||
find_package(ODE)
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ add_subdirectory(src/wgldisplay)
|
||||
add_subdirectory(src/osxdisplay)
|
||||
add_subdirectory(src/cocoadisplay)
|
||||
add_subdirectory(src/movies)
|
||||
add_subdirectory(src/ffmpeg)
|
||||
add_subdirectory(src/audio)
|
||||
add_subdirectory(src/audiotraits)
|
||||
add_subdirectory(src/chan)
|
||||
|
||||
26
panda/src/ffmpeg/CMakeLists.txt
Normal file
26
panda/src/ffmpeg/CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
if(HAVE_FFMPEG)
|
||||
|
||||
set(P3FFMPEG_HEADERS
|
||||
config_ffmpeg.h
|
||||
ffmpegVideo.h ffmpegVideo.I
|
||||
ffmpegVideoCursor.h ffmpegVideoCursor.I
|
||||
ffmpegAudio.h ffmpegAudio.I
|
||||
ffmpegAudioCursor.h ffmpegAudioCursor.I
|
||||
ffmpegVirtualFile.h ffmpegVirtualFile.I)
|
||||
|
||||
|
||||
set(P3FFMPEG_SOURCES
|
||||
config_ffmpeg.cxx
|
||||
ffmpegVideo.cxx
|
||||
ffmpegVideoCursor.cxx
|
||||
ffmpegAudio.cxx
|
||||
ffmpegAudioCursor.cxx
|
||||
ffmpegVirtualFile.cxx)
|
||||
|
||||
composite_sources(p3ffmpeg P3FFMPEG_SOURCES)
|
||||
add_library(p3ffmpeg ${P3FFMPEG_HEADERS} ${P3FFMPEG_SOURCES})
|
||||
target_link_libraries(p3ffmpeg p3movies)
|
||||
target_use_packages(p3ffmpeg FFMPEG SWSCALE SWRESAMPLE)
|
||||
|
||||
install(TARGETS p3ffmpeg DESTINATION lib)
|
||||
endif()
|
||||
Reference in New Issue
Block a user