-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'rpavlik:main' into main
- Loading branch information
Showing
3 changed files
with
302 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
#.rst: | ||
# FindEGL | ||
# ------- | ||
# | ||
# Try to find EGL. | ||
# | ||
# This will define the following variables: | ||
# | ||
# ``EGL_FOUND`` | ||
# True if (the requested version of) EGL is available | ||
# ``EGL_VERSION`` | ||
# The version of EGL; note that this is the API version defined in the | ||
# headers, rather than the version of the implementation (eg: Mesa) | ||
# ``EGL_LIBRARIES`` | ||
# This can be passed to target_link_libraries() instead of the ``EGL::EGL`` | ||
# target | ||
# ``EGL_INCLUDE_DIRS`` | ||
# This should be passed to target_include_directories() if the target is not | ||
# used for linking | ||
# ``EGL_DEFINITIONS`` | ||
# This should be passed to target_compile_options() if the target is not | ||
# used for linking | ||
# | ||
# If ``EGL_FOUND`` is TRUE, it will also define the following imported target: | ||
# | ||
# ``EGL::EGL`` | ||
# The EGL library | ||
# | ||
# In general we recommend using the imported target, as it is easier to use. | ||
# Bear in mind, however, that if the target is in the link interface of an | ||
# exported library, it must be made available by the package config file. | ||
# | ||
# Since pre-1.0.0. | ||
|
||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
# Note: This module is originally from the KDE "Extra CMake Modules" repo, | ||
# adapted to work standalone. Original source: | ||
# https://github.com/KDE/extra-cmake-modules/blob/3b0bf71a72789eb2b79310b4f67602115e347f56/find-modules/FindEGL.cmake | ||
#============================================================================= | ||
# Copyright 2014 Alex Merry <[email protected]> | ||
# Copyright 2014 Martin Gräßlin <[email protected]> | ||
# Copyright 2019, 2021 Ryan Pavlik <[email protected]> | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions | ||
# are met: | ||
# | ||
# 1. Redistributions of source code must retain the copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# 3. The name of the author may not be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
#============================================================================= | ||
|
||
include(CheckCXXSourceCompiles) | ||
include(CMakePushCheckState) | ||
|
||
# Use pkg-config to get the directories and then use these values | ||
# in the FIND_PATH() and FIND_LIBRARY() calls | ||
if(NOT ANDROID) | ||
find_package(PkgConfig QUIET) | ||
if(PKGCONFIG_FOUND) | ||
pkg_check_modules(PKG_EGL QUIET egl) | ||
endif() | ||
endif() | ||
|
||
set(EGL_DEFINITIONS ${PKG_EGL_CFLAGS_OTHER}) | ||
|
||
find_path(EGL_INCLUDE_DIR | ||
NAMES | ||
EGL/egl.h | ||
HINTS | ||
${PKG_EGL_INCLUDE_DIRS} | ||
) | ||
find_library(EGL_LIBRARY | ||
NAMES | ||
EGL | ||
HINTS | ||
${PKG_EGL_LIBRARY_DIRS} | ||
) | ||
|
||
# NB: We do *not* use the version information from pkg-config, as that | ||
# is the implementation version (eg: the Mesa version) | ||
if(EGL_INCLUDE_DIR) | ||
# egl.h has defines of the form EGL_VERSION_x_y for each supported | ||
# version; so the header for EGL 1.1 will define EGL_VERSION_1_0 and | ||
# EGL_VERSION_1_1. Finding the highest supported version involves | ||
# finding all these defines and selecting the highest numbered. | ||
file(READ "${EGL_INCLUDE_DIR}/EGL/egl.h" _EGL_header_contents) | ||
string(REGEX MATCHALL | ||
"[ \t]EGL_VERSION_[0-9_]+" | ||
_EGL_version_lines | ||
"${_EGL_header_contents}" | ||
) | ||
unset(_EGL_header_contents) | ||
foreach(_EGL_version_line ${_EGL_version_lines}) | ||
string(REGEX REPLACE | ||
"[ \t]EGL_VERSION_([0-9_]+)" | ||
"\\1" | ||
_version_candidate | ||
"${_EGL_version_line}" | ||
) | ||
string(REPLACE "_" "." _version_candidate "${_version_candidate}") | ||
if(NOT DEFINED EGL_VERSION OR EGL_VERSION VERSION_LESS _version_candidate) | ||
set(EGL_VERSION "${_version_candidate}") | ||
endif() | ||
endforeach() | ||
unset(_EGL_version_lines) | ||
endif() | ||
|
||
cmake_push_check_state(RESET) | ||
list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}") | ||
list(APPEND CMAKE_REQUIRED_INCLUDES "${EGL_INCLUDE_DIR}") | ||
|
||
check_cxx_source_compiles(" | ||
#include <EGL/egl.h> | ||
int main(int argc, char *argv[]) { | ||
EGLint x = 0; EGLDisplay dpy = 0; EGLContext ctx = 0; | ||
eglDestroyContext(dpy, ctx); | ||
}" HAVE_EGL) | ||
|
||
cmake_pop_check_state() | ||
|
||
set(required_vars EGL_INCLUDE_DIR HAVE_EGL) | ||
if(NOT EMSCRIPTEN) | ||
list(APPEND required_vars EGL_LIBRARY) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(EGL | ||
FOUND_VAR | ||
EGL_FOUND | ||
REQUIRED_VARS | ||
${required_vars} | ||
VERSION_VAR | ||
EGL_VERSION | ||
) | ||
|
||
if(EGL_FOUND AND NOT TARGET EGL::EGL) | ||
if (EMSCRIPTEN) | ||
add_library(EGL::EGL INTERFACE IMPORTED) | ||
# Nothing further to be done, system include paths have headers and linkage is implicit. | ||
else() | ||
add_library(EGL::EGL UNKNOWN IMPORTED) | ||
set_target_properties(EGL::EGL PROPERTIES | ||
IMPORTED_LOCATION "${EGL_LIBRARY}" | ||
INTERFACE_COMPILE_OPTIONS "${EGL_DEFINITIONS}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}" | ||
) | ||
endif() | ||
endif() | ||
|
||
mark_as_advanced(EGL_LIBRARY EGL_INCLUDE_DIR HAVE_EGL) | ||
|
||
# compatibility variables | ||
set(EGL_LIBRARIES ${EGL_LIBRARY}) | ||
set(EGL_INCLUDE_DIRS ${EGL_INCLUDE_DIR}) | ||
set(EGL_VERSION_STRING ${EGL_VERSION}) | ||
|
||
include(FeatureSummary) | ||
set_package_properties(EGL PROPERTIES | ||
URL "https://www.khronos.org/egl/" | ||
DESCRIPTION "A platform-agnostic mechanism for creating rendering surfaces for use with other graphics libraries, such as OpenGL|ES and OpenVG." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# - Find GLM | ||
# Find the GLM header-only library | ||
# | ||
# GLM::GLM - Interface target created if GLM was found. | ||
# | ||
# GLM_FOUND - True if GLM was found. | ||
# | ||
# Original Author: | ||
# 2019, 2021 Ryan Pavlik <[email protected]> <[email protected]> | ||
# | ||
# Copyright 2019, 2021, Collabora, Ltd. | ||
# | ||
# SPDX-License-Identifier: BSL-1.0 | ||
|
||
set(GLM_ROOT_DIR | ||
"${GLM_ROOT_DIR}" | ||
CACHE PATH "Directory to search for GLM") | ||
|
||
option(GLM_ATTEMPT_CMAKE_MODULE | ||
"Should we attempt to use GLM's own CMake module for configuration?" ON) | ||
mark_as_advanced(GLM_ATTEMPT_CMAKE_MODULE) | ||
|
||
if(GLM_ATTEMPT_CMAKE_MODULE AND NOT glm_FOUND) | ||
# Look for a CMake config file | ||
find_package(glm QUIET NO_MODULE) | ||
endif() | ||
|
||
# Ask pkg-config for hints | ||
find_package(PkgConfig QUIET) | ||
if(PKG_CONFIG_FOUND) | ||
set(_old_prefix_path "${CMAKE_PREFIX_PATH}") | ||
# So pkg-config uses GLM_ROOT_DIR too. | ||
if(GLM_ROOT_DIR) | ||
list(APPEND CMAKE_PREFIX_PATH ${GLM_ROOT_DIR}) | ||
endif() | ||
if(GLM_FIND_VERSION) | ||
set(_GLM_FIND_VERSION_EXT ">=${GLM_FIND_VERSION}") | ||
else() | ||
unset(_GLM_FIND_VERSION_EXT) | ||
endif() | ||
pkg_check_modules(PC_GLM QUIET glm${_GLM_FIND_VERSION_EXT}) | ||
# Restore | ||
set(CMAKE_PREFIX_PATH "${_old_prefix_path}") | ||
|
||
# Use pkg-config's version if we have it. | ||
if(PC_GLM_FOUND | ||
AND PC_GLM_VERSION | ||
AND GLM_FIND_VERSION | ||
AND NOT GLM_VERSION) | ||
set(GLM_VERSION ${PC_GLM_VERSION}) | ||
endif() | ||
endif() | ||
|
||
find_path( | ||
GLM_INCLUDE_DIR | ||
NAMES glm/glm.hpp | ||
PATHS "${GLM_ROOT_DIR}" | ||
PATH_SUFFIXES include | ||
HINTS ${PC_GLM_INCLUDE_DIRS} ${GLM_INCLUDE_DIRS}) | ||
|
||
if(GLM_INCLUDE_DIR AND NOT GLM_VERSION) | ||
# Parse the header to get the version, if we can | ||
file(STRINGS "${GLM_INCLUDE_DIR}/glm/detail/setup.hpp" _glm_header_contents | ||
REGEX "GLM_VERSION_(MAJOR|MINOR|PATCH|REVISION)") | ||
foreach(_line IN LISTS _glm_header_contents) | ||
if("${_line}" MATCHES | ||
"GLM_VERSION_(MAJOR|MINOR|PATCH|REVISION)[^0-9]+([0-9]+)") | ||
set(VERSION_COMPONENT "${CMAKE_MATCH_1}") | ||
set(GLM_VERSION_${VERSION_COMPONENT} "${CMAKE_MATCH_2}") | ||
endif() | ||
endforeach() | ||
|
||
if(DEFINED GLM_VERSION_MAJOR) | ||
set(GLM_VERSION "${GLM_VERSION_MAJOR}") | ||
if(DEFINED GLM_VERSION_MINOR) | ||
string(APPEND GLM_VERSION . ${GLM_VERSION_MINOR}) | ||
if(DEFINED GLM_VERSION_PATCH) | ||
string(APPEND GLM_VERSION . ${GLM_VERSION_PATCH}) | ||
|
||
if(DEFINED GLM_VERSION_REVISION) | ||
string(APPEND GLM_VERSION . ${GLM_VERSION_REVISION}) | ||
endif() | ||
endif() | ||
endif() | ||
endif() | ||
endif() | ||
|
||
if(GLM_VERSION) | ||
set(_version_arg VERSION_VAR GLM_VERSION) | ||
else() | ||
unset(_version_arg) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
find_package_handle_standard_args(GLM REQUIRED_VARS GLM_INCLUDE_DIR | ||
${_version_arg}) | ||
|
||
if(GLM_FOUND AND NOT TARGET GLM::GLM) | ||
if(TARGET glm::glm) | ||
add_library(GLM::GLM ALIAS glm::glm) | ||
else() | ||
add_library(GLM::GLM INTERFACE) | ||
set_target_properties(GLM::GLM PROPERTIES INTERFACE_INCLUDE_DIRECTORIES | ||
"${GLM_INCLUDE_DIR}") | ||
endif() | ||
endif() | ||
|
||
if(GLM_FOUND) | ||
mark_as_advanced(GLM_ROOT_DIR) | ||
endif() | ||
mark_as_advanced(GLM_INCLUDE_DIR) | ||
|
||
include(FeatureSummary) | ||
set_package_properties( | ||
GLM PROPERTIES | ||
URL "https://github.com/g-truc/glm" | ||
DESCRIPTION | ||
"A header-only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specifications." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters