FindOpenGLES2.cmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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, android NOT TESED
  18. # linux tested and works
  19. IF (WIN32)
  20. IF (CYGWIN)
  21. FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h )
  22. FIND_LIBRARY(OPENGLES2_gl_LIBRARY libGLESv2 )
  23. ELSE (CYGWIN)
  24. IF(BORLAND)
  25. SET (OPENGLES2_gl_LIBRARY import32 CACHE STRING "OpenGL ES 2.x library for win32")
  26. ELSE(BORLAND)
  27. # todo
  28. # SET (OPENGLES_gl_LIBRARY ${SOURCE_DIR}/Dependencies/lib/release/libGLESv2.lib CACHE STRING "OpenGL ES 2.x library for win32"
  29. ENDIF(BORLAND)
  30. ENDIF (CYGWIN)
  31. ELSE (WIN32)
  32. IF (APPLE)
  33. create_search_paths(/Developer/Platforms)
  34. findpkg_framework(OpenGLES2)
  35. set(OPENGLES2_gl_LIBRARY "-framework OpenGLES")
  36. ELSE(APPLE)
  37. FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
  38. /usr/openwin/share/include
  39. /opt/graphics/OpenGL/include /usr/X11R6/include
  40. /usr/include
  41. )
  42. FIND_LIBRARY(OPENGLES2_gl_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. /usr/openwin/share/include
  52. /opt/graphics/OpenGL/include /usr/X11R6/include
  53. /usr/include
  54. )
  55. FIND_LIBRARY(EGL_egl_LIBRARY
  56. NAMES EGL
  57. PATHS /opt/graphics/OpenGL/lib
  58. /usr/openwin/lib
  59. /usr/shlib /usr/X11R6/lib
  60. /usr/lib
  61. )
  62. # On Unix OpenGL most certainly always requires X11.
  63. # Feel free to tighten up these conditions if you don't
  64. # think this is always true.
  65. # It's not true on OSX.
  66. IF (OPENGLES2_gl_LIBRARY)
  67. IF(NOT X11_FOUND)
  68. INCLUDE(FindX11)
  69. ENDIF(NOT X11_FOUND)
  70. IF (X11_FOUND)
  71. IF (NOT APPLE)
  72. SET (OPENGLES2_LIBRARIES ${X11_LIBRARIES})
  73. ENDIF (NOT APPLE)
  74. ENDIF (X11_FOUND)
  75. ENDIF (OPENGLES2_gl_LIBRARY)
  76. ENDIF ()
  77. ENDIF(APPLE)
  78. ENDIF (WIN32)
  79. #SET( OPENGLES2_LIBRARIES ${OPENGLES2_gl_LIBRARY} ${OPENGLES2_LIBRARIES})
  80. IF (BUILD_ANDROID)
  81. IF(OPENGLES2_gl_LIBRARY)
  82. SET( OPENGLES2_LIBRARIES ${OPENGLES2_gl_LIBRARY} ${OPENGLES2_LIBRARIES})
  83. SET( EGL_LIBRARIES)
  84. SET( OPENGLES2_FOUND "YES" )
  85. ENDIF(OPENGLES2_gl_LIBRARY)
  86. ELSE ()
  87. SET( OPENGLES2_LIBRARIES ${OPENGLES2_gl_LIBRARY} ${OPENGLES2_LIBRARIES})
  88. IF(OPENGLES2_gl_LIBRARY AND EGL_egl_LIBRARY)
  89. SET( OPENGLES2_LIBRARIES ${OPENGLES2_gl_LIBRARY} ${OPENGLES2_LIBRARIES})
  90. SET( EGL_LIBRARIES ${EGL_egl_LIBRARY} ${EGL_LIBRARIES})
  91. SET( OPENGLES2_FOUND "YES" )
  92. ENDIF(OPENGLES2_gl_LIBRARY AND EGL_egl_LIBRARY)
  93. ENDIF ()
  94. MARK_AS_ADVANCED(
  95. OPENGLES2_INCLUDE_DIR
  96. OPENGLES2_gl_LIBRARY
  97. EGL_INCLUDE_DIR
  98. EGL_egl_LIBRARY
  99. )
  100. IF(OPENGLES2_FOUND)
  101. MESSAGE(STATUS "Found system opengles2 library ${OPENGLES2_LIBRARIES}")
  102. ELSE ()
  103. SET(OPENGLES2_LIBRARIES "")
  104. ENDIF ()