finally videorec on osx
authorkoda
Thu, 25 Oct 2012 01:16:13 +0200
changeset 7816 a25e943dd4b0
parent 7815 1a3a62b0ac11
child 7817 6cc558a69b58
finally videorec on osx
CMakeLists.txt
cmake_modules/FindFFMPEG.cmake
hedgewars/CMakeLists.txt
hedgewars/uVideoRec.pas
tools/CreateMacBundle.cmake.in
--- a/CMakeLists.txt	Wed Oct 24 18:44:23 2012 +0100
+++ b/CMakeLists.txt	Thu Oct 25 01:16:13 2012 +0200
@@ -176,7 +176,7 @@
     endif()
 endif()
 
-set(pascal_flags ${fpflags_parsed} "-vq" "-vm4079,4080,4081" "-B" "-FE../bin" "-Cs2000000" "-vewn" "-dDEBUGFILE" ${pascal_flags})
+set(pascal_flags ${fpflags_parsed} "-vm4079,4080,4081" "-B" "-FE../bin" "-Cs2000000" "-vewnq" "-dDEBUGFILE" ${pascal_flags})
 set(haskell_flags "-O2" ${ghflags_parsed} ${haskell_flags})
 
 #get BUILD_TYPE and enable/disable optimisation
--- a/cmake_modules/FindFFMPEG.cmake	Wed Oct 24 18:44:23 2012 +0100
+++ b/cmake_modules/FindFFMPEG.cmake	Thu Oct 25 01:16:13 2012 +0200
@@ -31,23 +31,35 @@
 
   find_path(FFMPEG_AVCODEC_INCLUDE_DIR
     NAMES libavcodec/avcodec.h
-    PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
+    PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS}
+        /usr/include /usr/local/include #system level
+        /opt/local/include #macports
+        /sw/include #fink
     PATH_SUFFIXES ffmpeg libav
   )
 
   find_library(FFMPEG_LIBAVCODEC
     NAMES avcodec
-    PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+    PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS}
+        /usr/lib /usr/local/lib #system level
+        /opt/local/lib #macports
+        /sw/lib #fink
   )
 
   find_library(FFMPEG_LIBAVFORMAT
     NAMES avformat
-    PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+    PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS}
+        /usr/lib /usr/local/lib #system level
+        /opt/local/lib #macports
+        /sw/lib #fink
   )
 
   find_library(FFMPEG_LIBAVUTIL
     NAMES avutil
-    PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+    PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS}
+        /usr/lib /usr/local/lib #system level
+        /opt/local/lib #macports
+        /sw/lib #fink
   )
 
   if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT)
@@ -62,16 +74,19 @@
       ${FFMPEG_LIBAVFORMAT}
       ${FFMPEG_LIBAVUTIL}
     )
+    if (APPLE)
+      set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} "bz2" "-framework CoreVideo" "-framework VideoDecodeAcceleration")
+    endif(APPLE)
 
   endif (FFMPEG_FOUND)
 
   if (FFMPEG_FOUND)
     if (NOT FFMPEG_FIND_QUIETLY)
-      message(STATUS "Found FFMPEG or Libav: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}")
+      message(STATUS "Found FFMPEG/LibAV: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}")
     endif (NOT FFMPEG_FIND_QUIETLY)
   else (FFMPEG_FOUND)
     if (FFMPEG_FIND_REQUIRED)
-      message(FATAL_ERROR "Could not find 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	Wed Oct 24 18:44:23 2012 +0100
+++ b/hedgewars/CMakeLists.txt	Thu Oct 25 01:16:13 2012 +0200
@@ -3,6 +3,7 @@
 find_package(SDL_net)
 find_package(SDL_ttf)
 find_package(SDL_mixer)
+set(FFMPEG_FIND_QUIETLY true)
 find_package(FFMPEG)
 
 include(${CMAKE_MODULE_PATH}/FindSDL_Extras.cmake)
@@ -211,13 +212,12 @@
         ELSE()
             add_library(avwrapper STATIC avwrapper.c)
             set(pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}" ${pascal_flags})
-         #   set(pascal_flags "-k${LIBRARY_OUTPUT_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}avwrapper${CMAKE_STATIC_LIBRARY_SUFFIX}" ${pascal_flags})
         ENDIF()
         if(fpc_version LESS "020600")
             add_dependencies(avwrapper ENGINECLEAN)
         endif()
     else()
-        message(STATUS "Could NOT find FFMPEG, video recording will be disabled")
+        message(STATUS "Could NOT find FFMPEG/LibAV, video recording will be disabled")
     endif()
 else()
     message(STATUS "Video recording disabled by user")
--- a/hedgewars/uVideoRec.pas	Wed Oct 24 18:44:23 2012 +0100
+++ b/hedgewars/uVideoRec.pas	Thu Oct 25 01:16:13 2012 +0200
@@ -30,6 +30,11 @@
 {$IFNDEF WIN32}
     {$LINKLIB ../bin/libavwrapper.a}
 {$ENDIF}
+{$IFDEF DARWIN}
+    {$LINKLIB bz2}
+    {$LINKFRAMEWORK CoreVideo}
+    {$LINKFRAMEWORK VideoDecodeAcceleration}
+{$ENDIF}
 
 interface
 
--- a/tools/CreateMacBundle.cmake.in	Wed Oct 24 18:44:23 2012 +0100
+++ b/tools/CreateMacBundle.cmake.in	Thu Oct 25 01:16:13 2012 +0200
@@ -3,7 +3,12 @@
 execute_process(COMMAND ls ${frameworks_dir} RESULT_VARIABLE doBundle OUTPUT_QUIET ERROR_QUIET)
 
 execute_process(COMMAND mkdir -p ${frameworks_dir})
+# macdeployqt will convert safely any absolute path library for 'hedgewars'
 execute_process(COMMAND ${macdeployqt_executable} ${CMAKE_BINARY_DIR}/${bundle_name} OUTPUT_QUIET ERROR_QUIET)
+# but macdeployqt will not work for 'hwengine'; luckily the dylibs were already updated before
+execute_process(COMMAND install_name_tool -change ${FFMPEG_LIBAVCODEC} @executable_path/../Frameworks/libavcodec.dylib ${CMAKE_BINARY_DIR}/${bundle_name}/Contents/MacOS/hwengine)
+execute_process(COMMAND install_name_tool -change ${FFMPEG_LIBAVFORMAT} @executable_path/../Frameworks/libavformat.dylib ${CMAKE_BINARY_DIR}/${bundle_name}/Contents/MacOS/hwengine)
+execute_process(COMMAND install_name_tool -change ${FFMPEG_LIBAVUTIL} @executable_path/../Frameworks/libavutil.dylib ${CMAKE_BINARY_DIR}/${bundle_name}/Contents/MacOS/hwengine)
 
 if(doBundle EQUAL 1)
     execute_process(COMMAND cp -pPR ${sdl_dir}          ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL.framework)