summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgaa-cifasis <gg@cifasis-conicet.gov.ar>2018-02-18 18:30:27 -0300
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-20 03:56:20 +0200
commit7aea1acf4490b7d68f6915cf63d28c1f18b49b5d (patch)
treeae142ab30c54b3992bd79973ebe3d0deffafb6d0
parent5673c1665a2c6d7fdaf1a20d554bb135a20c7bc8 (diff)
added libav to cmake
-rw-r--r--CMakeFFmpegLibavMacros.cmake65
-rw-r--r--CMakeLists.txt9
-rw-r--r--FindLibAV.cmake87
3 files changed, 161 insertions, 0 deletions
diff --git a/CMakeFFmpegLibavMacros.cmake b/CMakeFFmpegLibavMacros.cmake
new file mode 100644
index 0000000..06105c6
--- /dev/null
+++ b/CMakeFFmpegLibavMacros.cmake
@@ -0,0 +1,65 @@
+#-------------------------------------------------------------------
+# FindFFmpeg.cmake and FindLibAV.cmake are dependent on this file.
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file
+#
+#-------------------------------------------------------------------
+
+### Macro: set_component_found
+#
+# Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present.
+#
+macro(set_component_found _component )
+ if(${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS)
+ # message(STATUS " - ${_component} found.")
+ set(${_component}_FOUND TRUE)
+ else()
+ # message(STATUS " - ${_component} not found.")
+ endif()
+endmacro()
+
+#
+### Macro: find_component
+#
+# Finds each component's library file and include directory, and sets
+# *_LIBRARIES and *_INCLUDE_DIRS accordingly. Additionally detects each
+# component's version and sets *_VERSION_STRING.
+#
+macro(find_component _component _library _header _version)
+ find_path(${_component}_INCLUDE_DIRS ${_header}
+ PATH_SUFFIXES
+ ffmpeg
+ libav
+ include
+ )
+
+ find_library(${_component}_LIBRARIES
+ NAMES ${_library}
+ PATH_SUFFIXES
+ lib
+ )
+
+ if(${_component}_INCLUDE_DIRS AND EXISTS "${${_component}_INCLUDE_DIRS}/${_version}")
+ file(STRINGS "${${_component}_INCLUDE_DIRS}/${_version}" ${_component}_VERSION_MAJOR_LINE REGEX "^#define[ \t]+LIB${_component}_VERSION_MAJOR[ \t]+[0-9]+$")
+ file(STRINGS "${${_component}_INCLUDE_DIRS}/${_version}" ${_component}_VERSION_MINOR_LINE REGEX "^#define[ \t]+LIB${_component}_VERSION_MINOR[ \t]+[0-9]+$")
+ file(STRINGS "${${_component}_INCLUDE_DIRS}/${_version}" ${_component}_VERSION_PATCH_LINE REGEX "^#define[ \t]+LIB${_component}_VERSION_MICRO[ \t]+[0-9]+$")
+ string(REGEX REPLACE "^#define[ \t]+LIB${_component}_VERSION_MAJOR[ \t]+([0-9]+)$" "\\1" ${_component}_VERSION_MAJOR "${${_component}_VERSION_MAJOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+LIB${_component}_VERSION_MINOR[ \t]+([0-9]+)$" "\\1" ${_component}_VERSION_MINOR "${${_component}_VERSION_MINOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+LIB${_component}_VERSION_MICRO[ \t]+([0-9]+)$" "\\1" ${_component}_VERSION_PATCH "${${_component}_VERSION_PATCH_LINE}")
+ set(${_component}_VERSION_STRING ${${_component}_VERSION_MAJOR}.${${_component}_VERSION_MINOR}.${${_component}_VERSION_PATCH})
+ unset(${_component}_VERSION_MAJOR_LINE)
+ unset(${_component}_VERSION_MINOR_LINE)
+ unset(${_component}_VERSION_PATCH_LINE)
+ unset(${_component}_VERSION_MAJOR)
+ unset(${_component}_VERSION_MINOR)
+ unset(${_component}_VERSION_PATCH)
+ endif()
+
+ find_package_handle_standard_args(${_component}
+ REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS
+ VERSION_VAR ${_component}_VERSION_STRING
+ )
+
+ set_component_found(${_component})
+endmacro()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e585edb..1ae2a49 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,4 @@
+
# Aliens vs Predator Linux - http://icculus.org/avp/
# CMake 2.8 project
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
@@ -44,6 +45,7 @@ ENDIF(AVP_WEB)
IF(NOT AVP_WEB)
INCLUDE(FindOpenGLES2.cmake)
INCLUDE(FindSDL2.cmake)
+ INCLUDE(FindLibAV.cmake)
INCLUDE(FindSDL)
INCLUDE(FindOpenGL)
INCLUDE(FindOpenAL)
@@ -151,6 +153,7 @@ IF(NOT AVP_WEB)
ENDIF(NOT AVP_WEB)
# required source files
+LIST(APPEND source src/bink.c)
LIST(APPEND source src/stubs.c)
LIST(APPEND source src/version.c)
LIST(APPEND source src/mathline.c)
@@ -462,4 +465,10 @@ IF(NOT AVP_WEB)
ENDIF(OPENGL_TYPE STREQUAL "OPENGLES2")
TARGET_LINK_LIBRARIES(avp ${OPENAL_LIBRARY})
+ TARGET_LINK_LIBRARIES(avp ${LIBAV_LIBRARIES})
+ TARGET_LINK_LIBRARIES(avp ${SWSCALE_LIBRARIES})
+ TARGET_LINK_LIBRARIES(avp ${AVCODEC_LIBRARIES})
+
+
+
ENDIF(NOT AVP_WEB)
diff --git a/FindLibAV.cmake b/FindLibAV.cmake
new file mode 100644
index 0000000..26b5c14
--- /dev/null
+++ b/FindLibAV.cmake
@@ -0,0 +1,87 @@
+# vim: ts=2 sw=2
+# - Try to find the required libav components(default: AVFORMAT, AVUTIL, AVCODEC)
+#
+# Once done this will define
+# LIBAV_FOUND - System has the all required components.
+# LIBAV_INCLUDE_DIRS - Include directory necessary for using the required components headers.
+# LIBAV_LIBRARIES - Link these to use the required libav components.
+#
+# For each of the components it will additionally set.
+# - AVCODEC
+# - AVDEVICE
+# - AVFILTER
+# - AVFORMAT
+# - AVRESAMPLE
+# - AVUTIL
+# - SWSCALE
+# the following variables will be defined
+# <component>_FOUND - System has <component>
+# <component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers
+# <component>_LIBRARIES - Link these to use <component>
+# <component>_VERSION_STRING - The component's version
+#
+# Copyright (c) 2006, Matthias Kretz, <kretz@kde.org>
+# Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org>
+# Copyright (c) 2011, Michael Jansen, <kde@michael-jansen.biz>
+# Copyright (c) 2013,2015 Stephen Baker <baker.stephen.e@gmail.com>
+# Copyright (c) 2015, Alexander Bessman
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+include(FindPackageHandleStandardArgs)
+include(${CMAKE_CURRENT_LIST_DIR}/CMakeFFmpegLibavMacros.cmake)
+
+# The default components were taken from a survey over other FindLIBAV.cmake files
+if(NOT LibAV_FIND_COMPONENTS)
+ set(LibAV_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL)
+endif()
+
+# Check for cached results. If there are skip the costly part.
+if(NOT LIBAV_LIBRARIES)
+
+ # Check for all possible component.
+ find_component(AVCODEC avcodec libavcodec/avcodec.h libavcodec/version.h)
+ find_component(AVFORMAT avformat libavformat/avformat.h libavformat/version.h)
+ find_component(AVDEVICE avdevice libavdevice/avdevice.h libavdevice/version.h)
+ find_component(AVFILTER avfilter libavfilter/avfilter.h libavfilter/version.h)
+ find_component(AVRESAMPLE avresample libavresample/avresample.h libavresample/version.h)
+ find_component(AVUTIL avutil libavutil/avutil.h libavutil/version.h)
+ find_component(SWSCALE swscale libswscale/swscale.h libswscale/version.h)
+
+ # Check if the required components were found and add their stuff to the LIBAV_* vars.
+ foreach(_component ${LibAV_FIND_COMPONENTS})
+ if(${_component}_FOUND)
+ # message(STATUS "Required component ${_component} present.")
+ set(LIBAV_LIBRARIES ${LIBAV_LIBRARIES} ${${_component}_LIBRARIES})
+ list(APPEND LIBAV_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS})
+ else()
+ # message(STATUS "Required component ${_component} missing.")
+ endif()
+ endforeach()
+
+ # Build the include path with duplicates removed.
+ if(LIBAV_INCLUDE_DIRS)
+ list(REMOVE_DUPLICATES LIBAV_INCLUDE_DIRS)
+ endif()
+
+ # cache the vars.
+ set(LIBAV_INCLUDE_DIRS ${LIBAV_INCLUDE_DIRS} CACHE STRING "The LibAV include directories." FORCE)
+ set(LIBAV_LIBRARIES ${LIBAV_LIBRARIES} CACHE STRING "The LibAV libraries." FORCE)
+
+ mark_as_advanced(LIBAV_INCLUDE_DIRS LIBAV_LIBRARIES)
+endif()
+
+# Now set the noncached _FOUND vars for the components.
+foreach(_component AVCODEC AVDEVICE AVFILTER AVFORMAT AVRESAMPLE AVUTIL SWSCALE)
+ set_component_found(${_component})
+endforeach()
+
+# Compile the list of required vars
+set(_LibAV_REQUIRED_VARS LIBAV_LIBRARIES LIBAV_INCLUDE_DIRS)
+foreach(_component ${LibAV_FIND_COMPONENTS})
+ list(APPEND _LibAV_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS)
+endforeach()
+
+# Give a nice error message if some of the required vars are missing.
+find_package_handle_standard_args(LibAV DEFAULT_MSG ${_LibAV_REQUIRED_VARS})