]> source.dussan.org Git - tigervnc.git/commitdiff
Find FFMPEG using pkg-config 1473/head
authorPierre Ossman <ossman@cendio.se>
Mon, 30 May 2022 08:53:32 +0000 (10:53 +0200)
committerPierre Ossman <ossman@cendio.se>
Tue, 7 Jun 2022 08:06:32 +0000 (10:06 +0200)
This is the standard method of finding it on Unix systems, so make sure
we use it. Still keep a fallback, though, for other systems, e.g.
Windows.

CMakeLists.txt
cmake/Modules/FindFfmpeg.cmake [new file with mode: 0644]
common/rfb/CMakeLists.txt

index e5807def71fc6571d1c370f0766e998976a9c1ee..d88b177fa437a9651c60e8dba6f832823c0d4b53 100644 (file)
@@ -179,18 +179,11 @@ if(ENABLE_H264)
     set(H264_LIBS "WIN")  # may be LIBAV in the future
     set(H264_LIBRARIES ole32 mfplat mfuuid wmcodecdspuuid)
   else()
-    check_include_files(libavcodec/avcodec.h HAVE_AVCODEC_H)
-    check_include_files(libavutil/avutil.h HAVE_AVUTIL_H)
-    check_include_files(libswscale/swscale.h HAVE_SWSCALE_H)
-    if (HAVE_AVCODEC_H AND HAVE_AVUTIL_H AND HAVE_SWSCALE_H)
-      find_path(AVCODEC_INCLUDE_DIR libavcodec/avcodec.h)
-      find_library(AVCODEC_LIBRARY avcodec)
-      find_path(AVUTIL_INCLUDE_DIR libavutil/avutil.h)
-      find_library(AVUTIL_LIBRARY avutil)
-      find_path(SWSCALE_INCLUDE_DIR libswscale/swscale.h)
-      find_library(SWSCALE_LIBRARY swscale)
+    find_package(Ffmpeg)
+    if (AVCODEC_FOUND AND AVUTIL_FOUND AND SWSCALE_FOUND)
       set(H264_INCLUDE_DIRS ${AVCODEC_INCLUDE_DIRS} ${AVUTIL_INCLUDE_DIRS} ${SWSCALE_INCLUDE_DIRS})
-      set(H264_LIBRARIES ${AVCODEC_LIBRARY} ${AVUTIL_LIBRARY} ${SWSCALE_LIBRARY})
+      set(H264_LIBRARIES ${AVCODEC_LIBRARIES} ${AVUTIL_LIBRARIES} ${SWSCALE_LIBRARIES})
+      set(H264_LIBRARY_DIRS ${AVCODEC_LIBRARY_DIRS} ${AVUTIL_LIBRARY_DIRS} ${SWSCALE_LIBRARY_DIRS})
       add_definitions("-D__STDC_CONSTANT_MACROS")
       add_definitions("-DHAVE_H264")
       set(H264_LIBS "LIBAV")
diff --git a/cmake/Modules/FindFfmpeg.cmake b/cmake/Modules/FindFfmpeg.cmake
new file mode 100644 (file)
index 0000000..cf09fa4
--- /dev/null
@@ -0,0 +1,17 @@
+find_package(PkgConfig)
+
+if (PKG_CONFIG_FOUND)
+       pkg_check_modules(AVCODEC libavcodec)
+       pkg_check_modules(AVUTIL libavutil)
+       pkg_check_modules(SWSCALE libswscale)
+else()
+       find_path(AVCODEC_INCLUDE_DIRS NAMES avcodec.h PATH_SUFFIXES libavcodec)
+       find_library(AVCODEC_LIBRARIES NAMES avcodec)
+       find_package_handle_standard_args(AVCODEC DEFAULT_MSG AVCODEC_LIBRARIES AVCODEC_INCLUDE_DIRS)
+       find_path(AVUTIL_INCLUDE_DIRS NAMES avutil.h PATH_SUFFIXES libavutil)
+       find_library(AVUTIL_LIBRARIES NAMES avutil)
+       find_package_handle_standard_args(AVUTIL DEFAULT_MSG AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIRS)
+       find_path(SWSCALE_INCLUDE_DIRS NAMES swscale.h PATH_SUFFIXES libswscale)
+       find_library(SWSCALE_LIBRARIES NAMES swscale)
+       find_package_handle_standard_args(SWSCALE DEFAULT_MSG SWSCALE_LIBRARIES SWSCALE_INCLUDE_DIRS)
+endif()
index 66014f3e1671e92d8523e08be11b2096f28e2b18..994f11962992e6aa5eb39b0de6a0a3243c32b749 100644 (file)
@@ -76,6 +76,7 @@ if(ENABLE_H264 AND NOT H264_LIBS STREQUAL "NONE")
     target_sources(rfb PRIVATE H264WinDecoderContext.cxx)
   endif()
   target_link_libraries(rfb ${H264_LIBRARIES})
+  target_link_directories(rfb PUBLIC ${H264_LIBRARY_DIRS})
 endif()
 
 if(UNIX)