FindGLEW.cmake 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # Copyright (c) 2009 Boudewijn Rempt <boud@valdyas.org>
  2. #
  3. # Redistribution and use is allowed according to the terms of the BSD license.
  4. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  5. #
  6. # - try to find glew library and include files
  7. # GLEW_INCLUDE_DIR, where to find GL/glew.h, etc.
  8. # GLEW_LIBRARIES, the libraries to link against
  9. # GLEW_FOUND, If false, do not try to use GLEW.
  10. # Also defined, but not for general use are:
  11. # GLEW_GLEW_LIBRARY = the full path to the glew library.
  12. if (WIN32)
  13. if(CYGWIN)
  14. find_path( GLEW_INCLUDE_DIR GL/glew.h)
  15. find_library( GLEW_GLEW_LIBRARY glew32
  16. ${OPENGL_LIBRARY_DIR}
  17. /usr/lib/w32api
  18. /usr/X11R6/lib
  19. )
  20. else(CYGWIN)
  21. find_path( GLEW_INCLUDE_DIR GL/glew.h
  22. $ENV{GLEW_ROOT_PATH}/include
  23. )
  24. find_library( GLEW_GLEW_LIBRARY
  25. NAMES glew glew32
  26. PATHS
  27. $ENV{GLEW_ROOT_PATH}/lib
  28. ${OPENGL_LIBRARY_DIR}
  29. )
  30. endif(CYGWIN)
  31. else (WIN32)
  32. if (APPLE)
  33. # These values for Apple could probably do with improvement.
  34. find_path( GLEW_INCLUDE_DIR glew.h
  35. /System/Library/Frameworks/GLEW.framework/Versions/A/Headers
  36. ${OPENGL_LIBRARY_DIR}
  37. )
  38. set(GLEW_GLEW_LIBRARY "-framework GLEW" CACHE STRING "GLEW library for OSX")
  39. set(GLEW_cocoa_LIBRARY "-framework Cocoa" CACHE STRING "Cocoa framework for OSX")
  40. else (APPLE)
  41. find_path( GLEW_INCLUDE_DIR GL/glew.h
  42. /usr/include/GL
  43. /usr/openwin/share/include
  44. /usr/openwin/include
  45. /usr/X11R6/include
  46. /usr/include/X11
  47. /opt/graphics/OpenGL/include
  48. /opt/graphics/OpenGL/contrib/libglew
  49. )
  50. find_library( GLEW_GLEW_LIBRARY GLEW
  51. /usr/openwin/lib
  52. /usr/X11R6/lib
  53. )
  54. endif (APPLE)
  55. endif (WIN32)
  56. set( GLEW_FOUND "NO" )
  57. if(GLEW_INCLUDE_DIR)
  58. if(GLEW_GLEW_LIBRARY)
  59. # Is -lXi and -lXmu required on all platforms that have it?
  60. # If not, we need some way to figure out what platform we are on.
  61. set( GLEW_LIBRARIES
  62. ${GLEW_GLEW_LIBRARY}
  63. ${GLEW_cocoa_LIBRARY}
  64. )
  65. set( GLEW_FOUND "YES" )
  66. #The following deprecated settings are for backwards compatibility with CMake1.4
  67. set (GLEW_LIBRARY ${GLEW_LIBRARIES})
  68. set (GLEW_INCLUDE_PATH ${GLEW_INCLUDE_DIR})
  69. endif(GLEW_GLEW_LIBRARY)
  70. endif(GLEW_INCLUDE_DIR)
  71. if(GLEW_FOUND)
  72. if(NOT GLEW_FIND_QUIETLY)
  73. message(STATUS "Found Glew: ${GLEW_LIBRARIES}")
  74. endif(NOT GLEW_FIND_QUIETLY)
  75. else(GLEW_FOUND)
  76. if(GLEW_FIND_REQUIRED)
  77. message(FATAL_ERROR "Could not find Glew")
  78. endif(GLEW_FIND_REQUIRED)
  79. endif(GLEW_FOUND)
  80. mark_as_advanced(
  81. GLEW_INCLUDE_DIR
  82. GLEW_GLEW_LIBRARY
  83. GLEW_Xmu_LIBRARY
  84. GLEW_Xi_LIBRARY
  85. )