cmake scripts
authorStepan777 <stepik-777@mail.ru>
Sat, 11 Aug 2012 21:25:57 +0400
changeset 7540 cc6c656f70b5
parent 7538 2d6e69b392cb
child 7542 37ef1891efe2
cmake scripts
cmake_modules/FindFFMPEG.cmake
hedgewars/CMakeLists.txt
hedgewars/uVideoRec.pas
--- a/cmake_modules/FindFFMPEG.cmake	Fri Aug 10 17:35:48 2012 +0400
+++ b/cmake_modules/FindFFMPEG.cmake	Sat Aug 11 21:25:57 2012 +0400
@@ -1,7 +1,7 @@
 # - Try to find ffmpeg libraries (libavcodec, libavformat and libavutil)
 # Once done this will define
 #
-#  FFMPEG_FOUND - system has ffmpeg
+#  FFMPEG_FOUND - system has ffmpeg or libav
 #  FFMPEG_INCLUDE_DIR - the ffmpeg include directory
 #  FFMPEG_LIBRARIES - Link these to use ffmpeg
 #  FFMPEG_LIBAVCODEC
@@ -67,11 +67,11 @@
 
   if (FFMPEG_FOUND)
     if (NOT FFMPEG_FIND_QUIETLY)
-      message(STATUS "Found FFMPEG: ${FFMPEG_LIBRARIES} ${FFMPEG_INCLUDE_DIR}")
+      message(STATUS "Found FFMPEG or Libav: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}")
     endif (NOT FFMPEG_FIND_QUIETLY)
   else (FFMPEG_FOUND)
     if (FFMPEG_FIND_REQUIRED)
-      message(FATAL_ERROR "Could not find FFMPEG libavcodec or libavformat or libavutil")
+      message(FATAL_ERROR "Could not find libavcodec or libavformat or libavutil")
     endif (FFMPEG_FIND_REQUIRED)
   endif (FFMPEG_FOUND)
 
--- a/hedgewars/CMakeLists.txt	Fri Aug 10 17:35:48 2012 +0400
+++ b/hedgewars/CMakeLists.txt	Sat Aug 11 21:25:57 2012 +0400
@@ -190,14 +190,18 @@
         message(STATUS "Compiling with video recording")
         include_directories(${FFMPEG_INCLUDE_DIR})
         set(pascal_flags "-dUSE_VIDEO_RECORDING" ${pascal_flags})
+        set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
         IF (WIN32)
-            set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
             # 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})
         ELSE()
             add_library(avwrapper STATIC avwrapper.c)
+            set(pascal_flags "-k${FFMPEG_LIBAVCODEC} ${FFMPEG_LIBAVFORMAT} ${FFMPEG_LIBAVUTIL}" ${pascal_flags})
+         #   set(pascal_flags "-k${LIBRARY_OUTPUT_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}avwrapper${CMAKE_STATIC_LIBRARY_SUFFIX}" ${pascal_flags})
         ENDIF()
+    else()
+        message(STATUS "FFMPEG library not found, video recording will be disabled")
     endif()
 else()
     message(STATUS "Video recording disabled by user")
--- a/hedgewars/uVideoRec.pas	Fri Aug 10 17:35:48 2012 +0400
+++ b/hedgewars/uVideoRec.pas	Sat Aug 11 21:25:57 2012 +0400
@@ -28,10 +28,7 @@
 {$ELSE}
 
 {$IFNDEF WIN32}
-    {$LINKLIB avwrapper}
-    {$LINKLIB avutil}
-    {$LINKLIB avcodec}
-    {$LINKLIB avformat}
+    {$LINKLIB ../bin/libavwrapper.a}
 {$ENDIF}
 
 interface
@@ -53,16 +50,14 @@
 
 uses uVariables, uUtils, GLunit, SDLh, SysUtils, uIO, uMisc, uTypes;
 
-const AVWrapperLibName = {$IFDEF WIN32}'libavwrapper.dll'{$ELSE}''{$ENDIF};
-
 type TAddFileLogRaw = procedure (s: pchar); cdecl;
 
 procedure AVWrapper_Init(
               AddLog: TAddFileLogRaw;
               filename, desc, soundFile, format, vcodec, acodec: PChar;
-              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;
+              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};
 
 type TFrame = record
                   realTicks: LongWord;