FindGLUT.cmake 3.0 KB

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