FindEGL.cmake 1.88 KB
Newer Older
1 2 3
#.rst:
# FindEGL
# -------
4
#
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
# Find the EGL library.
#
# Imported Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines the following :prop_tgt:`IMPORTED` targets:
#
# ``EGL::EGL``
#   The EGL library, if found.
#
# ``EGL::OpenGL``
#   The OpenGL library, if found.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module will set the following variables in your project:
#
# ``EGL_FOUND``
#   System has the EGL library.
# ``EGL_INCLUDE_DIR``
#   The EGL include directory.
# ``EGL_LIBRARY``
#   The libEGL library.
# ``EGL_LIBRARIES``
#   All EGL related libraries, including ``EGL_LIBRARY``.
#
# Hints
# ^^^^^
#
# Set `EGL_ROOT_DIR` to the root directory of an EGL installation.
find_path(EGL_INCLUDE_DIR
  NAMES
    EGL/egl.h
  PATHS
    ${EGL_ROOT_DIR}/include
    /usr/local/include
    /usr/include)
43

44 45 46 47 48 49 50
find_library(EGL_LIBRARY
  NAMES
    EGL
  PATHS
    ${EGL_ROOT_DIR}/lib
    /usr/local/lib
    /usr/lib)
51

52 53 54 55 56 57 58
find_library(EGL_opengl_LIBRARY
  NAMES
   OpenGL
  PATHS
    ${EGL_ROOT_DIR}/lib
    /usr/local/lib
    /usr/lib)
59

60
set(EGL_LIBRARIES ${EGL_LIBRARY} ${EGL_opengl_LIBRARY})
61

62 63 64 65 66
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
  EGL DEFAULT_MSG
  EGL_LIBRARY EGL_opengl_LIBRARY EGL_INCLUDE_DIR)
mark_as_advanced(EGL_ROOT_DIR EGL_INCLUDE_DIR EGL_LIBRARY EGL_opengl_LIBRARY)
67

68 69 70 71 72 73 74
if(EGL_FOUND)
  add_library(EGL::OpenGL UNKNOWN IMPORTED)
  set_target_properties(EGL::OpenGL PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}")
  set_target_properties(EGL::OpenGL PROPERTIES
    IMPORTED_LINK_INTERFACE_LANGUAGES "C"
    IMPORTED_LOCATION "${EGL_opengl_LIBRARY}")
75

76 77 78 79 80 81 82
  add_library(EGL::EGL UNKNOWN IMPORTED)
  set_target_properties(EGL::EGL PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}")
  set_target_properties(EGL::EGL PROPERTIES
    IMPORTED_LINK_INTERFACE_LANGUAGES "C"
    INTERFACE_LINK_LIBRARIES "EGL::OpenGL"
    IMPORTED_LOCATION "${EGL_LIBRARY}")
83
endif()