Skip to content

Commit e2d0cce

Browse files
author
Clement Champetier
committed
CMake findFFmpeg: remove arguments FFMPEG_INCLUDE_DIR/FFMPEG_LIBRARY_DIR
Use CMAKE_PREFIX_PATH to point to a specific ffmpeg/libav install.
1 parent 2bb3bf9 commit e2d0cce

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

cmake/FindFFmpeg.cmake

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,12 @@ macro(find_component COMPONENT PKGCONFIG LIBRARY HEADER)
7676
)
7777
endmacro()
7878

79-
# Get FFmpeg from custom install
80-
if(FFMPEG_LIBRARY_DIR AND FFMPEG_INCLUDE_DIR)
81-
set(FFMPEG_FOUND TRUE)
82-
if(WIN32)
83-
file(GLOB FFMPEG_LIBRARIES "${FFMPEG_LIBRARY_DIR}/*.lib")
84-
else()
85-
file(GLOB FFMPEG_LIBRARIES "${FFMPEG_LIBRARY_DIR}/*.so")
86-
endif()
87-
# Get FFmpeg from system install
88-
else()
89-
# Check FFmpeg version
90-
if(DEFINED FFmpeg_FIND_VERSION)
91-
check_ffmpeg_version()
92-
endif()
93-
94-
if(NOT FFmpeg_FIND_COMPONENTS)
95-
set(FFmpeg_FIND_COMPONENTS avcodec avformat avutil)
96-
endif()
97-
79+
### Macro: manage_components
80+
# Define CMake variables for each component defined in FFmpeg_FIND_COMPONENTS
81+
# Send error if a required component is missing (warning if not required)
82+
# Set if FFMPEG is found
83+
#
84+
macro(manage_components)
9885
# Check components and add their stuff to the FFMPEG_* vars.
9986
foreach(COMPONENT ${FFmpeg_FIND_COMPONENTS})
10087
# Get component name is lower cases.
@@ -120,4 +107,17 @@ else()
120107
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIR)
121108
set(FFMPEG_FOUND TRUE)
122109
endif()
110+
endmacro()
111+
112+
# Check FFmpeg version
113+
if(DEFINED FFmpeg_FIND_VERSION)
114+
check_ffmpeg_version()
123115
endif()
116+
117+
# Get basic components if no one is indicated
118+
if(NOT FFmpeg_FIND_COMPONENTS)
119+
set(FFmpeg_FIND_COMPONENTS avcodec avformat avutil)
120+
endif()
121+
122+
# Check each component
123+
manage_components()

0 commit comments

Comments
 (0)