1#.rst: 2# Find OpenGL ES 3 3# ---------------- 4# 5# Finds the OpenGL ES 3 library. This module defines: 6# 7# OpenGLES3_FOUND - True if OpenGL ES 3 library is found 8# OpenGLES3::OpenGLES3 - OpenGL ES 3 imported target 9# 10# Additionally these variables are defined for internal usage: 11# 12# OPENGLES3_LIBRARY - OpenGL ES 3 library 13# 14# Please note this find module is tailored especially for the needs of Magnum. 15# In particular, it depends on its platform definitions and doesn't look for 16# OpenGL ES includes as Magnum has its own, generated using flextGL. 17# 18 19# 20# This file is part of Magnum. 21# 22# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 23# Vladimír Vondruš <mosra@centrum.cz> 24# 25# Permission is hereby granted, free of charge, to any person obtaining a 26# copy of this software and associated documentation files (the "Software"), 27# to deal in the Software without restriction, including without limitation 28# the rights to use, copy, modify, merge, publish, distribute, sublicense, 29# and/or sell copies of the Software, and to permit persons to whom the 30# Software is furnished to do so, subject to the following conditions: 31# 32# The above copyright notice and this permission notice shall be included 33# in all copies or substantial portions of the Software. 34# 35# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 36# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 37# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 38# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 39# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 40# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 41# DEALINGS IN THE SOFTWARE. 42# 43 44# Under Emscripten, GL is linked implicitly. With MINIMAL_RUNTIME you need to 45# specify -lGL. Simply set the library name to that. 46if(CORRADE_TARGET_EMSCRIPTEN) 47 set(OPENGLES3_LIBRARY GL CACHE STRING "Path to a library." FORCE) 48else() 49 find_library(OPENGLES3_LIBRARY NAMES 50 GLESv3 51 52 # On some platforms (e.g. desktop emulation with Mesa or NVidia) ES3 53 # support is provided in ES2 lib 54 GLESv2 55 56 # ANGLE (CMake doesn't search for lib prefix on Windows) 57 libGLESv2 58 59 # iOS 60 OpenGLES) 61endif() 62 63include(FindPackageHandleStandardArgs) 64find_package_handle_standard_args("OpenGLES3" DEFAULT_MSG 65 OPENGLES3_LIBRARY) 66 67if(NOT TARGET OpenGLES3::OpenGLES3) 68 # Work around BUGGY framework support on macOS. Do this also in case of 69 # Emscripten, since there we don't have a location either. 70 # http://public.kitware.com/pipermail/cmake/2016-April/063179.html 71 if((CORRADE_TARGET_APPLE AND ${OPENGLES3_LIBRARY} MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN) 72 add_library(OpenGLES3::OpenGLES3 INTERFACE IMPORTED) 73 set_property(TARGET OpenGLES3::OpenGLES3 APPEND PROPERTY 74 INTERFACE_LINK_LIBRARIES ${OPENGLES3_LIBRARY}) 75 else() 76 add_library(OpenGLES3::OpenGLES3 UNKNOWN IMPORTED) 77 set_property(TARGET OpenGLES3::OpenGLES3 PROPERTY 78 IMPORTED_LOCATION ${OPENGLES3_LIBRARY}) 79 endif() 80 81 # Emscripten needs a special flag to use WebGL 2. CMake 3.13 allows to set 82 # this via INTERFACE_LINK_OPTIONS, for older versions we modify the global 83 # CMAKE_EXE_LINKER_FLAGS inside FindMagnum.cmake. 84 if(CORRADE_TARGET_EMSCRIPTEN AND NOT CMAKE_VERSION VERSION_LESS 3.13) 85 # I could probably use target_link_options() here, but let's be 86 # consistent with the rest 87 set_property(TARGET OpenGLES3::OpenGLES3 APPEND PROPERTY 88 INTERFACE_LINK_OPTIONS "SHELL:-s USE_WEBGL2=1") 89 endif() 90endif() 91 92mark_as_advanced(OPENGLES3_LIBRARY) 93