aboutsummaryrefslogtreecommitdiff
path: root/cmake/modules/FindEGL.cmake
blob: 0b73eb80bc67ca5f38155462f185f827ef6d2780 (plain)
1
2
3
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
43
44
45
46
47
48
49
50
51
52
#.rst:
# FindEGL
# -------
# Finds the EGL library
#
# This will define the following variables::
#
# EGL_FOUND - system has EGL
# EGL_INCLUDE_DIRS - the EGL include directory
# EGL_LIBRARIES - the EGL libraries
# EGL_DEFINITIONS - the EGL definitions
#
# and the following imported targets::
#
#   EGL::EGL   - The EGL library

if(CORE_PLATFORM_NAME_LC STREQUAL rbpi)
    set(_brcmprefix brcm)
endif()

if(PKG_CONFIG_FOUND)
  pkg_check_modules(PC_EGL ${_brcmprefix}egl QUIET)
endif()

find_path(EGL_INCLUDE_DIR EGL/egl.h
                          PATHS ${PC_EGL_INCLUDEDIR})

find_library(EGL_LIBRARY NAMES ${_brcmprefix}EGL egl
                         PATHS ${PC_EGL_LIBDIR})

set(EGL_VERSION ${PC_EGL_VERSION})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(EGL
                                  REQUIRED_VARS EGL_LIBRARY EGL_INCLUDE_DIR
                                  VERSION_VAR EGL_VERSION)

if(EGL_FOUND)
  set(EGL_LIBRARIES ${EGL_LIBRARY})
  set(EGL_INCLUDE_DIRS ${EGL_INCLUDE_DIR})
  set(EGL_DEFINITIONS -DHAS_EGL=1)

  if(NOT TARGET EGL::EGL)
    add_library(EGL::EGL UNKNOWN IMPORTED)
    set_target_properties(EGL::EGL PROPERTIES
                                   IMPORTED_LOCATION "${EGL_LIBRARY}"
                                   INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}"
                                   INTERFACE_COMPILE_DEFINITIONS HAS_EGL=1)
  endif()
endif()

mark_as_advanced(EGL_INCLUDE_DIR EGL_LIBRARY)