11658
|
1 |
#.rst:
|
|
2 |
# FindOpenGL
|
|
3 |
# ----------
|
|
4 |
#
|
|
5 |
# FindModule for OpenGL and GLU.
|
|
6 |
#
|
|
7 |
# Result Variables
|
|
8 |
# ^^^^^^^^^^^^^^^^
|
|
9 |
#
|
|
10 |
# This module sets the following variables:
|
|
11 |
#
|
|
12 |
# ``OPENGL_FOUND``
|
|
13 |
# True, if the system has OpenGL.
|
|
14 |
# ``OPENGL_XMESA_FOUND``
|
|
15 |
# True, if the system has XMESA.
|
|
16 |
# ``OPENGL_GLU_FOUND``
|
|
17 |
# True, if the system has GLU.
|
|
18 |
# ``OPENGL_INCLUDE_DIR``
|
|
19 |
# Path to the OpenGL include directory.
|
|
20 |
# ``OPENGL_LIBRARIES``
|
|
21 |
# Paths to the OpenGL and GLU libraries.
|
|
22 |
#
|
|
23 |
# If you want to use just GL you can use these values:
|
|
24 |
#
|
|
25 |
# ``OPENGL_gl_LIBRARY``
|
|
26 |
# Path to the OpenGL library.
|
|
27 |
# ``OPENGL_glu_LIBRARY``
|
|
28 |
# Path to the GLU library.
|
|
29 |
#
|
|
30 |
# OSX Specific
|
|
31 |
# ^^^^^^^^^^^^
|
|
32 |
#
|
|
33 |
# On OSX default to using the framework version of OpenGL. People will
|
|
34 |
# have to change the cache values of OPENGL_glu_LIBRARY and
|
|
35 |
# OPENGL_gl_LIBRARY to use OpenGL with X11 on OSX.
|
|
36 |
|
|
37 |
|
|
38 |
#=============================================================================
|
|
39 |
# Copyright 2001-2009 Kitware, Inc.
|
|
40 |
#
|
|
41 |
# Distributed under the OSI-approved BSD License (the "License");
|
|
42 |
# see accompanying file Copyright.txt for details.
|
|
43 |
#
|
|
44 |
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
45 |
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
46 |
# See the License for more information.
|
|
47 |
#=============================================================================
|
|
48 |
# (To distribute this file outside of CMake, substitute the full
|
|
49 |
# License text for the above reference.)
|
|
50 |
|
|
51 |
set(_OpenGL_REQUIRED_VARS OPENGL_gl_LIBRARY)
|
|
52 |
|
|
53 |
if (CYGWIN)
|
|
54 |
|
|
55 |
find_path(OPENGL_INCLUDE_DIR GL/gl.h )
|
|
56 |
list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
|
|
57 |
|
|
58 |
find_library(OPENGL_gl_LIBRARY opengl32 )
|
|
59 |
|
|
60 |
find_library(OPENGL_glu_LIBRARY glu32 )
|
|
61 |
|
|
62 |
elseif (WIN32)
|
|
63 |
|
|
64 |
if(BORLAND)
|
|
65 |
set (OPENGL_gl_LIBRARY import32 CACHE STRING "OpenGL library for win32")
|
|
66 |
set (OPENGL_glu_LIBRARY import32 CACHE STRING "GLU library for win32")
|
|
67 |
else()
|
|
68 |
set (OPENGL_gl_LIBRARY opengl32 CACHE STRING "OpenGL library for win32")
|
|
69 |
set (OPENGL_glu_LIBRARY glu32 CACHE STRING "GLU library for win32")
|
|
70 |
endif()
|
|
71 |
|
|
72 |
elseif (APPLE)
|
|
73 |
|
|
74 |
# The OpenGL.framework provides both gl and glu
|
|
75 |
find_library(OPENGL_gl_LIBRARY OpenGL DOC "OpenGL library for OS X")
|
|
76 |
find_library(OPENGL_glu_LIBRARY OpenGL DOC
|
|
77 |
"GLU library for OS X (usually same as OpenGL library)")
|
|
78 |
find_path(OPENGL_INCLUDE_DIR OpenGL/gl.h DOC "Include for OpenGL on OS X")
|
|
79 |
list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
|
|
80 |
|
|
81 |
else()
|
|
82 |
if (CMAKE_SYSTEM_NAME MATCHES "HP-UX")
|
|
83 |
# Handle HP-UX cases where we only want to find OpenGL in either hpux64
|
|
84 |
# or hpux32 depending on if we're doing a 64 bit build.
|
|
85 |
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
86 |
set(_OPENGL_LIB_PATH
|
|
87 |
/opt/graphics/OpenGL/lib/hpux32/)
|
|
88 |
else()
|
|
89 |
set(_OPENGL_LIB_PATH
|
|
90 |
/opt/graphics/OpenGL/lib/hpux64/
|
|
91 |
/opt/graphics/OpenGL/lib/pa20_64)
|
|
92 |
endif()
|
|
93 |
elseif(CMAKE_SYSTEM_NAME STREQUAL Haiku)
|
|
94 |
set(_OPENGL_LIB_PATH
|
|
95 |
/boot/develop/lib/x86)
|
|
96 |
set(_OPENGL_INCLUDE_PATH
|
|
97 |
/boot/develop/headers/os/opengl)
|
|
98 |
endif()
|
|
99 |
|
|
100 |
# The first line below is to make sure that the proper headers
|
|
101 |
# are used on a Linux machine with the NVidia drivers installed.
|
|
102 |
# They replace Mesa with NVidia's own library but normally do not
|
|
103 |
# install headers and that causes the linking to
|
|
104 |
# fail since the compiler finds the Mesa headers but NVidia's library.
|
|
105 |
# Make sure the NVIDIA directory comes BEFORE the others.
|
|
106 |
# - Atanas Georgiev <atanas@cs.columbia.edu>
|
|
107 |
|
|
108 |
find_path(OPENGL_INCLUDE_DIR GL/gl.h
|
|
109 |
/usr/share/doc/NVIDIA_GLX-1.0/include
|
|
110 |
/usr/openwin/share/include
|
|
111 |
/opt/graphics/OpenGL/include /usr/X11R6/include
|
|
112 |
${_OPENGL_INCLUDE_PATH}
|
|
113 |
)
|
|
114 |
list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
|
|
115 |
|
|
116 |
find_path(OPENGL_xmesa_INCLUDE_DIR GL/xmesa.h
|
|
117 |
/usr/share/doc/NVIDIA_GLX-1.0/include
|
|
118 |
/usr/openwin/share/include
|
|
119 |
/opt/graphics/OpenGL/include /usr/X11R6/include
|
|
120 |
)
|
|
121 |
|
|
122 |
find_library(OPENGL_gl_LIBRARY
|
|
123 |
NAMES GL MesaGL
|
|
124 |
PATHS /opt/graphics/OpenGL/lib
|
|
125 |
/usr/openwin/lib
|
|
126 |
/usr/shlib /usr/X11R6/lib
|
|
127 |
${_OPENGL_LIB_PATH}
|
|
128 |
)
|
|
129 |
|
|
130 |
unset(_OPENGL_INCLUDE_PATH)
|
|
131 |
unset(_OPENGL_LIB_PATH)
|
|
132 |
|
|
133 |
find_library(OPENGL_glu_LIBRARY
|
|
134 |
NAMES GLU MesaGLU
|
|
135 |
PATHS ${OPENGL_gl_LIBRARY}
|
|
136 |
/opt/graphics/OpenGL/lib
|
|
137 |
/usr/openwin/lib
|
|
138 |
/usr/shlib /usr/X11R6/lib
|
|
139 |
)
|
|
140 |
|
|
141 |
endif ()
|
|
142 |
|
|
143 |
if(OPENGL_gl_LIBRARY)
|
|
144 |
|
|
145 |
if(OPENGL_xmesa_INCLUDE_DIR)
|
|
146 |
set( OPENGL_XMESA_FOUND "YES" )
|
|
147 |
else()
|
|
148 |
set( OPENGL_XMESA_FOUND "NO" )
|
|
149 |
endif()
|
|
150 |
|
|
151 |
set( OPENGL_LIBRARIES ${OPENGL_gl_LIBRARY} ${OPENGL_LIBRARIES})
|
|
152 |
if(OPENGL_glu_LIBRARY)
|
|
153 |
set( OPENGL_GLU_FOUND "YES" )
|
|
154 |
if(NOT "${OPENGL_glu_LIBRARY}" STREQUAL "${OPENGL_gl_LIBRARY}")
|
|
155 |
set( OPENGL_LIBRARIES ${OPENGL_glu_LIBRARY} ${OPENGL_LIBRARIES} )
|
|
156 |
endif()
|
|
157 |
else()
|
|
158 |
set( OPENGL_GLU_FOUND "NO" )
|
|
159 |
endif()
|
|
160 |
|
|
161 |
# This deprecated setting is for backward compatibility with CMake1.4
|
|
162 |
set (OPENGL_LIBRARY ${OPENGL_LIBRARIES})
|
|
163 |
|
|
164 |
endif()
|
|
165 |
|
|
166 |
# This deprecated setting is for backward compatibility with CMake1.4
|
|
167 |
set(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR})
|
|
168 |
|
|
169 |
if(BUILD_ENGINE_JS)
|
|
170 |
# The implementation is based on the standard FindOpenGL.cmake provided
|
|
171 |
# with CMake, but customized for targeting Emscripten only.
|
|
172 |
|
|
173 |
# These libraries are provided with Emscripten
|
|
174 |
SET(OPENGL_FOUND TRUE)
|
|
175 |
SET(OPENGL_GLU_FOUND TRUE)
|
|
176 |
|
|
177 |
# Doesn't look like this one is part of Emscripten
|
|
178 |
SET(OPENGL_XMESA_FOUND FALSE)
|
|
179 |
|
|
180 |
# This is the path where <GL/gl.h> is found
|
|
181 |
SET(OPENGL_INCLUDE_DIR "${EMSCRIPTEN_ROOT_PATH}/system/include")
|
|
182 |
|
|
183 |
# No library to link against for OpenGL, since Emscripten picks it up
|
|
184 |
# automatically from library_gl.js, but need to report something, or
|
|
185 |
# CMake thinks we failed in the search.
|
|
186 |
SET(OPENGL_LIBRARIES "opengl_emscripten_internal")
|
|
187 |
SET(OPENGL_gl_LIBRARY "gl_emscripten_internal")
|
|
188 |
SET(OPENGL_glu_LIBRARY "glu_emscripten_internal")
|
|
189 |
|
|
190 |
mark_as_advanced(
|
|
191 |
OPENGL_INCLUDE_DIR
|
|
192 |
OPENGL_glu_LIBRARY
|
|
193 |
OPENGL_gl_LIBRARY
|
|
194 |
)
|
|
195 |
endif()
|
|
196 |
|
|
197 |
# handle the QUIETLY and REQUIRED arguments and set OPENGL_FOUND to TRUE if
|
|
198 |
# all listed variables are TRUE
|
|
199 |
INCLUDE(FindPackageHandleStandardArgs)
|
|
200 |
|
|
201 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL REQUIRED_VARS ${_OpenGL_REQUIRED_VARS})
|
|
202 |
unset(_OpenGL_REQUIRED_VARS)
|
|
203 |
|
|
204 |
mark_as_advanced(
|
|
205 |
OPENGL_INCLUDE_DIR
|
|
206 |
OPENGL_xmesa_INCLUDE_DIR
|
|
207 |
OPENGL_glu_LIBRARY
|
|
208 |
OPENGL_gl_LIBRARY
|
|
209 |
)
|