Ghost Context Refactor
[blender-staging.git] / build_files / cmake / Modules / FindOpenGLES.cmake
1 # - Try to find OpenGLES
2 # Once done this will define
3 #
4 #  OPENGLES_FOUND           - system has OpenGLES and EGL
5 #  OPENGL_EGL_FOUND         - system has EGL
6 #  OPENGLES_INCLUDE_DIR     - the GLES include directory
7 #  OPENGLES_LIBRARY         - the GLES library
8 #  OPENGLES_EGL_INCLUDE_DIR - the EGL include directory
9 #  OPENGLES_EGL_LIBRARY     - the EGL library
10 #  OPENGLES_LIBRARIES       - all libraries needed for OpenGLES
11 #  OPENGLES_INCLUDES        - all includes needed for OpenGLES
12
13 # If OPENGLES_ROOT_DIR was defined in the environment, use it.
14 IF(NOT OPENGLES_ROOT_DIR AND NOT $ENV{OPENGLES_ROOT_DIR} STREQUAL "")
15   SET(OPENGLES_ROOT_DIR $ENV{OPENGLES_ROOT_DIR})
16 ENDIF()
17
18 SET(_opengles_SEARCH_DIRS
19   ${OPENGLES_ROOT_DIR}
20   /usr/local
21 )
22
23 FIND_PATH(OPENGLES_INCLUDE_DIR
24   NAMES
25     GLES2/gl2.h
26   HINTS
27     ${_opengles_SEARCH_DIRS}
28 )
29
30 FIND_LIBRARY(OPENGLES_LIBRARY
31   NAMES
32     GLESv2
33   PATHS
34     ${_opengles_SEARCH_DIRS}
35   PATH_SUFFIXES
36     lib64 lib
37 )
38
39 FIND_PATH(OPENGLES_EGL_INCLUDE_DIR
40   NAMES
41     EGL/egl.h
42   HINTS
43     ${_opengles_SEARCH_DIRS}
44 )
45
46 FIND_LIBRARY(OPENGLES_EGL_LIBRARY
47   NAMES
48     EGL
49   HINTS
50     ${_opengles_SEARCH_DIRS}
51   PATH_SUFFIXES
52     lib64 lib
53 )
54
55 IF(OPENGLES_EGL_LIBRARY AND OPENGLES_EGL_INCLUDE_DIR)
56   SET(OPENGL_EGL_FOUND "YES")
57 ELSE()
58   SET(OPENGL_EGL_FOUND "NO")
59 ENDIF()
60
61 IF(OPENGLES_LIBRARY AND OPENGLES_INCLUDE_DIR AND
62    OPENGLES_EGL_LIBRARY AND OPENGLES_EGL_INCLUDE_DIR)
63   SET(OPENGLES_LIBRARIES ${OPENGLES_LIBRARY} ${OPENGLES_LIBRARIES}
64                            ${OPENGLES_EGL_LIBRARY})
65   SET(OPENGLES_INCLUDES ${OPENGLES_INCLUDE_DIR} ${OPENGLES_EGL_INCLUDE_DIR})
66   SET(OPENGLES_FOUND "YES")
67 ELSE()
68   SET(OPENGLES_FOUND "NO")
69 ENDIF()
70
71 MARK_AS_ADVANCED(
72   OPENGLES_EGL_INCLUDE_DIR
73   OPENGLES_EGL_LIBRARY
74   OPENGLES_INCLUDE_DIR
75 )
76