OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I686LINUX / util / I686LINUX / share / CMake / Modules / FindOpenGL.cmake
1 # Try to find OpenGL
2 # Once done this will define
3 #
4 # OPENGL_FOUND        - system has OpenGL and it should be used
5 # OPENGL_XMESA_FOUND  - system has XMESA, and it should be used.
6 # OPENGL_GLU_FOUND    - system has GLU and it should be used.
7 # OPENGL_INCLUDE_DIR  - where the GL include directory can be found
8 # OPENGL_LIBRARIES    - Link these to use OpenGL
9 #
10 #
11 # Also defined, but not for general use are
12 # OPENGL_gl_LIBRARY   - Path to OpenGL Library
13 # OPENGL_glu_LIBRARY  - Path to GLU Library
14 #
15
16 # On OSX default to using the framework version of opengl
17 # People will have to change the cache values of OPENGL_glu_LIBRARY 
18 # and OPENGL_gl_LIBRARY to use OpenGL with X11 on OSX
19 IF (APPLE)
20   SET (OPENGL_gl_LIBRARY "-framework OpenGL" CACHE STRING "OpenGL lib for OSX")
21   SET (OPENGL_glu_LIBRARY "-framework AGL" CACHE STRING "AGL lib for OSX")
22 ENDIF (APPLE)
23
24 IF (WIN32)
25   IF (CYGWIN)
26
27     FIND_PATH(OPENGL_INCLUDE_DIR GL/gl.h
28       /usr/include
29       /usr/include/w32api
30       /usr/X11R6/include
31     )
32
33     FIND_LIBRARY(OPENGL_gl_LIBRARY opengl32
34       /usr/lib
35       /usr/lib/w32api
36     )
37
38     FIND_LIBRARY(OPENGL_glu_LIBRARY glu32
39       /usr/lib
40       /usr/lib/w32api
41     )
42
43   ELSE (CYGWIN)
44
45     IF(BORLAND)
46       SET (OPENGL_gl_LIBRARY import32 CACHE STRING "OpenGL library for win32")
47       SET (OPENGL_glu_LIBRARY import32 CACHE STRING "GLU library for win32")
48     ELSE(BORLAND)
49       SET (OPENGL_gl_LIBRARY opengl32 CACHE STRING "OpenGL library for win32")
50       SET (OPENGL_glu_LIBRARY glu32 CACHE STRING "GLU library for win32")
51     ENDIF(BORLAND)
52
53   ENDIF (CYGWIN)
54
55 ELSE (WIN32)
56
57   # The first line below is to make sure that the proper headers
58   # are used on a Linux machine with the NVidia drivers installed.
59   # They replace Mesa with NVidia's own library but normally do not
60   # install headers and that causes the linking to
61   # fail since the compiler finds the Mesa headers but NVidia's library.
62   # Make sure the NVIDIA directory comes BEFORE the others.
63   #  - Atanas Georgiev <atanas@cs.columbia.edu>
64
65   FIND_PATH(OPENGL_INCLUDE_DIR GL/gl.h
66     /usr/share/doc/NVIDIA_GLX-1.0/include
67     /usr/include
68     /usr/local/include
69     /usr/openwin/share/include
70     /opt/graphics/OpenGL/include
71     /usr/X11R6/include
72   )
73
74   FIND_PATH(OPENGL_xmesa_INCLUDE_DIR GL/xmesa.h
75     /usr/share/doc/NVIDIA_GLX-1.0/include
76     /usr/include
77     /usr/local/include
78     /usr/openwin/share/include
79     /opt/graphics/OpenGL/include
80     /usr/X11R6/include
81   )
82
83   FIND_LIBRARY(OPENGL_gl_LIBRARY
84     NAMES MesaGL GL
85     PATHS /usr/lib
86           /usr/local/lib
87           /opt/graphics/OpenGL/lib
88           /usr/openwin/lib
89           /usr/X11R6/lib
90   )
91
92   # On Unix OpenGL most certainly always requires X11.
93   # Feel free to tighten up these conditions if you don't 
94   # think this is always true.
95
96   IF (OPENGL_gl_LIBRARY)
97     INCLUDE( ${CMAKE_ROOT}/Modules/FindX11.cmake )
98     IF (X11_FOUND)
99       SET (OPENGL_LIBRARIES ${X11_LIBRARIES})
100     ENDIF (X11_FOUND)
101   ENDIF (OPENGL_gl_LIBRARY)
102
103   FIND_LIBRARY(OPENGL_glu_LIBRARY
104     NAMES MesaGLU GLU
105     PATHS ${OPENGL_gl_LIBRARY}
106           /usr/lib
107           /usr/local/lib
108           /opt/graphics/OpenGL/lib
109           /usr/openwin/lib
110           /usr/X11R6/lib
111   )
112
113 ENDIF (WIN32)
114
115 SET( OPENGL_FOUND "NO" )
116 IF(OPENGL_gl_LIBRARY)
117
118     IF(OPENGL_xmesa_INCLUDE_DIR)
119       SET( OPENGL_XMESA_FOUND "YES" )
120     ELSE(OPENGL_xmesa_INCLUDE_DIR)
121       SET( OPENGL_XMESA_FOUND "NO" )
122     ENDIF(OPENGL_xmesa_INCLUDE_DIR)
123
124     SET( OPENGL_LIBRARIES  ${OPENGL_gl_LIBRARY} ${OPENGL_LIBRARIES})
125     IF(OPENGL_glu_LIBRARY)
126       SET( OPENGL_GLU_FOUND "YES" )
127       SET( OPENGL_LIBRARIES ${OPENGL_glu_LIBRARY} ${OPENGL_LIBRARIES} )
128     ELSE(OPENGL_glu_LIBRARY)
129       SET( OPENGL_GLU_FOUND "NO" )
130     ENDIF(OPENGL_glu_LIBRARY)
131
132     SET( OPENGL_FOUND "YES" )
133
134     # This deprecated setting is for backward compatibility with CMake1.4
135
136     SET (OPENGL_LIBRARY ${OPENGL_LIBRARIES})
137
138 ENDIF(OPENGL_gl_LIBRARY)
139
140 # This deprecated setting is for backward compatibility with CMake1.4
141 SET(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR})
142
143 MARK_AS_ADVANCED(
144   OPENGL_INCLUDE_DIR
145   OPENGL_xmesa_INCLUDE_DIR
146   OPENGL_glu_LIBRARY
147   OPENGL_gl_LIBRARY
148 )