4 # Finds the EGL library
6 # This will define the following target:
8 # ${APP_NAME_LC}::EGL - The EGL library
10 if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
11 find_package(PkgConfig)
13 pkg_check_modules(PC_EGL egl QUIET)
16 find_path(EGL_INCLUDE_DIR EGL/egl.h
17 HINTS ${PC_EGL_INCLUDEDIR})
19 find_library(EGL_LIBRARY NAMES EGL egl
20 HINTS ${PC_EGL_LIBDIR})
22 set(EGL_VERSION ${PC_EGL_VERSION})
24 include(FindPackageHandleStandardArgs)
25 find_package_handle_standard_args(EGL
26 REQUIRED_VARS EGL_LIBRARY EGL_INCLUDE_DIR
27 VERSION_VAR EGL_VERSION)
30 list(APPEND GL_INTERFACES_LIST egl egl-pb)
31 set(GL_INTERFACES_LIST ${GL_INTERFACES_LIST} PARENT_SCOPE)
33 set(CMAKE_REQUIRED_INCLUDES "${EGL_INCLUDE_DIR}")
34 include(CheckIncludeFiles)
35 check_include_files("EGL/egl.h;EGL/eglext.h;EGL/eglext_angle.h" HAVE_EGLEXTANGLE)
36 unset(CMAKE_REQUIRED_INCLUDES)
38 if(${EGL_LIBRARY} MATCHES ".+\.so$")
39 add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} SHARED IMPORTED)
41 add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED)
44 set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
45 IMPORTED_LOCATION "${EGL_LIBRARY}"
46 INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}"
47 INTERFACE_COMPILE_DEFINITIONS HAS_EGL
48 IMPORTED_NO_SONAME TRUE)
51 set_property(TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} APPEND PROPERTY
52 INTERFACE_COMPILE_DEFINITIONS HAVE_EGLEXTANGLE)