Hi We have four different files of that style flying aroung in kde
strigi/libstreamanalyzer/cmake/FindFFMPEG.cmake kdelibs/cmake/modules/FindFFmpeg.cmake kdemultimedia/cmake/modules/FindFFMPEG.cmake amarok/cmake/modules/FindFFmpeg.cmake They best is the kdelibs one. Some are plain out problematic. They for example look up their header with PATH_SUFFIX libavcodec but include with <libavcodec/avcodec.h> (kdemultimedia). which break the build for some of us. The others seem to stem from the fact that they need different parts of ffmpeg. amarok only looks for avcodec and avformat. kdemultimedia looks for swscale additionaly. I tried to clean up the stuff with the attached file. Please review. It uses the components approach. Questions: There seems to be no way to check for a ffmpeg version because it has no global one. Perhaps it is a bad idea to look for ffmpeg and instead provide one FindXYZ.cmake file for each component. For now i export the individual version so potential users can check themselve. There are some @QUESTION comments in that script. And i have a problem with macro_optional_find_package and the analog thing from strigi. They do not account for potential COMPONENT arguments to the required module. Another argument for a split find_package for each component? Without a solution to that problem this file is useless. All modules use the macros to find ffmpeg. Mike
# vim: ts=2 sw=2 # - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC) # # Once done this will define # FFMPEG_FOUND - System has the all required components. # FFMPEG_INCLUDE_DIR - Include directory necessary for using the required components headers. # FFMPEG_LIBRARIES - Link these to use the required ffmpeg components. # FFMPEG_DEFINITIONS - Compiler switches required for using the required ffmpeg components. # # For each of the components it will additionaly set. # - AVFORMAT # - AVCODEC # - AVDEVICE # - AVUTIL # - SWSCALE # - POSTPROCESS # the following variables will be defined # <component>_FOUND - System has <component> # <component>_INCLUDE_DIR - Include directory necessary for using the <component> headers # <component>_LIBRARIES - Link these to use <component> # <component>_DEFINITIONS - Compiler switches required for using <component> # <component>_VERSION - The components version # # Copyright (c) 2006, Matthias Kretz, <[email protected]> # Copyright (c) 2008, Alexander Neundorf, <[email protected]> # Copyright (c) 2011, Michael Jansen, <[email protected]> # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. # The default components were taken from a survey over other FindFFMPEG.cmake files if(NOT FFmpeg_FIND_COMPONENTS) set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL) endif() message(STATUS "Looking for ${FFmpeg_FIND_COMPONENTS}") # A macro to look up the components macro(find_component _component _pkgconfig _library _header) if (NOT WIN32) # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls pkg_check_modules(PC_${_component} ${_pkgconfig}) endif (NOT WIN32) # #include <libXXXX/XXXX.h> is the new style for FFMPEG headers # This has been verified at least since 0.4.9 # Please do not change to the old format, since this will break for # people who are using newer versions. Instead, upgrade your ffmpeg # installation. find_path(${_component}_INCLUDE_DIR ${_header} HINTS ${PC_LIB${_component}_INCLUDEDIR} ${PC_LIB${_component}_INCLUDE_DIRS} ) find_library(${_component}_LIBRARIES NAMES ${_library} HINTS ${PC_LIB${_component}_LIBDIR} ${PC_LIB${_component}_LIBRARY_DIRS} ) set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS") set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number") # @QUESTION: Is this correct here? As far as i can tell those vars are not cached. But that # would mean they get lost on the next cmake run? Should this be before # find_package_handle_standard_args? if(${_component}_LIBRARIES AND ${_component}_INCLUDE_DIR) message(STATUS " - ${_component} found.") set(FFmpeg_${_component}_FOUND TRUE) else() message(STATUS " - ${_component} not found.") endif() mark_as_advanced( ${_component}_INCLUDE_DIR ${_component}_LIBRARIES ${_component}_DEFINITIONS ${_component}_VERSION) endmacro() if (FFMPEG_LIBRARIES) # in cache already set(FFMPEG_FOUND TRUE) else (FFMPEG_LIBRARIES) find_package(PkgConfig) # 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(SWSCALE libswscale swscale libswscale/swscale.h) find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h) # Check if the required components were found and add their stuff to the FFMPEG_* vars. foreach(_component ${FFmpeg_FIND_COMPONENTS}) if(FFmpeg_${_component}_FOUND) message(STATUS "Required component ${_component} present.") set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES}) set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${_component}_DEFINITIONS}) list(APPEND _FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIR}) else() message(STATUS "Required component ${_component} missing.") endif() endforeach() # Build the include path with duplicates removed. if(_FFMPEG_INCLUDE_DIRS) list(REMOVE_DUPLICATES _FFMPEG_INCLUDE_DIRS) endif() string(REPLACE ";" " " FFMPEG_INCLUDE_DIRS "${_FFMPEG_INCLUDE_DIRS}") # cache the vars. set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE) set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE) set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg cflags." FORCE) mark_as_advanced( FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES FFMPEG_DEFINITIONS) endif (FFMPEG_LIBRARIES) # Compile the list of required vars and check if we were successful. # @QUESTION: Should this be inside the if(FFMPEG_LIBRARIES) above? Or is it helpful here by making # sure all required vars are cached? SET(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS) foreach(_component ${FFmpeg_FIND_COMPONENTS}) list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIR) endforeach() # @QUESTION: Should this be inside the if(FFMPEG_LIBRARIES) above? find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS})
_______________________________________________ Kde-buildsystem mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-buildsystem
