-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFindFFmpeg.cmake
More file actions
179 lines (149 loc) · 6.13 KB
/
FindFFmpeg.cmake
File metadata and controls
179 lines (149 loc) · 6.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# Locate ffmpeg
# This module defines
# FFMPEG_LIBRARIES
# FFMPEG_FOUND, if false, do not try to link to ffmpeg
# FFMPEG_INCLUDE_DIR, where to find the headers
#
# $FFMPEG_DIR is an environment variable that would
# correspond to the ./configure --prefix=$FFMPEG_DIR
#
# Created by Robert Osfield.
#In ffmpeg code, old version use "#include <header.h>" and newer use "#include <libname/header.h>"
#In OSG ffmpeg plugin, we use "#include <header.h>" for compatibility with old version of ffmpeg
#We have to search the path which contain the header.h (usefull for old version)
#and search the path which contain the libname/header.h (usefull for new version)
#Then we need to include ${FFMPEG_libname_INCLUDE_DIRS} (in old version case, use by ffmpeg header and osg plugin code)
# (in new version case, use by ffmpeg header)
#and ${FFMPEG_libname_INCLUDE_DIRS/libname} (in new version case, use by osg plugin code)
# Macro to find header and lib directories
# example: FFMPEG_FIND(AVFORMAT avformat avformat.h)
MACRO(FFMPEG_FIND varname shortname headername)
# old version of ffmpeg put header in $prefix/include/[ffmpeg]
# so try to find header in include directory
FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ${headername}
PATHS
${DEPENDENCIES_INCLUDE_DIR}
${FFMPEG_ROOT}/include
$ENV{FFMPEG_DIR}/include
$ENV{OSGDIR}/include
$ENV{OSG_ROOT}/include
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
/usr/freeware/include
PATH_SUFFIXES ffmpeg
DOC "Location of FFMPEG Headers"
)
# newer version of ffmpeg put header in $prefix/include/[ffmpeg/]lib${shortname}
# so try to find lib${shortname}/header in include directory
IF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
PATHS
${DEPENDENCIES_INCLUDE_DIR}
${FFMPEG_ROOT}/include
$ENV{FFMPEG_DIR}/include
$ENV{OSGDIR}/include
$ENV{OSG_ROOT}/include
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include/
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
/usr/freeware/include
PATH_SUFFIXES ffmpeg
DOC "Location of FFMPEG Headers"
)
ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES
NAMES ${shortname}
PATHS
${DEPENDENCIES_LIBRARIES_DIR}
${FFMPEG_ROOT}/lib
${FFMPEG_ROOT}/lib64
$ENV{FFMPEG_DIR}/lib
$ENV{FFMPEG_DIR}/lib64
$ENV{OSGDIR}/lib
$ENV{OSG_ROOT}/lib
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/local/lib64
/usr/lib/x86_64-linux-gnu
/usr/lib
/usr/lib64
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
DOC "Location of FFMPEG Libraries"
)
IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
message("FFMPEG_${varname}_FOUND")
SET(FFMPEG_${varname}_FOUND 1)
ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
IF (WIN32)
FILE(GLOB FFMPEG_${varname}_RUNTIME_LIBRARY ${DEPENDENCIES_RUNTIME_DIR}/${shortname}*.dll)
SET(${varname}_RUNTIME_LIBRARY ${FFMPEG_${varname}_RUNTIME_LIBRARY})
SET(FFMPEG_RUNTIME_LIBRARIES ${FFMPEG_RUNTIME_LIBRARIES} ${${varname}_RUNTIME_LIBRARY})
MESSAGE("FFMPEG_${varname}_RUNTIME_LIBRARY : ${FFMPEG_${varname}_RUNTIME_LIBRARY}")
ENDIF(WIN32)
ENDMACRO(FFMPEG_FIND)
SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG")
FFMPEG_FIND(LIBAVFORMAT avformat avformat.h)
FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h)
FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h)
FFMPEG_FIND(LIBAVUTIL avutil avutil.h)
FFMPEG_FIND(LIBSWSCALE swscale swscale.h)
#FFMPEG_FIND(LIBAVFILTER avfilter avfilter.h)
if (WIN32)
FFMPEG_FIND(LIBSWRESAMPLE swresample swresample.h)
else (WIN32)
FFMPEG_FIND(LIBSWRESAMPLE avresample avresample.h)
endif (WIN32)
FFMPEG_FIND(LIBPOSTPROC postproc postprocess.h)
message("FFMPEG_LIBAVFORMAT: ${FFMPEG_LIBAVFORMAT_LIBRARIES}")
message("FFMPEG_LIBAVDEVICE: ${FFMPEG_LIBAVDEVICE_LIBRARIES}")
message("FFMPEG_LIBAVCODEC: ${FFMPEG_LIBAVCODEC_LIBRARIES}")
message("FFMPEG_LIBAVUTIL: ${FFMPEG_LIBAVUTIL_LIBRARIES}")
message("FFMPEG_LIBAVSWSCALE: ${FFMPEG_LIBAVSWSCALE_LIBRARIES}")
message("FFMPEG_LIBAVSWRESAMPLE: ${FFMPEG_LIBAVSWRESAMPLE_LIBRARIES}")
SET(FFMPEG_FOUND FALSE)
# Note we don't check FFMPEG_LIBAVFILTER and LIBPOSTPROC because we don't need them
IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND FFMPEG_LIBSWSCALE_FOUND AND FFMPEG_LIBSWRESAMPLE_FOUND)
SET(FFMPEG_FOUND TRUE)
message("FFmpeg found")
SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS})
# Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, it will be added if found later.
SET(FFMPEG_LIBRARIES
${FFMPEG_LIBAVFORMAT_LIBRARIES}
${FFMPEG_LIBAVDEVICE_LIBRARIES}
${FFMPEG_LIBAVCODEC_LIBRARIES}
${FFMPEG_LIBAVUTIL_LIBRARIES}
${FFMPEG_LIBSWSCALE_LIBRARIES}
${FFMPEG_LIBSWRESAMPLE_LIBRARIES}
#${FFMPEG_LIBAVFILTER_LIBRARIES}
#${FFMPEG_LIBPOSTPROC_LIBRARIES}
)
SET(FFMPEG_RUNTIME_LIBRARIES
${FFMPEG_LIBAVFORMAT_RUNTIME_LIBRARY}
${FFMPEG_LIBAVDEVICE_RUNTIME_LIBRARY}
${FFMPEG_LIBAVCODEC_RUNTIME_LIBRARY}
${FFMPEG_LIBAVUTIL_RUNTIME_LIBRARY}
${FFMPEG_LIBSWSCALE_RUNTIME_LIBRARY}
${FFMPEG_LIBSWRESAMPLE_RUNTIME_LIBRARY}
#${FFMPEG_LIBAVFILTER_RUNTIME_LIBRARY}
#${FFMPEG_LIBPOSTPROC_RUNTIME_LIBRARY}
)
ELSE (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND FFMPEG_LIBSWSCALE_FOUND AND FFMPEG_LIBSWRESAMPLE_FOUND)
message(STATUS "Could not find FFMPEG")
ENDIF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND FFMPEG_LIBSWSCALE_FOUND AND FFMPEG_LIBSWRESAMPLE_FOUND)