forked from rpavlik/cmake-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindDirectShow.cmake
204 lines (181 loc) · 5.53 KB
/
FindDirectShow.cmake
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# - Find Microsoft DirectShow sample files, library, and headers.
#
# DIRECTSHOW_INCLUDE_DIRS - where to find needed include file
# DIRECTSHOW_BASECLASS_DIR- Directory containing the DirectShow baseclass sample code.
# DIRECTSHOW_FOUND - True if DirectShow found.
#
# Requires these CMake modules:
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Initially in VRPN - Distributed under the Boost Software License, Version 1.0.
#
# Almost entirely re-written by:
# 2012 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2012.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# Look for one of the sample files.
set(_ds_quiet)
if(DirectShow_FIND_QUIETLY)
set(_ds_quiet QUIET)
endif()
find_package(WindowsSDK ${_ds_quiet})
find_package(DirectX ${_ds_quiet})
set(DIRECTSHOW_WINDOWSSDK_ROOT
"${DIRECTSHOW_WINDOWSSDK_ROOT}"
CACHE
PATH
"A specific Windows SDK to use for DirectShow.")
if(MSVC AND CMAKE_CL_64)
set(DIRECTSHOW_LIB_SUBDIR /x64)
else()
set(DIRECTSHOW_LIB_SUBDIR)
endif()
set(_acceptable_winsdk)
if(WINDOWSSDK_FOUND)
foreach(_sdkdir ${WINDOWSSDK_DIRS})
if(EXISTS "${_sdkdir}/Samples/Multimedia/DirectShow/BaseClasses/streams.h"
AND EXISTS "${_sdkdir}/Lib${DIRECTSHOW_LIB_SUBDIR}/strmiids.lib"
AND EXISTS "${_sdkdir}/Include/DShow.h")
list(APPEND _acceptable_winsdk "${_sdkdir}")
endif()
endforeach()
endif()
find_path(DIRECTSHOW_BASECLASS_DIR
NAMES
streams.h
HINTS
"${DIRECTSHOW_WINDOWSSDK_ROOT}"
PATHS
${_acceptable_winsdk}
PATH_SUFFIXES
"Samples/Multimedia/DirectShow/BaseClasses")
find_path(DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR
NAMES
DShow.h
HINTS
"${DIRECTSHOW_WINDOWSSDK_ROOT}"
PATHS
${_acceptable_winsdk}
PATH_SUFFIXES
"Include")
###
# Begin code dedicated to finding a proper qedit.h file...
###
# Checks to see if a directory has qedit.h and if that file contains ISampleGrabber.
function(_directshow_check_qedit _dir _var)
set(fn "${_dir}/qedit.h")
if(NOT EXISTS "${fn}")
set(${_var} FALSE PARENT_SCOPE)
return()
endif()
file(STRINGS "${fn}" samplegrabber REGEX ISampleGrabber)
if(NOT samplegrabber)
set(${_var} FALSE PARENT_SCOPE)
return()
endif()
set(${_var} TRUE PARENT_SCOPE)
endfunction()
function(_directshow_check_current_qedit)
if(DIRECTSHOW_QEDIT_INCLUDE_DIR)
_directshow_check_qedit("${DIRECTSHOW_QEDIT_INCLUDE_DIR}" _ds_ok)
if(NOT _ds_ok)
message(STATUS "FindDirectShow: qedit.h in ${DIRECTSHOW_QEDIT_INCLUDE_DIR} lacks ISampleGrabber, unsetting DIRECTSHOW_QEDIT_INCLUDE_DIR")
set(DIRECTSHOW_QEDIT_INCLUDE_DIR "" CACHE PATH "" FORCE)
endif()
endif()
endfunction()
# Check before deciding if we should make our list of possible locations.
_directshow_check_current_qedit()
# Compose a list of possible directories that might hold a qedit.h file.
set(DIRECTSHOW_QEDIT_SEARCH)
if(WINDOWSSDK_FOUND AND NOT DIRECTSHOW_QEDIT_INCLUDE_DIR)
foreach(_sdk ${WINDOWSSDK_DIRS})
windowssdk_build_lookup("${_sdk}" _build)
if(_build AND ("${_build}" VERSION_LESS 6.2))
get_windowssdk_include_dirs("${_sdk}" _dirs)
if(_dirs)
list(APPEND DIRECTSHOW_QEDIT_SEARCH ${_dirs})
endif()
endif()
endforeach()
endif()
# This one we can grab from another SDK version.
find_path(DIRECTSHOW_QEDIT_INCLUDE_DIR
NAMES
qedit.h
HINTS
"${DIRECTSHOW_WINDOWSSDK_ROOT}"
PATHS
${DIRECTSHOW_QEDIT_SEARCH}
PATH_SUFFIXES
"Include")
# Check if the directory is OK after the search.
_directshow_check_current_qedit()
# If we didn't find a proper qedit, manually look through the possibilities.
if(NOT DIRECTSHOW_QEDIT_INCLUDE_DIR)
foreach(_dir "${DIRECTSHOW_WINDOWSSDK_ROOT}/Include" ${DIRECTSHOW_QEDIT_SEARCH})
if(NOT DIRECTSHOW_QEDIT_INCLUDE_DIR)
_directshow_check_qedit("${_dir}" _ds_ok)
if(_ds_ok)
set(DIRECTSHOW_QEDIT_INCLUDE_DIR "${_dir}" CACHE PATH "" FORCE)
endif()
endif()
endforeach()
endif()
###
# End qedit.h section.
###
set(DIRECTSHOW_STRMIIDS_SEARCH)
if(WINDOWSSDK_FOUND AND NOT DIRECTSHOW_STRMIIDS_LIBRARY)
foreach(_sdk ${WINDOWSSDK_DIRS})
get_windowssdk_library_dirs("${_sdk}" _dirs)
if(_dirs)
list(APPEND DIRECTSHOW_STRMIIDS_SEARCH ${_dirs})
endif()
endforeach()
endif()
find_library(DIRECTSHOW_STRMIIDS_LIBRARY
NAMES
strmiids
HINTS
"${DIRECTSHOW_WINDOWSSDK_ROOT}"
PATHS
${DIRECTSHOW_STRMIIDS_SEARCH}
PATH_SUFFIXES
"Lib${DIRECTSHOW_LIB_SUBDIR}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DirectShow
DEFAULT_MSG
DIRECTSHOW_BASECLASS_DIR
DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR
DIRECTSHOW_QEDIT_INCLUDE_DIR
DIRECTX_INCLUDE_DIR
DIRECTSHOW_STRMIIDS_LIBRARY)
if(DIRECTSHOW_FOUND)
set(DIRECTSHOW_INCLUDE_DIRS
# Baseclass must be before SDK so it gets the correct refclock.h
"${DIRECTSHOW_BASECLASS_DIR}"
"${DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR}"
"${DIRECTX_INCLUDE_DIR}"
)
if(EXISTS "${DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR}/atl/atlbase.h")
list(APPEND
DIRECTSHOW_INCLUDE_DIRS
"${DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR}/atl")
endif()
if(NOT "${DIRECTSHOW_QEDIT_INCLUDE_DIR}" STREQUAL "${DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR}")
# QEdit include dir might be an older SDK, so put it last.
list(APPEND DIRECTSHOW_INCLUDE_DIRS "${DIRECTSHOW_QEDIT_INCLUDE_DIR}")
endif()
set(DIRECTSHOW_LIBRARIES "${DIRECTSHOW_STRMIIDS_LIBRARY}")
mark_as_advanced(DIRECTSHOW_WINDOWSSDK_ROOT)
endif()
mark_as_advanced(DIRECTSHOW_BASECLASS_DIR
DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR
DIRECTSHOW_QEDIT_INCLUDE_DIR
DIRECTSHOW_STRMIIDS_LIBRARY)