# HG changeset patch # User koda # Date 1362568322 -3600 # Node ID 1652c1d9adc8e4ff82cf4a9cbab46c7e5ee3cd54 # Parent 3ff8694d9e2299c2ec2ac1d00f894090a9018bcb rework ffmpeg/libav/videorec linking and their cmake discovery diff -r 3ff8694d9e22 -r 1652c1d9adc8 CMakeLists.txt --- a/CMakeLists.txt Wed Mar 06 11:18:54 2013 +0100 +++ b/CMakeLists.txt Wed Mar 06 12:12:02 2013 +0100 @@ -22,7 +22,7 @@ #possible cmake configuration option(NOSERVER "Disable gameServer build [default: auto]" OFF) option(NOPNG "Disable screenshoot compression [default: auto]" OFF) -option(NOVIDEOREC "Disable video recording [default: auto]" OFF) +option(NOVIDEOREC "Disable video recording [default: off]" OFF) #set this to ON when 2.1.0 becomes more widespread (and only for linux) option(SYSTEM_PHYSFS "Use system physfs [default:off]" OFF) @@ -194,11 +194,6 @@ list(APPEND pascal_flags "-Ff~/Library/Frameworks") #set deployment target list(APPEND pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}") - - #silly libav that always brings in VideoDecoderAcceleration, avaible only from 10.6.3 - if(NOT NOVIDEOREC AND ${minimum_macosx_version} VERSION_LESS "10.6") - set(${WARNING} "Video recording support before OS X 10.6 is experimental") - endif() endif(APPLE) @@ -358,6 +353,15 @@ list(APPEND pascal_flags "-XLAphysfs=${physfs_output_name}" "-dPHYSFS_INTERNAL") endif() +if(NOT ${NOVIDEOREC}) + find_package(FFMPEG) + if(NOT ${FFMPEG_FOUND}) + message(FATAL_ERROR "Missing FFMPEG/Libav! Rerun cmake with -DNOVIDEOREC=on to disable video recording") + endif() +else() + set(FFMPEG_FOUND false) +endif() + # add_subdirectory(misc/libphyslayer) diff -r 3ff8694d9e22 -r 1652c1d9adc8 QTfrontend/CMakeLists.txt --- a/QTfrontend/CMakeLists.txt Wed Mar 06 11:18:54 2013 +0100 +++ b/QTfrontend/CMakeLists.txt Wed Mar 06 12:12:02 2013 +0100 @@ -15,12 +15,11 @@ find_package(SDL REQUIRED) #video in SDLInteraction find_package(SDL_mixer REQUIRED) #audio in SDLInteraction -find_package(SDL_net REQUIRED) #network frontlib -if(NOT NOVIDEOREC) - find_package(FFMPEG) - if(${FFMPEG_FOUND}) - add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS) - endif() + +if(${FFMPEG_FOUND}) + add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS) + include_directories(${FFMPEG_INCLUDE_DIR}) + list(APPEND HW_LINK_LIBS ${FFMPEG_LIBRARIES}) endif() # server messages localization @@ -56,7 +55,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/util/platform) include_directories(${SDL_INCLUDE_DIR}) include_directories(${SDLMIXER_INCLUDE_DIR}) -include_directories(${FFMPEG_INCLUDE_DIR}) include_directories(${PHYSFS_INCLUDE_DIR}) include_directories(${PHYSLAYER_INCLUDE_DIR}) @@ -204,7 +202,6 @@ ${QT_LIBRARIES} ${SDL_LIBRARY} ${SDLMIXER_LIBRARY} - ${FFMPEG_LIBRARIES} ) if(WIN32 AND NOT UNIX) diff -r 3ff8694d9e22 -r 1652c1d9adc8 hedgewars/CMakeLists.txt --- a/hedgewars/CMakeLists.txt Wed Mar 06 11:18:54 2013 +0100 +++ b/hedgewars/CMakeLists.txt Wed Mar 06 12:12:02 2013 +0100 @@ -189,30 +189,22 @@ endif() -if(NOT NOVIDEOREC) - find_package(FFMPEG) - if(${FFMPEG_FOUND}) - # TODO: this check is only for SDL < 2 - # fpc will take care of linking but we need to have this library installed - find_package(GLUT REQUIRED) +if(${FFMPEG_FOUND}) + # TODO: this check is only for SDL < 2 + # fpc will take care of linking but we need to have this library installed + find_package(GLUT REQUIRED) - #TODO: convert avwrapper to .pas unit so we can skip this step - include_directories(${FFMPEG_INCLUDE_DIR}) - list(APPEND pascal_flags "-dUSE_VIDEO_RECORDING") - IF (WIN32) - # there are some problems with linking our avwrapper as static lib, so link it as shared - add_library(avwrapper SHARED avwrapper.c) - target_link_libraries(avwrapper ${FFMPEG_LIBRARIES}) - install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_library_install_dir}) - ELSE() - add_library(avwrapper STATIC avwrapper.c) - list(APPEND pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}") - ENDIF() + #TODO: convert avwrapper to .pas unit so we can skip this step + include_directories(${FFMPEG_INCLUDE_DIR}) + list(APPEND pascal_flags "-dUSE_VIDEO_RECORDING") + if(WIN32) + # there are some problems with linking our avwrapper as static lib, so link it as shared + add_library(avwrapper SHARED avwrapper.c) + target_link_libraries(avwrapper ${FFMPEG_LIBRARIES}) + install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_library_install_dir}) else() - message(${WARNING} "Could NOT find FFMPEG/LibAV, video recording will be disabled") + add_library(avwrapper STATIC avwrapper.c) endif() -else() - message(STATUS "Video recording disabled by user") endif() @@ -273,7 +265,7 @@ endif() #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6 -if((FREEPASCAL_VERSION VERSION_LESS "2.6") AND (NOVIDEOREC OR NOT ${FFMPEG_FOUND})) +if((FREEPASCAL_VERSION VERSION_LESS "2.6") AND (NOT ${FFMPEG_FOUND})) add_dependencies(hwengine ENGINECLEAN) endif() diff -r 3ff8694d9e22 -r 1652c1d9adc8 hedgewars/uVideoRec.pas --- a/hedgewars/uVideoRec.pas Wed Mar 06 11:18:54 2013 +0100 +++ b/hedgewars/uVideoRec.pas Wed Mar 06 12:12:02 2013 +0100 @@ -28,7 +28,9 @@ {$ELSE} {$IFNDEF WIN32} - {$LINKLIB ../bin/libavwrapper.a} + {$linklib avcodec} + {$linklib avformat} + {$linklib avutil} {$ENDIF} interface @@ -48,17 +50,17 @@ procedure freeModule; implementation - uses uVariables, uUtils, GLunit, SDLh, SysUtils, uIO, uMisc, uTypes; type TAddFileLogRaw = procedure (s: pchar); cdecl; +const AvwrapperLibName = 'libavwrapper'; procedure AVWrapper_Init( AddLog: TAddFileLogRaw; filename, desc, soundFile, format, vcodec, acodec: PChar; - width, height, framerateNum, framerateDen, vquality: LongInt); cdecl; external {$IFDEF WIN32}'libavwrapper.dll'{$ENDIF}; -procedure AVWrapper_Close; cdecl; external {$IFDEF WIN32}'libavwrapper.dll'{$ENDIF}; -procedure AVWrapper_WriteFrame( pY, pCb, pCr: PByte ); cdecl; external {$IFDEF WIN32}'libavwrapper.dll'{$ENDIF}; + width, height, framerateNum, framerateDen, vquality: LongInt); cdecl; external AvwrapperLibName; +procedure AVWrapper_Close; cdecl; external AvwrapperLibName; +procedure AVWrapper_WriteFrame( pY, pCb, pCr: PByte ); cdecl; external AvwrapperLibName; type TFrame = record realTicks: LongWord; diff -r 3ff8694d9e22 -r 1652c1d9adc8 share/CMakeLists.txt --- a/share/CMakeLists.txt Wed Mar 06 11:18:54 2013 +0100 +++ b/share/CMakeLists.txt Wed Mar 06 12:12:02 2013 +0100 @@ -7,12 +7,9 @@ #CFBundleVersion is HEDGEWARS_REVISION #CFBundleShortVersionString is HEDGEWARS_VERSION - #silly libav that always brings in VideoDecoderAcceleration, avaible only from 10.6.3 - if(NOT NOVIDEOREC) - find_package(FFMPEG) - if(${FFMPEG_FOUND} AND ${minimum_macosx_version} VERSION_EQUAL "10.6") - set(minimum_macosx_version "10.6.3") - endif() + #libav/ffmpeg always brings in VideoDecoderAcceleration, avaible only from 10.6.3 + if(${FFMPEG_FOUND} AND ${minimum_macosx_version} VERSION_EQUAL "10.6") + set(minimum_macosx_version "10.6.3") endif() configure_file(${hedgewars_SOURCE_DIR}/share/Info.plist.in