-
Notifications
You must be signed in to change notification settings - Fork 213
/
FindOVR.cmake
223 lines (198 loc) · 5.46 KB
/
FindOVR.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# - try to find Oculus VR's SDK for Oculus Rift support
#
# Cache Variables: (probably not for direct use in your scripts)
# OVR_INCLUDE_DIR
# OVR_SOURCE_DIR
# OVR_LIBRARY
#
# Non-cache variables you might use in your CMakeLists.txt:
# OVR_FOUND
# OVR_INCLUDE_DIRS
# OVR_LIBRARIES
#
# Requires these CMake modules:
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Original Author:
# 2014 Kevin M. Godby <kevin@godby.org>
#
# Copyright 2014, Kevin M. Godby <kevin@godby.org>
#
# 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)
#
# SPDX-License-Identifier: BSL-1.0
set(OVR_ROOT_DIR
"${OVR_ROOT_DIR}"
CACHE
PATH
"Directory to search for Oculus SDK")
# The OVR library is built in a directory tree that varies based on platform,
# architecture, and compiler.
#
# The libraries live in one of the following locations:
#
# Lib/Win32/VS2012/libovrd.lib
# Lib/Win32/VS2012/libovr.lib
# Lib/Win32/VS2013/libovrd.lib
# Lib/Win32/VS2013/libovr.lib
# Lib/Win32/VS2010/libovrd.lib
# Lib/Win32/VS2010/libovr.lib
# Lib/x64/VS2012/libovr64d.lib
# Lib/x64/VS2012/libovr64.lib
# Lib/x64/VS2013/libovr64d.lib
# Lib/x64/VS2013/libovr64.lib
# Lib/x64/VS2010/libovr64d.lib
# Lib/x64/VS2010/libovr64.lib
# Lib/Linux/Release/x86_64/libovr.a
# Lib/Linux/Debug/x86_64/libovr.a
# Lib/Linux/Release/i386/libovr.a
# Lib/Linux/Debug/i386/libovr.a
# Lib/Mac/Release/libovr.a
# Lib/Mac/Debug/libovr.a
set(OVR_LIBRARY_PATH_SUFFIX "Lib")
# Test compiler
if(MSVC10) # Microsoft Visual Studio 2010
set(_ovr_library_compiler "VS2010")
elseif(MSVC11) # Microsoft Visual Studio 2012
set(_ovr_library_compiler "VS2012")
elseif(MSVC12) # Microsoft Visual Studio 2013
set(_ovr_library_compiler "VS2013")
endif()
# Test 32/64 bits
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(_ovr_library_arch "x86_64")
if (WIN32)
set(_ovr_library_arch "x64")
set(_ovr_libname_bitsuffix "64")
endif(WIN32)
else()
set(_ovr_library_arch "i386")
if (WIN32)
set(_ovr_library_arch "Win32")
set(_ovr_libname_bitsuffix "")
endif(WIN32)
endif()
# Test platform
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(OVR_LIBRARY_PATH_SUFFIX_START "Lib/Linux") # needs build type and arch
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(OVR_LIBRARY_PATH_SUFFIX_START "Lib/Mac") # needs build type
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(OVR_LIBRARY_PATH_SUFFIX "Lib/${_ovr_library_arch}/${_ovr_library_compiler}")
endif()
find_library(OVR_LIBRARY_RELEASE
NAMES
ovr${_ovr_libname_bitsuffix}
libovr${_ovr_libname_bitsuffix}
PATHS
"${OVR_ROOT_DIR}"
"${OVR_ROOT_DIR}/LibOVR"
c:/tools/oculus-sdk.install/OculusSDK/LibOVR
PATH_SUFFIXES
${OVR_LIBRARY_PATH_SUFFIX}
${OVR_LIBRARY_PATH_SUFFIX_START}/Release
${OVR_LIBRARY_PATH_SUFFIX_START}/Release/${_ovr_library_arch})
find_library(OVR_LIBRARY_DEBUG
NAMES
ovr${_ovr_libname_bitsuffix}d
libovr${_ovr_libname_bitsuffix}d
PATHS
"${OVR_ROOT_DIR}"
"${OVR_ROOT_DIR}/LibOVR"
c:/tools/oculus-sdk.install/OculusSDK/LibOVR
PATH_SUFFIXES
${OVR_LIBRARY_PATH_SUFFIX}
${OVR_LIBRARY_PATH_SUFFIX_START}/Debug
${OVR_LIBRARY_PATH_SUFFIX_START}/Debug/${_ovr_library_arch})
include(SelectLibraryConfigurations)
select_library_configurations(OVR)
if(OVR_LIBRARY_RELEASE)
get_filename_component(_libdir "${OVR_LIBRARY_RELEASE}" PATH)
endif()
find_path(OVR_INCLUDE_DIR
NAMES
OVR.h
HINTS
"${_libdir}"
"${_libdir}/.."
"${_libdir}/../.."
"${_libdir}/../../.."
PATHS
"${OVR_ROOT_DIR}"
PATH_SUFFIXES
include
Include
)
find_path(OVR_SOURCE_DIR
NAMES
OVR_CAPI.h
HINTS
"${_libdir}"
"${_libdir}/.."
"${_libdir}/../.."
"${_libdir}/../../.."
PATHS
"${OVR_ROOT_DIR}"
PATH_SUFFIXES
Src
)
# Dependencies
set(_ovr_dependency_libraries "")
set(_ovr_dependency_includes "")
if(NOT OPENGL_FOUND)
find_package(OpenGL)
list(APPEND _ovr_dependency_libraries ${OPENGL_LIBRARIES})
list(APPEND _ovr_dependency_includes ${OPENGL_INCLUDE_DIR})
list(APPEND _ovr_dependencies OPENGL_FOUND)
endif()
if(NOT THREADS_FOUND)
find_package(Threads)
list(APPEND _ovr_dependency_libraries ${CMAKE_THREAD_LIBS_INIT})
list(APPEND _ovr_dependencies THREADS_FOUND)
endif()
# Linux-only dependencies
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(NOT X11_FOUND)
find_package(X11)
list(APPEND _ovr_dependency_libraries ${X11_LIBRARIES})
list(APPEND _ovr_dependency_includes ${X11_INCLUDE_DIR})
list(APPEND _ovr_dependencies X11_FOUND)
endif()
if(NOT XRANDR_FOUND)
find_package(Xrandr)
list(APPEND _ovr_dependency_libraries ${XRANDR_LIBRARIES})
list(APPEND _ovr_dependency_includes ${XRANDR_INCLUDE_DIR})
list(APPEND _ovr_dependencies XRANDR_FOUND)
endif()
if(NOT UDEV_FOUND)
find_package(udev)
list(APPEND _ovr_dependency_libraries ${UDEV_LIBRARIES})
list(APPEND _ovr_dependency_includes ${UDEV_INCLUDE_DIR})
list(APPEND _ovr_dependencies UDEV_FOUND)
endif()
endif()
if(WIN32)
#find_library(OVR_WINMM_LIBRARY winmm)
#find_library(OVR_WS2_LIBRARY ws2_32)
list(APPEND _ovr_dependency_libraries winmm ws2_32)#${OVR_WINMM_LIBRARY} ${OVR_WS2_LIBRARY})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OVR
DEFAULT_MSG
OVR_LIBRARY
OVR_INCLUDE_DIR
OVR_SOURCE_DIR
${_ovr_dependencies}
)
if(OVR_FOUND)
set(OVR_LIBRARIES ${OVR_LIBRARY} ${_ovr_dependency_libraries})
set(OVR_INCLUDE_DIRS ${OVR_INCLUDE_DIR} ${OVR_SOURCE_DIR} ${_ovr_dependency_includes})
mark_as_advanced(OVR_ROOT_DIR)
endif()
mark_as_advanced(OVR_INCLUDE_DIR
OVR_SOURCE_DIR
OVR_LIBRARY
OVR_WINMM_LIBRARY
OVR_WS2_LIBRARY)