diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-05-31 23:06:06 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-05-31 23:06:06 -0400 |
commit | 56da5e3fb1579bdb973582516fd7eff7bbfcfe0c (patch) | |
tree | 7cec29258eff080f0c08eb2f847bcce34961ce7b /cmake | |
download | sap-56da5e3fb1579bdb973582516fd7eff7bbfcfe0c.tar.gz sap-56da5e3fb1579bdb973582516fd7eff7bbfcfe0c.tar.bz2 sap-56da5e3fb1579bdb973582516fd7eff7bbfcfe0c.zip |
Initial commit
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindFFMPEG.cmake | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/cmake/FindFFMPEG.cmake b/cmake/FindFFMPEG.cmake new file mode 100644 index 0000000..d7f972e --- /dev/null +++ b/cmake/FindFFMPEG.cmake | |||
@@ -0,0 +1,144 @@ | |||
1 | # - Try to find FFMPEG | ||
2 | # Once done this will define | ||
3 | # FFMPEG_FOUND - System has FFMPEG | ||
4 | # FFMPEG_INCLUDE_DIRS - The FFMPEG include directories | ||
5 | # FFMPEG_LIBRARIES - The libraries needed to use FFMPEG | ||
6 | # FFMPEG_LIBRARY_DIRS - The directory to find FFMPEG libraries | ||
7 | # | ||
8 | # written by Roy Shilkrot 2013 http://www.morethantechnical.com/ | ||
9 | # | ||
10 | |||
11 | find_package(PkgConfig) | ||
12 | |||
13 | |||
14 | MACRO(FFMPEG_FIND varname shortname headername) | ||
15 | |||
16 | IF(NOT WIN32) | ||
17 | PKG_CHECK_MODULES(PC_${varname} ${shortname}) | ||
18 | |||
19 | FIND_PATH(${varname}_INCLUDE_DIR "${shortname}/${headername}" | ||
20 | HINTS ${PC_${varname}_INCLUDEDIR} ${PC_${varname}_INCLUDE_DIRS} | ||
21 | NO_DEFAULT_PATH | ||
22 | ) | ||
23 | ELSE() | ||
24 | FIND_PATH(${varname}_INCLUDE_DIR "${shortname}/${headername}") | ||
25 | ENDIF() | ||
26 | |||
27 | IF(${varname}_INCLUDE_DIR STREQUAL "${varname}_INCLUDE_DIR-NOTFOUND") | ||
28 | message(STATUS "look for newer strcture") | ||
29 | IF(NOT WIN32) | ||
30 | PKG_CHECK_MODULES(PC_${varname} "lib${shortname}") | ||
31 | |||
32 | FIND_PATH(${varname}_INCLUDE_DIR "lib${shortname}/${headername}" | ||
33 | HINTS ${PC_${varname}_INCLUDEDIR} ${PC_${varname}_INCLUDE_DIRS} | ||
34 | NO_DEFAULT_PATH | ||
35 | ) | ||
36 | ELSE() | ||
37 | FIND_PATH(${varname}_INCLUDE_DIR "lib${shortname}/${headername}") | ||
38 | IF(${${varname}_INCLUDE_DIR} STREQUAL "${varname}_INCLUDE_DIR-NOTFOUND") | ||
39 | #Desperate times call for desperate measures | ||
40 | MESSAGE(STATUS "globbing...") | ||
41 | FILE(GLOB_RECURSE ${varname}_INCLUDE_DIR "/ffmpeg*/${headername}") | ||
42 | MESSAGE(STATUS "found: ${${varname}_INCLUDE_DIR}") | ||
43 | IF(${varname}_INCLUDE_DIR) | ||
44 | GET_FILENAME_COMPONENT(${varname}_INCLUDE_DIR "${${varname}_INCLUDE_DIR}" PATH) | ||
45 | GET_FILENAME_COMPONENT(${varname}_INCLUDE_DIR "${${varname}_INCLUDE_DIR}" PATH) | ||
46 | ELSE() | ||
47 | SET(${varname}_INCLUDE_DIR "${varname}_INCLUDE_DIR-NOTFOUND") | ||
48 | ENDIF() | ||
49 | ENDIF() | ||
50 | ENDIF() | ||
51 | ENDIF() | ||
52 | |||
53 | |||
54 | IF(${${varname}_INCLUDE_DIR} STREQUAL "${varname}_INCLUDE_DIR-NOTFOUND") | ||
55 | MESSAGE(STATUS "Can't find includes for ${shortname}...") | ||
56 | ELSE() | ||
57 | MESSAGE(STATUS "Found ${shortname} include dirs: ${${varname}_INCLUDE_DIR}") | ||
58 | |||
59 | # GET_DIRECTORY_PROPERTY(FFMPEG_PARENT DIRECTORY ${${varname}_INCLUDE_DIR} PARENT_DIRECTORY) | ||
60 | GET_FILENAME_COMPONENT(FFMPEG_PARENT ${${varname}_INCLUDE_DIR} PATH) | ||
61 | MESSAGE(STATUS "Using FFMpeg dir parent as hint: ${FFMPEG_PARENT}") | ||
62 | |||
63 | IF(NOT WIN32) | ||
64 | FIND_LIBRARY(${varname}_LIBRARIES NAMES ${shortname} | ||
65 | HINTS ${PC_${varname}_LIBDIR} ${PC_${varname}_LIBRARY_DIR} ${FFMPEG_PARENT}) | ||
66 | ELSE() | ||
67 | # FIND_PATH(${varname}_LIBRARIES "${shortname}.dll.a" HINTS ${FFMPEG_PARENT}) | ||
68 | FILE(GLOB_RECURSE ${varname}_LIBRARIES "${FFMPEG_PARENT}/*${shortname}.lib") | ||
69 | # GLOBing is very bad... but windows sux, this is the only thing that works | ||
70 | ENDIF() | ||
71 | |||
72 | IF(${varname}_LIBRARIES STREQUAL "${varname}_LIBRARIES-NOTFOUND") | ||
73 | MESSAGE(STATUS "look for newer structure for library") | ||
74 | FIND_LIBRARY(${varname}_LIBRARIES NAMES lib${shortname} | ||
75 | HINTS ${PC_${varname}_LIBDIR} ${PC_${varname}_LIBRARY_DIR} ${FFMPEG_PARENT}) | ||
76 | ENDIF() | ||
77 | |||
78 | |||
79 | IF(${varname}_LIBRARIES STREQUAL "${varname}_LIBRARIES-NOTFOUND") | ||
80 | MESSAGE(STATUS "Can't find lib for ${shortname}...") | ||
81 | ELSE() | ||
82 | MESSAGE(STATUS "Found ${shortname} libs: ${${varname}_LIBRARIES}") | ||
83 | ENDIF() | ||
84 | |||
85 | |||
86 | IF(NOT ${varname}_INCLUDE_DIR STREQUAL "${varname}_INCLUDE_DIR-NOTFOUND" | ||
87 | AND NOT ${varname}_LIBRARIES STREQUAL ${varname}_LIBRARIES-NOTFOUND) | ||
88 | |||
89 | MESSAGE(STATUS "found ${shortname}: include ${${varname}_INCLUDE_DIR} lib ${${varname}_LIBRARIES}") | ||
90 | SET(FFMPEG_${varname}_FOUND 1) | ||
91 | SET(FFMPEG_${varname}_INCLUDE_DIRS ${${varname}_INCLUDE_DIR}) | ||
92 | SET(FFMPEG_${varname}_LIBS ${${varname}_LIBRARIES}) | ||
93 | ELSE() | ||
94 | MESSAGE(STATUS "Can't find ${shortname}") | ||
95 | ENDIF() | ||
96 | |||
97 | ENDIF() | ||
98 | |||
99 | ENDMACRO(FFMPEG_FIND) | ||
100 | |||
101 | FFMPEG_FIND(LIBAVFORMAT avformat avformat.h) | ||
102 | FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h) | ||
103 | FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h) | ||
104 | FFMPEG_FIND(LIBAVUTIL avutil avutil.h) | ||
105 | FFMPEG_FIND(LIBSWSCALE swscale swscale.h) | ||
106 | |||
107 | SET(FFMPEG_FOUND "NO") | ||
108 | IF (FFMPEG_LIBAVFORMAT_FOUND AND | ||
109 | FFMPEG_LIBAVDEVICE_FOUND AND | ||
110 | FFMPEG_LIBAVCODEC_FOUND AND | ||
111 | FFMPEG_LIBAVUTIL_FOUND AND | ||
112 | FFMPEG_LIBSWSCALE_FOUND | ||
113 | ) | ||
114 | |||
115 | |||
116 | SET(FFMPEG_FOUND "YES") | ||
117 | |||
118 | SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}) | ||
119 | |||
120 | SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS}) | ||
121 | |||
122 | SET(FFMPEG_LIBRARIES | ||
123 | ${FFMPEG_LIBAVFORMAT_LIBS} | ||
124 | ${FFMPEG_LIBAVDEVICE_LIBS} | ||
125 | ${FFMPEG_LIBAVCODEC_LIBS} | ||
126 | ${FFMPEG_LIBAVUTIL_LIBS} | ||
127 | ${FFMPEG_LIBSWSCALE_LIBS} | ||
128 | ) | ||
129 | |||
130 | ELSE () | ||
131 | |||
132 | MESSAGE(STATUS "Could not find FFMPEG") | ||
133 | |||
134 | ENDIF() | ||
135 | |||
136 | message(STATUS ${FFMPEG_LIBRARIES} ${FFMPEG_LIBAVFORMAT_LIBRARIES}) | ||
137 | |||
138 | include(FindPackageHandleStandardArgs) | ||
139 | # handle the QUIETLY and REQUIRED arguments and set FFMPEG_FOUND to TRUE | ||
140 | # if all listed variables are TRUE | ||
141 | find_package_handle_standard_args(FFMPEG DEFAULT_MSG | ||
142 | FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS) | ||
143 | |||
144 | mark_as_advanced(FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARY_DIRS FFMPEG_LIBRARIES) \ No newline at end of file | ||