Imported Upstream version 2.8.11.2
[platform/upstream/cmake.git] / Modules / FindGLUT.cmake
1 # - try to find glut library and include files
2 #  GLUT_INCLUDE_DIR, where to find GL/glut.h, etc.
3 #  GLUT_LIBRARIES, the libraries to link against
4 #  GLUT_FOUND, If false, do not try to use GLUT.
5 # Also defined, but not for general use are:
6 #  GLUT_glut_LIBRARY = the full path to the glut library.
7 #  GLUT_Xmu_LIBRARY  = the full path to the Xmu library.
8 #  GLUT_Xi_LIBRARY   = the full path to the Xi Library.
9
10 #=============================================================================
11 # Copyright 2001-2009 Kitware, Inc.
12 #
13 # Distributed under the OSI-approved BSD License (the "License");
14 # see accompanying file Copyright.txt for details.
15 #
16 # This software is distributed WITHOUT ANY WARRANTY; without even the
17 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 # See the License for more information.
19 #=============================================================================
20 # (To distribute this file outside of CMake, substitute the full
21 #  License text for the above reference.)
22
23 if (WIN32)
24   find_path( GLUT_INCLUDE_DIR NAMES GL/glut.h
25     PATHS  ${GLUT_ROOT_PATH}/include )
26   find_library( GLUT_glut_LIBRARY NAMES glut glut32 freeglut
27     PATHS
28     ${OPENGL_LIBRARY_DIR}
29     ${GLUT_ROOT_PATH}/Release
30     )
31 else ()
32
33   if (APPLE)
34     # These values for Apple could probably do with improvement.
35     find_path( GLUT_INCLUDE_DIR glut.h
36       /System/Library/Frameworks/GLUT.framework/Versions/A/Headers
37       ${OPENGL_LIBRARY_DIR}
38       )
39     set(GLUT_glut_LIBRARY "-framework GLUT" CACHE STRING "GLUT library for OSX")
40     set(GLUT_cocoa_LIBRARY "-framework Cocoa" CACHE STRING "Cocoa framework for OSX")
41   else ()
42
43     if (BEOS)
44
45       set(_GLUT_INC_DIR /boot/develop/headers/os/opengl)
46       set(_GLUT_glut_LIB_DIR /boot/develop/lib/x86)
47
48     else()
49
50       find_library( GLUT_Xi_LIBRARY Xi
51         /usr/openwin/lib
52         )
53
54       find_library( GLUT_Xmu_LIBRARY Xmu
55         /usr/openwin/lib
56         )
57
58     endif ()
59
60     find_path( GLUT_INCLUDE_DIR GL/glut.h
61       /usr/include/GL
62       /usr/openwin/share/include
63       /usr/openwin/include
64       /opt/graphics/OpenGL/include
65       /opt/graphics/OpenGL/contrib/libglut
66       ${_GLUT_INC_DIR}
67       )
68
69     find_library( GLUT_glut_LIBRARY glut
70       /usr/openwin/lib
71       ${_GLUT_glut_LIB_DIR}
72       )
73
74     unset(_GLUT_INC_DIR)
75     unset(_GLUT_glut_LIB_DIR)
76
77   endif ()
78
79 endif ()
80
81 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
82 FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLUT REQUIRED_VARS GLUT_glut_LIBRARY GLUT_INCLUDE_DIR)
83
84 if (GLUT_FOUND)
85   # Is -lXi and -lXmu required on all platforms that have it?
86   # If not, we need some way to figure out what platform we are on.
87   set( GLUT_LIBRARIES
88     ${GLUT_glut_LIBRARY}
89     ${GLUT_Xmu_LIBRARY}
90     ${GLUT_Xi_LIBRARY}
91     ${GLUT_cocoa_LIBRARY}
92     )
93
94   #The following deprecated settings are for backwards compatibility with CMake1.4
95   set (GLUT_LIBRARY ${GLUT_LIBRARIES})
96   set (GLUT_INCLUDE_PATH ${GLUT_INCLUDE_DIR})
97 endif()
98
99 mark_as_advanced(
100   GLUT_INCLUDE_DIR
101   GLUT_glut_LIBRARY
102   GLUT_Xmu_LIBRARY
103   GLUT_Xi_LIBRARY
104   )