FindOpenGLES2.cmake 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #-------------------------------------------------------------------
  2. # This file is stolen from part of the CMake build system for OGRE (Object-oriented Graphics Rendering Engine) http://www.ogre3d.org/
  3. #
  4. # The contents of this file are placed in the public domain. Feel
  5. # free to make use of it in any way you like.
  6. #-------------------------------------------------------------------
  7. # - Try to find OpenGLES and EGL
  8. # Once done this will define
  9. #
  10. # OPENGLES2_FOUND - system has OpenGLES
  11. # OPENGLES2_INCLUDE_DIR - the GL include directory
  12. # OPENGLES2_LIBRARIES - Link these to use OpenGLES
  13. #
  14. # EGL_FOUND - system has EGL
  15. # EGL_INCLUDE_DIR - the EGL include directory
  16. # EGL_LIBRARIES - Link these to use EGL
  17. # Win32, Apple, and Android are not tested!
  18. # Linux tested and works
  19. if(WIN32)
  20. if(CYGWIN)
  21. find_path(OPENGLES2_INCLUDE_DIR GLES2/gl2.h)
  22. find_library(OPENGLES2_LIBRARY libGLESv2)
  23. else()
  24. if(BORLAND)
  25. set(OPENGLES2_LIBRARY import32 CACHE STRING "OpenGL ES 2.x library for Win32")
  26. else()
  27. # TODO
  28. # set(OPENGLES_LIBRARY ${SOURCE_DIR}/Dependencies/lib/release/libGLESv2.lib CACHE STRING "OpenGL ES 2.x library for win32"
  29. endif()
  30. endif()
  31. elseif(APPLE)
  32. create_search_paths(/Developer/Platforms)
  33. findpkg_framework(OpenGLES2)
  34. set(OPENGLES2_LIBRARY "-framework OpenGLES")
  35. else()
  36. find_path(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
  37. PATHS /usr/openwin/share/include
  38. /opt/graphics/OpenGL/include
  39. /usr/X11R6/include
  40. /usr/include
  41. )
  42. find_library(OPENGLES2_LIBRARY
  43. NAMES GLESv2
  44. PATHS /opt/graphics/OpenGL/lib
  45. /usr/openwin/lib
  46. /usr/shlib /usr/X11R6/lib
  47. /usr/lib
  48. )
  49. if(NOT BUILD_ANDROID)
  50. find_path(EGL_INCLUDE_DIR EGL/egl.h
  51. PATHS /usr/openwin/share/include
  52. /opt/graphics/OpenGL/include
  53. /usr/X11R6/include
  54. /usr/include
  55. )
  56. find_library(EGL_LIBRARY
  57. NAMES EGL
  58. PATHS /opt/graphics/OpenGL/lib
  59. /usr/openwin/lib
  60. /usr/shlib
  61. /usr/X11R6/lib
  62. /usr/lib
  63. )
  64. # On Unix OpenGL usually requires X11.
  65. # It doesn't require X11 on OSX.
  66. if(OPENGLES2_LIBRARY)
  67. if(NOT X11_FOUND)
  68. include(FindX11)
  69. endif()
  70. if(X11_FOUND)
  71. set(OPENGLES2_LIBRARIES ${X11_LIBRARIES})
  72. endif()
  73. endif()
  74. endif()
  75. endif()
  76. set(OPENGLES2_LIBRARIES ${OPENGLES2_LIBRARIES} ${OPENGLES2_LIBRARY})
  77. if(BUILD_ANDROID)
  78. if(OPENGLES2_LIBRARY)
  79. set(EGL_LIBRARIES)
  80. set(OPENGLES2_FOUND TRUE)
  81. endif()
  82. else()
  83. if(OPENGLES2_LIBRARY AND EGL_LIBRARY)
  84. set(OPENGLES2_LIBRARIES ${OPENGLES2_LIBRARY} ${OPENGLES2_LIBRARIES})
  85. set(EGL_LIBRARIES ${EGL_LIBRARY} ${EGL_LIBRARIES})
  86. set(OPENGLES2_FOUND TRUE)
  87. endif()
  88. endif()
  89. mark_as_advanced(
  90. OPENGLES2_INCLUDE_DIR
  91. OPENGLES2_LIBRARY
  92. EGL_INCLUDE_DIR
  93. EGL_LIBRARY
  94. )
  95. if(OPENGLES2_FOUND)
  96. message(STATUS "Found system OpenGL ES 2 library: ${OPENGLES2_LIBRARIES}")
  97. else()
  98. set(OPENGLES2_LIBRARIES "")
  99. endif()