-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindFFmpeg.cmake
More file actions
157 lines (131 loc) · 6.02 KB
/
FindFFmpeg.cmake
File metadata and controls
157 lines (131 loc) · 6.02 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
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake)
include(${CMAKE_ROOT}/Modules/CMakeFindDependencyMacro.cmake)
find_dependency(Threads)
macro(find_ffmpeg component)
set(libname "lib${component}")
set(headername "${component}.h")
find_path("${libname}_INCLUDE_PATH"
NAMES "${libname}/${headername}"
PATHS "${FFMPEG_DIR}/include"
"~/Library/Frameworks"
"/Library/Frameworks"
"/usr/local/include"
"/usr/include")
mark_as_advanced("${${libname}_INCLUDE_PATH}")
find_library("${libname}_LIBRARY_PATH"
NAMES "${component}"
PATHS "${FFMPEG_DIR}/lib"
"${FFMPEG_DIR}/bin"
"~/Library/Frameworks"
"/Library/Frameworks"
"/usr/local/lib"
"/usr/local/lib64"
"/usr/lib"
"/usr/lib64")
mark_as_advanced("${${libname}_LIBRARY_PATH}")
if(${libname}_INCLUDE_PATH AND ${libname}_LIBRARY_PATH)
file(STRINGS "${${libname}_INCLUDE_PATH}/${libname}/version.h" version_lines
REGEX "#define LIB.+_VERSION_(MAJOR|MINOR|MICRO)[ \t]+[0-9]+")
foreach(line ${version_lines})
if(line MATCHES "MAJOR[ \t]+([0-9]+)")
set(${libname}_MAJOR_VERSION ${CMAKE_MATCH_1})
elseif(line MATCHES "MINOR[ \t]+([0-9]+)")
set(${libname}_MINOR_VERSION ${CMAKE_MATCH_1})
elseif(line MATCHES "MICRO[ \t]+([0-9]+)")
set(${libname}_MICRO_VERSION ${CMAKE_MATCH_1})
endif()
endforeach()
set(FFMPEG_${libname}_FOUND TRUE)
get_filename_component(${libname}_LIBRARY_DIR "${${libname}_LIBRARY_PATH}" DIRECTORY)
endif()
endmacro()
find_ffmpeg(avcodec)
find_ffmpeg(avdevice)
find_ffmpeg(avfilter)
find_ffmpeg(avformat)
find_ffmpeg(avutil)
find_ffmpeg(swresample)
find_ffmpeg(swscale)
set(version_file "${libavutil_INCLUDE_PATH}/libavutil/ffversion.h")
if(EXISTS ${version_file})
file(STRINGS ${version_file} ffmpeg_version
REGEX "#define FFMPEG_VERSION \".+\"")
foreach(line ${ffmpeg_version})
if(line MATCHES "#define FFMPEG_VERSION \"(.+)\"")
set(FFMPEG_VERSION ${CMAKE_MATCH_1})
endif()
endforeach()
endif()
if(FFMPEG_libavcodec_FOUND OR FFMPEG_libavdevice_FOUND OR FFMPEG_libavfilter_FOUND OR FFMPEG_libavformat_FOUND OR FFMPEG_libavutil_FOUND OR FFMPEG_libswresample_FOUND OR FFMPEG_libswscale_FOUND)
list(APPEND FFMPEG_INCLUDE_DIRS
${libavcodec_INCLUDE_PATH}
${libavdevice_INCLUDE_PATH}
${libavfilter_INCLUDE_PATH}
${libavformat_INCLUDE_PATH}
${libavutil_INCLUDE_PATH}
${libswresample_INCLUDE_PATH}
${libswscale_INCLUDE_PATH})
list(APPEND FFMPEG_LIBRARY_DIRS
${libavcodec_LIBRARY_DIR}
${libavdevice_LIBRARY_DIR}
${libavfilter_LIBRARY_DIR}
${libavformat_LIBRARY_DIR}
${libavutil_LIBRARY_DIR}
${libswresample_LIBRARY_DIR}
${libswscale_LIBRARY_DIR})
list(APPEND FFMPEG_LIBRARIES
${libavcodec_LIBRARY_PATH}
${libavdevice_LIBRARY_PATH}
${libavfilter_LIBRARY_PATH}
${libavformat_LIBRARY_PATH}
${libavutil_LIBRARY_PATH}
${libswresample_LIBRARY_PATH}
${libswscale_LIBRARY_PATH})
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
list(REMOVE_DUPLICATES FFMPEG_LIBRARY_DIRS)
list(REMOVE_DUPLICATES FFMPEG_LIBRARIES)
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "")
set(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBRARY_DIRS} CACHE STRING "")
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "")
set(FFMPEG_FOUND TRUE)
# message(STATUS "Found ffmpeg: (found version \"${FFMPEG_VERSION}\")")
# if(FFMPEG_libavcodec_FOUND)
# message(STATUS "Found libavcodec: ${libavcodec_LIBRARY_PATH} (found version \"${libavcodec_MAJOR_VERSION}.${libavcodec_MINOR_VERSION}.${libavcodec_MICRO_VERSION}\")")
# else()
# message(STATUS "Not found libavcodec")
# endif()
# if(FFMPEG_libavdevice_FOUND)
# message(STATUS "Found libavdevice: ${libavdevice_LIBRARY_PATH} (found version \"${libavdevice_MAJOR_VERSION}.${libavdevice_MINOR_VERSION}.${libavdevice_MICRO_VERSION}\")")
# else()
# message(STATUS "Not found libavdevice")
# endif()
# if(FFMPEG_libavfilter_FOUND)
# message(STATUS "Found libavdevice: ${libavdevice_LIBRARY_PATH} (found version \"${libavfilter_MAJOR_VERSION}.${libavfilter_MINOR_VERSION}.${libavfilter_MICRO_VERSION}\")")
# else()
# message(STATUS "Not found libavibavfiltercodec")
# endif()
# if(FFMPEG_libavformat_FOUND)
# message(STATUS "Found libavformat: ${libavformat_LIBRARY_PATH} (found version \"${libavformat_MAJOR_VERSION}.${libavformat_MINOR_VERSION}.${libavformat_MICRO_VERSION}\")")
# else()
# message(STATUS "Not found libavformat")
# endif()
# if(FFMPEG_libavutil_FOUND)
# message(STATUS "Found libavutil: ${libavutil_LIBRARY_PATH} (found version \"${libavutil_MAJOR_VERSION}.${libavutil_MINOR_VERSION}.${libavutil_MICRO_VERSION}\")")
# else()
# message(STATUS "Not found libavutil")
# endif()
# if(FFMPEG_libswresample_FOUND)
# message(STATUS "Found libswresample: ${libswresample_LIBRARY_PATH} (found version \"${libswresample_MAJOR_VERSION}.${libswresample_MINOR_VERSION}.${libswresample_MICRO_VERSION}\")")
# else()
# message(STATUS "Not found libswresample")
# endif()
# if(FFMPEG_libswscale_FOUND)
# message(STATUS "Found libswscale: ${libswscale_LIBRARY_PATH} (found version \"${libswscale_MAJOR_VERSION}.${libswscale_MINOR_VERSION}.${libswscale_MICRO_VERSION}\")")
# else()
# message(STATUS "Not found libswscal")
# endif()
endif()
find_package_handle_standard_args(FFMPEG
REQUIRED_VARS FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES FFMPEG_LIBRARY_DIRS
VERSION_VAR FFMPEG_VERSION)