-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathFindOpenSubdiv.cmake
More file actions
140 lines (126 loc) · 3.96 KB
/
FindOpenSubdiv.cmake
File metadata and controls
140 lines (126 loc) · 3.96 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
# - Find OpenSubdiv library
# Find the native OpenSubdiv includes and library
# This module defines
# OPENSUBDIV_INCLUDE_DIRS, where to find OpenSubdiv headers, Set when
# OPENSUBDIV_INCLUDE_DIR is found.
# OPENSUBDIV_LIBRARIES, libraries to link against to use OpenSubdiv.
# OPENSUBDIV_ROOT_DIR, the base directory to search for OpenSubdiv.
# This can also be an environment variable.
# OPENSUBDIV_FOUND, if false, do not try to use OpenSubdiv.
#
# also defined, but not for general use are
# OPENSUBDIV_LIBRARY, where to find the OpenSubdiv library.
#=============================================================================
# Copyright 2013 Blender Foundation.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# If OPENSUBDIV_ROOT_DIR was defined in the environment, use it.
IF(NOT OPENSUBDIV_ROOT_DIR AND NOT $ENV{OPENSUBDIV_ROOT_DIR} STREQUAL "")
SET(OPENSUBDIV_ROOT_DIR $ENV{OPENSUBDIV_ROOT_DIR})
ENDIF()
SET(_opensubdiv_FIND_COMPONENTS
osdCPU
)
if(OPENSUBDIV_USE_GPU)
list(APPEND
_opensubdiv_FIND_COMPONENTS
osdGPU)
endif()
SET(_opensubdiv_SEARCH_DIRS
${OPENSUBDIV_ROOT_DIR}
/usr/local
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt/lib/opensubdiv
/opt/lib/osd # install_deps.sh
)
FIND_PATH(OPENSUBDIV_INCLUDE_DIR
NAMES
opensubdiv/osd/mesh.h
HINTS
${_opensubdiv_SEARCH_DIRS}
PATH_SUFFIXES
include
)
if(OPENSUBDIV_INCLUDE_DIR AND EXISTS "${OPENSUBDIV_INCLUDE_DIR}/opensubdiv/version.h")
file(STRINGS
${OPENSUBDIV_INCLUDE_DIR}/opensubdiv/version.h
TMP
REGEX "#define OPENSUBDIV_VERSION v.*$"
)
string(REGEX
MATCHALL "[0-9]_[0-9]_[0-9]"
OPENSUBDIV_VERSION
${TMP}
)
string(REPLACE
"_"
"."
OPENSUBDIV_VERSION
${OPENSUBDIV_VERSION}
)
endif()
SET(_opensubdiv_LIBRARIES)
FOREACH(COMPONENT ${_opensubdiv_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
set(_lib_name ${COMPONENT})
if (APPLE AND PXR_BUILD_APPLE_FRAMEWORK)
set(_lib_name lib${COMPONENT}.a)
endif ()
FIND_LIBRARY(OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY
NAMES
${_lib_name}
HINTS
${_opensubdiv_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
if(OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY)
LIST(APPEND
_opensubdiv_LIBRARIES
"${OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY}")
set(OPENSUBDIV_FOUND TRUE)
endif()
ENDFOREACH()
MACRO(OPENSUBDIV_CHECK_CONTROLLER
controller_include_file
variable_name)
IF(EXISTS
"${OPENSUBDIV_INCLUDE_DIR}/opensubdiv/osd/${controller_include_file}"
)
SET(${variable_name} TRUE)
ELSE()
SET(${variable_name} FALSE)
ENDIF()
ENDMACRO()
IF(OPENSUBDIV_FOUND)
SET(OPENSUBDIV_LIBRARIES ${_opensubdiv_LIBRARIES})
SET(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_INCLUDE_DIR})
# Find available compute controllers that USD may want to use.
OPENSUBDIV_CHECK_CONTROLLER("glXFBEvaluator.h" OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK)
OPENSUBDIV_CHECK_CONTROLLER("glComputeEvaluator.h" OPENSUBDIV_HAS_GLSL_COMPUTE)
ENDIF(OPENSUBDIV_FOUND)
MARK_AS_ADVANCED(
OPENSUBDIV_INCLUDE_DIR
)
FOREACH(COMPONENT ${_opensubdiv_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
MARK_AS_ADVANCED(OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY)
ENDFOREACH()
# handle the QUIETLY and REQUIRED arguments and set OPENSUBDIV_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSubdiv
REQUIRED_VARS
OPENSUBDIV_INCLUDE_DIR
OPENSUBDIV_LIBRARIES
VERSION_VAR
OPENSUBDIV_VERSION
)