fix FindFFMPEG
authorStepan777 <stepik-777@mail.ru>
Thu, 09 Aug 2012 19:52:21 +0400
changeset 7534 ccb9c2906160
parent 7531 0adcad8714c4
child 7536 e1b80da69991
fix FindFFMPEG
cmake_modules/FindFFMPEG.cmake
hedgewars/CMakeLists.txt
--- a/cmake_modules/FindFFMPEG.cmake	Thu Aug 09 03:00:24 2012 +0400
+++ b/cmake_modules/FindFFMPEG.cmake	Thu Aug 09 19:52:21 2012 +0400
@@ -1,10 +1,9 @@
-# - Try to find libxml++-2.6
+# - Try to find ffmpeg libraries (libavcodec, libavformat and libavutil)
 # Once done this will define
 #
-#  FFMPEG_FOUND - system has libxml++
-#  FFMPEG_INCLUDE_DIRS - the libxml++ include directory
-#  FFMPEG_LIBRARIES - Link these to use libxml++
-#  FFMPEG_DEFINITIONS - Compiler switches required for using libxml++
+#  FFMPEG_FOUND - system has ffmpeg
+#  FFMPEG_INCLUDE_DIR - the ffmpeg include directory
+#  FFMPEG_LIBRARIES - Link these to use ffmpeg
 #
 #  Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
 #  Modified for other libraries by Lasse Kärkkäinen <tronic>
@@ -14,10 +13,10 @@
 #  BSD license.
 #
 
-if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIRS)
+if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
   # in cache already
   set(FFMPEG_FOUND TRUE)
-else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIRS)
+else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
   # use pkg-config to get the directories and then use these values
   # in the FIND_PATH() and FIND_LIBRARY() calls
   find_package(PkgConfig)
@@ -28,15 +27,9 @@
   endif (PKG_CONFIG_FOUND)
 
   find_path(FFMPEG_AVCODEC_INCLUDE_DIR
-    NAMES avcodec.h
+    NAMES libavcodec/avcodec.h
     PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
-    PATH_SUFFIXES ffmpeg libavcodec
-  )
-
-  find_path(FFMPEG_AVFORMAT_INCLUDE_DIR
-    NAMES avformat.h
-    PATHS ${_FFMPEG_AVFORMAT_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
-    PATH_SUFFIXES ffmpeg libavformat
+    PATH_SUFFIXES ffmpeg libav
   )
 
   find_library(FFMPEG_AVCODEC_LIBRARY
@@ -59,11 +52,7 @@
   endif (FFMPEG_AVCODEC_LIBRARY AND FFMPEG_AVFORMAT_LIBRARY)
 
   if (FFMPEG_FOUND)
-
-    set(FFMPEG_INCLUDE_DIR
-      ${FFMPEG_AVCODEC_INCLUDE_DIR}
-      ${FFMPEG_AVFORMAT_INCLUDE_DIR}
-    )
+    set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR}/..)
 
     set(FFMPEG_LIBRARIES
       ${FFMPEG_AVCODEC_LIBRARY}
@@ -75,7 +64,7 @@
 
   if (FFMPEG_FOUND)
     if (NOT FFMPEG_FIND_QUIETLY)
-      message(STATUS "Found FFMPEG: ${FFMPEG_LIBRARIES}")
+      message(STATUS "Found FFMPEG: ${FFMPEG_LIBRARIES} ${FFMPEG_INCLUDE_DIR}")
     endif (NOT FFMPEG_FIND_QUIETLY)
   else (FFMPEG_FOUND)
     if (FFMPEG_FIND_REQUIRED)
@@ -83,5 +72,5 @@
     endif (FFMPEG_FIND_REQUIRED)
   endif (FFMPEG_FOUND)
 
-endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIRS)
+endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
 
--- a/hedgewars/CMakeLists.txt	Thu Aug 09 03:00:24 2012 +0400
+++ b/hedgewars/CMakeLists.txt	Thu Aug 09 19:52:21 2012 +0400
@@ -189,10 +189,9 @@
 
 IF (WIN32)
     set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
-    include_directories(${CMAKE_SOURCE_DIR}/misc/winutils/include)
-    link_directories(${CMAKE_SOURCE_DIR}/misc/winutils/lib)
+    include_directories(${FFMPEG_INCLUDE_DIR})
     add_library(avwrapper SHARED avwrapper.c)
-    target_link_libraries(avwrapper avcodec avformat avutil)
+    target_link_libraries(avwrapper ${FFMPEG_LIBRARIES})
 ELSE()
     add_library(avwrapper STATIC avwrapper.c)
 ENDIF()