Commit ed067864 authored by Aashish Chaudhary's avatar Aashish Chaudhary

Support external installation of FFMPEG

* Removed unused variables from the Find package
* Using a macro for code reuse
* Added new variable that could be set to specify path to FFMPEG

Conflicts:
	CMake/FindFFMPEG.cmake
	IO/FFMPEG/CMakeLists.txt

VTK needs toplevel include directory

Conflicts:
	CMake/FindFFMPEG.cmake

Updated find ffmpeg test to use newer variables

(cherry picked from commit f568fa74c32202c44a07fcec389951c64ad3b15c)

Conflicts:
	IO/FFMPEG/CMakeLists.txt

Fixed wrong variable name (typo)
parent 582dd5c8
Pipeline #8043 passed with stage
# #
# Find the native FFMPEG includes and library # Find the native FFMPEG includes and library
#
# This module defines # This module defines
# FFMPEG_INCLUDE_DIR, where to find avcodec.h, avformat.h ... # FFMPEG_INCLUDE_DIR, where to find avcodec.h, avformat.h ...
# FFMPEG_LIBRARIES, the libraries to link against to use FFMPEG. # FFMPEG_LIBRARIES, the libraries to link against to use FFMPEG.
# FFMPEG_FOUND, If false, do not try to use FFMPEG. # FFMPEG_FOUND, If false, do not try to use FFMPEG.
# FFMPEG_ROOT, if this module use this path to find FFMPEG headers
# also defined, but not for general use are # and libraries.
# FFMPEG_avformat_LIBRARY and FFMPEG_avcodec_LIBRARY, where to find the FFMPEG library.
# This is useful to do it this way so that we can always add more libraries # Macro to find header and lib directories
# if needed to FFMPEG_LIBRARIES if ffmpeg ever changes... # example: FFMPEG_FIND(AVFORMAT avformat avformat.h)
MACRO(FFMPEG_FIND varname shortname headername)
# If the FFMPEG headers are all in one directory. # old version of ffmpeg put header in $prefix/include/[ffmpeg]
find_path(FFMPEG_INCLUDE_DIR avformat.h # so try to find header in include directory
PATHS FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
$ENV{FFMPEG_DIR}/include PATHS
$ENV{OSGDIR}/include ${FFMPEG_ROOT}/include/lib${shortname}
$ENV{OSG_ROOT}/include $ENV{FFMPEG_DIR}/include/lib${shortname}
~/Library/Frameworks ~/Library/Frameworks/lib${shortname}
/Library/Frameworks /Library/Frameworks/lib${shortname}
/usr/local/include /usr/local/include/lib${shortname}
/usr/include /usr/include/lib${shortname}
/sw/include # Fink /sw/include/lib${shortname} # Fink
/opt/local/include # DarwinPorts /opt/local/include/lib${shortname} # DarwinPorts
/opt/csw/include # Blastwave /opt/csw/include/lib${shortname} # Blastwave
/opt/include /opt/include/lib${shortname}
/usr/freeware/include /usr/freeware/include/lib${shortname}
PATH_SUFFIXES ffmpeg PATH_SUFFIXES ffmpeg
DOC "Location of FFMPEG Headers" DOC "Location of FFMPEG Headers"
) )
# If the FFMPEG headers are separated to each of libavformat, libavcodec etc.. FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
if(NOT FFMPEG_INCLUDE_DIR) PATHS
find_path(FFMPEG_INCLUDE_DIR libavformat/avformat.h ${FFMPEG_ROOT}/include
PATHS $ENV{FFMPEG_DIR}/include
$ENV{FFMPEG_DIR}/include ~/Library/Frameworks
$ENV{OSGDIR}/include /Library/Frameworks
$ENV{OSG_ROOT}/include /usr/local/include
~/Library/Frameworks /usr/include
/Library/Frameworks /sw/include # Fink
/usr/local/include /opt/local/include # DarwinPorts
/usr/include /opt/csw/include # Blastwave
/sw/include # Fink /opt/include
/opt/local/include # DarwinPorts /usr/freeware/include
/opt/csw/include # Blastwave PATH_SUFFIXES ffmpeg
/opt/include DOC "Location of FFMPEG Headers"
/usr/freeware/include )
PATH_SUFFIXES ffmpeg
DOC "Location of FFMPEG Headers" FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES
) NAMES ${shortname}
endif() PATHS
${FFMPEG_ROOT}/lib
# We want the -I include line to use the parent directory of FFMPEG, it $ENV{FFMPEG_DIR}/lib
# uses relative includes such as <ffmpeg/avformat.h> or <libavcodec/avformat.h> ~/Library/Frameworks
get_filename_component(FFMPEG_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR} ABSOLUTE) /Library/Frameworks
/usr/local/lib
find_library(FFMPEG_avformat_LIBRARY avformat /usr/local/lib64
/usr/local/lib /usr/lib
/usr/lib /usr/lib64
) /sw/lib
/opt/local/lib
find_library(FFMPEG_avcodec_LIBRARY avcodec /opt/csw/lib
/usr/local/lib /opt/lib
/usr/lib /usr/freeware/lib64
) DOC "Location of FFMPEG Libraries"
)
find_library(FFMPEG_avutil_LIBRARY avutil
/usr/local/lib IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
/usr/lib SET(FFMPEG_${varname}_FOUND 1)
) ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
find_library(FFMPEG_vorbis_LIBRARY vorbis ENDMACRO(FFMPEG_FIND)
/usr/local/lib
/usr/lib SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG")
)
# find stdint.h
find_library(FFMPEG_dc1394_LIBRARY dc1394_control IF(WIN32)
/usr/local/lib
/usr/lib FIND_PATH(FFMPEG_STDINT_INCLUDE_DIR stdint.h
) PATHS
${FFMPEG_ROOT}/include
find_library(FFMPEG_vorbisenc_LIBRARY vorbisenc $ENV{FFMPEG_DIR}/include
/usr/local/lib ~/Library/Frameworks
/usr/lib /Library/Frameworks
) /usr/local/include
/usr/include
find_library(FFMPEG_theora_LIBRARY theora /sw/include # Fink
/usr/local/lib /opt/local/include # DarwinPorts
/usr/lib /opt/csw/include # Blastwave
) /opt/include
/usr/freeware/include
find_library(FFMPEG_dts_LIBRARY dts PATH_SUFFIXES ffmpeg
/usr/local/lib DOC "Location of FFMPEG stdint.h Header"
/usr/lib )
)
IF (FFMPEG_STDINT_INCLUDE_DIR)
find_library(FFMPEG_gsm_LIBRARY gsm SET(STDINT_OK TRUE)
/usr/local/lib ENDIF()
/usr/lib
) ELSE()
find_library(FFMPEG_swscale_LIBRARY swscale SET(STDINT_OK TRUE)
/usr/local/lib
/usr/lib ENDIF()
)
FFMPEG_FIND(LIBAVFORMAT avformat avformat.h)
find_library(FFMPEG_z_LIBRARY z FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h)
/usr/local/lib FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h)
/usr/lib FFMPEG_FIND(LIBAVUTIL avutil avutil.h)
) FFMPEG_FIND(LIBSWSCALE swscale swscale.h) # not sure about the header to look for here.
unset(FFMPEG_LIBRARIES) SET(FFMPEG_FOUND "NO")
if(FFMPEG_INCLUDE_DIR AND FFMPEG_avformat_LIBRARY AND FFMPEG_avcodec_LIBRARY # Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional.
AND FFMPEG_avutil_LIBRARY) IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND
set(FFMPEG_FOUND TRUE) FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND STDINT_OK)
set(FFMPEG_BASIC_LIBRARIES
${FFMPEG_avcodec_LIBRARY} SET(FFMPEG_FOUND "YES")
${FFMPEG_avformat_LIBRARY}
${FFMPEG_avutil_LIBRARY} SET(FFMPEG_INCLUDE_DIR ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
)
SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS})
# swscale is always a part of newer ffmpeg distros
if(FFMPEG_swscale_LIBRARY) # Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here,
list(APPEND FFMPEG_BASIC_LIBRARIES ${FFMPEG_swscale_LIBRARY}) # it will be added if found later.
endif() SET(FFMPEG_LIBRARIES
${FFMPEG_LIBAVFORMAT_LIBRARIES}
set(FFMPEG_LIBRARIES ${FFMPEG_BASIC_LIBRARIES}) ${FFMPEG_LIBAVDEVICE_LIBRARIES}
${FFMPEG_LIBAVCODEC_LIBRARIES}
if(FFMPEG_vorbis_LIBRARY) ${FFMPEG_LIBAVUTIL_LIBRARIES}
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_vorbis_LIBRARY}) ${FFMPEG_LIBSWSCALE_LIBRARIES})
endif() ELSE ()
if(FFMPEG_dc1394_LIBRARY) # MESSAGE(STATUS "Could not find FFMPEG")
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_dc1394_LIBRARY})
endif() ENDIF()
if(FFMPEG_vorbisenc_LIBRARY)
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_vorbisenc_LIBRARY})
endif()
if(FFMPEG_theora_LIBRARY)
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_theora_LIBRARY})
endif()
if(FFMPEG_dts_LIBRARY)
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_dts_LIBRARY})
endif()
if(FFMPEG_gsm_LIBRARY)
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_gsm_LIBRARY})
endif()
if(FFMPEG_z_LIBRARY)
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_z_LIBRARY})
endif()
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE INTERNAL "All presently found FFMPEG libraries.")
endif()
mark_as_advanced(
FFMPEG_INCLUDE_DIR
FFMPEG_avformat_LIBRARY
FFMPEG_avcodec_LIBRARY
FFMPEG_avutil_LIBRARY
FFMPEG_vorbis_LIBRARY
FFMPEG_dc1394_LIBRARY
FFMPEG_vorbisenc_LIBRARY
FFMPEG_theora_LIBRARY
FFMPEG_dts_LIBRARY
FFMPEG_gsm_LIBRARY
FFMPEG_swscale_LIBRARY
FFMPEG_z_LIBRARY
)
...@@ -24,10 +24,10 @@ if(FFMPEG_INCLUDE_DIR) ...@@ -24,10 +24,10 @@ if(FFMPEG_INCLUDE_DIR)
include(CheckCSourceCompiles) include(CheckCSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${FFMPEG_INCLUDE_DIR}) set(CMAKE_REQUIRED_INCLUDES ${FFMPEG_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_avformat_LIBRARY} set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBAVFORMAT_LIBRARIES}
${FFMPEG_avutil_LIBRARY} ${FFMPEG_avcodec_LIBRARY}) ${FFMPEG_LIBAVUTIL_LIBRARIES} ${FFMPEG_LIBAVCODEC_LIBRARIES})
if(NOT DEFINED VTK_FFMPEG_HAS_IMG_CONVERT AND FFMPEG_avcodec_LIBRARY) if(NOT DEFINED VTK_FFMPEG_HAS_IMG_CONVERT AND FFMPEG_LIBAVCODEC_LIBRARIES)
set(_source " set(_source "
#include <${FFMEG_CODEC_HEADER_PATH}/avcodec.h> #include <${FFMEG_CODEC_HEADER_PATH}/avcodec.h>
int main() int main()
...@@ -40,7 +40,7 @@ int main() ...@@ -40,7 +40,7 @@ int main()
check_c_source_compiles("${_source}" VTK_FFMPEG_HAS_IMG_CONVERT) check_c_source_compiles("${_source}" VTK_FFMPEG_HAS_IMG_CONVERT)
endif() endif()
if(NOT DEFINED VTK_FFMPEG_NEW_ALLOC AND FFMPEG_avformat_LIBRARY) if(NOT DEFINED VTK_FFMPEG_NEW_ALLOC AND FFMPEG_LIBAVFORMAT_LIBRARIES)
set(_source " set(_source "
#include <${FFMEG_FORMAT_HEADER_PATH}/avformat.h> #include <${FFMEG_FORMAT_HEADER_PATH}/avformat.h>
int main() int main()
...@@ -50,7 +50,7 @@ int main() ...@@ -50,7 +50,7 @@ int main()
}\n") }\n")
check_c_source_compiles("${_source}" VTK_FFMPEG_NEW_ALLOC) check_c_source_compiles("${_source}" VTK_FFMPEG_NEW_ALLOC)
endif() endif()
if(NOT DEFINED VTK_FFMPEG_AVCODECID AND FFMPEG_avformat_LIBRARY) if(NOT DEFINED VTK_FFMPEG_AVCODECID AND FFMPEG_LIBAVFORMAT_LIBRARIES)
set(_source " set(_source "
#include <${FFMEG_FORMAT_HEADER_PATH}/avformat.h> #include <${FFMEG_FORMAT_HEADER_PATH}/avformat.h>
int main() int main()
......
...@@ -21,12 +21,12 @@ set_source_files_properties( vtkFFMPEGWriter.cxx ...@@ -21,12 +21,12 @@ set_source_files_properties( vtkFFMPEGWriter.cxx
PROPERTIES COMPILE_DEFINITIONS __STDC_CONSTANT_MACROS PROPERTIES COMPILE_DEFINITIONS __STDC_CONSTANT_MACROS
) )
set(_ffmpeg_libs ${FFMPEG_avformat_LIBRARY} ${FFMPEG_avcodec_LIBRARY} set(_ffmpeg_libs ${FFMPEG_LIBAVFORMAT_LIBRARIES} ${FFMPEG_LIBAVCODEC_LIBRARIES}
${FFMPEG_avutil_LIBRARY} ${FFMPEG_LIBAVUTIL_LIBRARIES}
) )
if(NOT VTK_FFMPEG_HAS_IMG_CONVERT) if(NOT VTK_FFMPEG_HAS_IMG_CONVERT)
list(APPEND _ffmpeg_libs ${FFMPEG_swscale_LIBRARY}) list(APPEND _ffmpeg_libs ${FFMPEG_LIBSWSCALE_LIBRARIES})
endif() endif()
vtk_module_library(vtkIOFFMPEG ${Module_SRCS}) vtk_module_library(vtkIOFFMPEG ${Module_SRCS})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment