Removed curl dependency by using cmake internal curl
[platform/upstream/cmake.git] / Modules / FindOpenGL.cmake
1 # - Try to find OpenGL
2 # Once done this will define
3 #
4 #  OPENGL_FOUND        - system has OpenGL
5 #  OPENGL_XMESA_FOUND  - system has XMESA
6 #  OPENGL_GLU_FOUND    - system has GLU
7 #  OPENGL_INCLUDE_DIR  - the GL include directory
8 #  OPENGL_LIBRARIES    - Link these to use OpenGL and GLU
9 #
10 # If you want to use just GL you can use these values
11 #  OPENGL_gl_LIBRARY   - Path to OpenGL Library
12 #  OPENGL_glu_LIBRARY  - Path to GLU Library
13 #
14 # On OSX default to using the framework version of opengl
15 # People will have to change the cache values of OPENGL_glu_LIBRARY
16 # and OPENGL_gl_LIBRARY to use OpenGL with X11 on OSX
17
18 #=============================================================================
19 # Copyright 2001-2009 Kitware, Inc.
20 #
21 # Distributed under the OSI-approved BSD License (the "License");
22 # see accompanying file Copyright.txt for details.
23 #
24 # This software is distributed WITHOUT ANY WARRANTY; without even the
25 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
26 # See the License for more information.
27 #=============================================================================
28 # (To distribute this file outside of CMake, substitute the full
29 #  License text for the above reference.)
30
31 set(_OpenGL_REQUIRED_VARS OPENGL_gl_LIBRARY)
32
33 if (CYGWIN)
34
35   find_path(OPENGL_INCLUDE_DIR GL/gl.h )
36   list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
37
38   find_library(OPENGL_gl_LIBRARY opengl32 )
39
40   find_library(OPENGL_glu_LIBRARY glu32 )
41
42 elseif (WIN32)
43
44   if(BORLAND)
45     set (OPENGL_gl_LIBRARY import32 CACHE STRING "OpenGL library for win32")
46     set (OPENGL_glu_LIBRARY import32 CACHE STRING "GLU library for win32")
47   else()
48     set (OPENGL_gl_LIBRARY opengl32 CACHE STRING "OpenGL library for win32")
49     set (OPENGL_glu_LIBRARY glu32 CACHE STRING "GLU library for win32")
50   endif()
51
52 elseif (APPLE)
53
54   find_library(OPENGL_gl_LIBRARY OpenGL DOC "OpenGL lib for OSX")
55   find_library(OPENGL_glu_LIBRARY AGL DOC "AGL lib for OSX")
56   find_path(OPENGL_INCLUDE_DIR OpenGL/gl.h DOC "Include for OpenGL on OSX")
57   list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
58
59 else()
60   if (CMAKE_SYSTEM_NAME MATCHES "HP-UX")
61     # Handle HP-UX cases where we only want to find OpenGL in either hpux64
62     # or hpux32 depending on if we're doing a 64 bit build.
63     if(CMAKE_SIZEOF_VOID_P EQUAL 4)
64       set(_OPENGL_LIB_PATH
65         /opt/graphics/OpenGL/lib/hpux32/)
66     else()
67       set(_OPENGL_LIB_PATH
68         /opt/graphics/OpenGL/lib/hpux64/
69         /opt/graphics/OpenGL/lib/pa20_64)
70     endif()
71   elseif(CMAKE_SYSTEM_NAME STREQUAL Haiku)
72     set(_OPENGL_LIB_PATH
73       /boot/develop/lib/x86)
74     set(_OPENGL_INCLUDE_PATH
75       /boot/develop/headers/os/opengl)
76   endif()
77
78   # The first line below is to make sure that the proper headers
79   # are used on a Linux machine with the NVidia drivers installed.
80   # They replace Mesa with NVidia's own library but normally do not
81   # install headers and that causes the linking to
82   # fail since the compiler finds the Mesa headers but NVidia's library.
83   # Make sure the NVIDIA directory comes BEFORE the others.
84   #  - Atanas Georgiev <atanas@cs.columbia.edu>
85
86   find_path(OPENGL_INCLUDE_DIR GL/gl.h
87     /usr/share/doc/NVIDIA_GLX-1.0/include
88     /usr/openwin/share/include
89     /opt/graphics/OpenGL/include /usr/X11R6/include
90     ${_OPENGL_INCLUDE_PATH}
91   )
92   list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
93
94   find_path(OPENGL_xmesa_INCLUDE_DIR GL/xmesa.h
95     /usr/share/doc/NVIDIA_GLX-1.0/include
96     /usr/openwin/share/include
97     /opt/graphics/OpenGL/include /usr/X11R6/include
98   )
99
100   find_library(OPENGL_gl_LIBRARY
101     NAMES GL MesaGL
102     PATHS /opt/graphics/OpenGL/lib
103           /usr/openwin/lib
104           /usr/shlib /usr/X11R6/lib
105           ${_OPENGL_LIB_PATH}
106   )
107
108   unset(_OPENGL_INCLUDE_PATH)
109   unset(_OPENGL_LIB_PATH)
110
111   # On Unix OpenGL most certainly always requires X11.
112   # Feel free to tighten up these conditions if you don't
113   # think this is always true.
114
115   if (OPENGL_gl_LIBRARY)
116     if(NOT X11_FOUND)
117       include(${CMAKE_CURRENT_LIST_DIR}/FindX11.cmake)
118     endif()
119     if (X11_FOUND)
120       set (OPENGL_LIBRARIES ${X11_LIBRARIES})
121     endif ()
122   endif ()
123
124   find_library(OPENGL_glu_LIBRARY
125     NAMES GLU MesaGLU
126     PATHS ${OPENGL_gl_LIBRARY}
127           /opt/graphics/OpenGL/lib
128           /usr/openwin/lib
129           /usr/shlib /usr/X11R6/lib
130   )
131
132 endif ()
133
134 if(OPENGL_gl_LIBRARY)
135
136     if(OPENGL_xmesa_INCLUDE_DIR)
137       set( OPENGL_XMESA_FOUND "YES" )
138     else()
139       set( OPENGL_XMESA_FOUND "NO" )
140     endif()
141
142     set( OPENGL_LIBRARIES  ${OPENGL_gl_LIBRARY} ${OPENGL_LIBRARIES})
143     if(OPENGL_glu_LIBRARY)
144       set( OPENGL_GLU_FOUND "YES" )
145       set( OPENGL_LIBRARIES ${OPENGL_glu_LIBRARY} ${OPENGL_LIBRARIES} )
146     else()
147       set( OPENGL_GLU_FOUND "NO" )
148     endif()
149
150     # This deprecated setting is for backward compatibility with CMake1.4
151     set (OPENGL_LIBRARY ${OPENGL_LIBRARIES})
152
153 endif()
154
155 # This deprecated setting is for backward compatibility with CMake1.4
156 set(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR})
157
158 # handle the QUIETLY and REQUIRED arguments and set OPENGL_FOUND to TRUE if
159 # all listed variables are TRUE
160 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
161 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL REQUIRED_VARS ${_OpenGL_REQUIRED_VARS})
162 unset(_OpenGL_REQUIRED_VARS)
163
164 mark_as_advanced(
165   OPENGL_INCLUDE_DIR
166   OPENGL_xmesa_INCLUDE_DIR
167   OPENGL_glu_LIBRARY
168   OPENGL_gl_LIBRARY
169 )