Browse Source

modules: updated GL-related Find modules.

appveyor-coverage
Vladimír Vondruš 7 years ago
parent
commit
3c96880f2e
  1. 35
      modules/FindEGL.cmake
  2. 52
      modules/FindOpenGLES2.cmake
  3. 52
      modules/FindOpenGLES3.cmake

35
modules/FindEGL.cmake

@ -38,8 +38,11 @@
# DEALINGS IN THE SOFTWARE.
#
# Library
if(NOT CORRADE_TARGET_EMSCRIPTEN)
# Under Emscripten, GL is linked implicitly. With MINIMAL_RUNTIME you need to
# specify -lGL. Simply set the library name to that.
if(CORRADE_TARGET_EMSCRIPTEN)
set(EGL_LIBRARY GL CACHE STRING "Path to a library." FORCE)
else()
find_library(EGL_LIBRARY NAMES
EGL
@ -48,7 +51,6 @@ if(NOT CORRADE_TARGET_EMSCRIPTEN)
# On iOS a part of OpenGLES
OpenGLES)
set(EGL_LIBRARY_NEEDED EGL_LIBRARY)
endif()
# Include dir
@ -60,26 +62,25 @@ find_path(EGL_INCLUDE_DIR NAMES
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(EGL DEFAULT_MSG
${EGL_LIBRARY_NEEDED}
EGL_LIBRARY
EGL_INCLUDE_DIR)
if(NOT TARGET EGL::EGL)
if(EGL_LIBRARY_NEEDED)
# Work around BUGGY framework support on macOS
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html
if(APPLE AND ${EGL_LIBRARY} MATCHES "\\.framework$")
add_library(EGL::EGL INTERFACE IMPORTED)
set_property(TARGET EGL::EGL APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${EGL_LIBRARY})
else()
add_library(EGL::EGL UNKNOWN IMPORTED)
set_property(TARGET EGL::EGL PROPERTY
IMPORTED_LOCATION ${EGL_LIBRARY})
endif()
else()
# Work around BUGGY framework support on macOS. Do this also in case of
# Emscripten, since there we don't have a location either.
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html
if((APPLE AND ${EGL_LIBRARY} MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN)
add_library(EGL::EGL INTERFACE IMPORTED)
set_property(TARGET EGL::EGL APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${EGL_LIBRARY})
else()
add_library(EGL::EGL UNKNOWN IMPORTED)
set_property(TARGET EGL::EGL PROPERTY
IMPORTED_LOCATION ${EGL_LIBRARY})
endif()
set_target_properties(EGL::EGL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${EGL_INCLUDE_DIR})
endif()
mark_as_advanced(EGL_LIBRARY EGL_INCLUDE_DIR)

52
modules/FindOpenGLES2.cmake

@ -10,7 +10,10 @@
# Additionally these variables are defined for internal usage:
#
# OPENGLES2_LIBRARY - OpenGL ES 2 library
# OPENGLES2_INCLUDE_DIR - Include dir
#
# Please note this find module is tailored especially for the needs of Magnum.
# In particular, it depends on its platform definitions and doesn't look for
# OpenGL ES includes as Magnum has its own, generated using flextGL.
#
#
@ -38,9 +41,11 @@
# DEALINGS IN THE SOFTWARE.
#
# In Emscripten OpenGL ES 2 is linked automatically, thus no need to find the
# library.
if(NOT CORRADE_TARGET_EMSCRIPTEN)
# Under Emscripten, GL is linked implicitly. With MINIMAL_RUNTIME you need to
# specify -lGL. Simply set the library name to that.
if(CORRADE_TARGET_EMSCRIPTEN)
set(OPENGLES2_LIBRARY GL CACHE STRING "Path to a library." FORCE)
else()
find_library(OPENGLES2_LIBRARY NAMES
GLESv2
@ -49,38 +54,25 @@ if(NOT CORRADE_TARGET_EMSCRIPTEN)
# iOS
OpenGLES)
set(OPENGLES2_LIBRARY_NEEDED OPENGLES2_LIBRARY)
endif()
# Include dir
find_path(OPENGLES2_INCLUDE_DIR NAMES
GLES2/gl2.h
# iOS
ES2/gl.h)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenGLES2 DEFAULT_MSG
${OPENGLES2_LIBRARY_NEEDED}
OPENGLES2_INCLUDE_DIR)
OPENGLES2_LIBRARY)
if(NOT TARGET OpenGLES2::OpenGLES2)
if(OPENGLES2_LIBRARY_NEEDED)
# Work around BUGGY framework support on macOS
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html
if(CORRADE_TARGET_APPLE AND ${OPENGLES2_LIBRARY} MATCHES "\\.framework$")
add_library(OpenGLES2::OpenGLES2 INTERFACE IMPORTED)
set_property(TARGET OpenGLES2::OpenGLES2 APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${OPENGLES2_LIBRARY})
else()
add_library(OpenGLES2::OpenGLES2 UNKNOWN IMPORTED)
set_property(TARGET OpenGLES2::OpenGLES2 PROPERTY
IMPORTED_LOCATION ${OPENGLES2_LIBRARY})
endif()
else()
# Work around BUGGY framework support on macOS. Do this also in case of
# Emscripten, since there we don't have a location either.
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html
if((CORRADE_TARGET_APPLE AND ${OPENGLES2_LIBRARY} MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN)
add_library(OpenGLES2::OpenGLES2 INTERFACE IMPORTED)
set_property(TARGET OpenGLES2::OpenGLES2 APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${OPENGLES2_LIBRARY})
else()
add_library(OpenGLES2::OpenGLES2 UNKNOWN IMPORTED)
set_property(TARGET OpenGLES2::OpenGLES2 PROPERTY
IMPORTED_LOCATION ${OPENGLES2_LIBRARY})
endif()
set_property(TARGET OpenGLES2::OpenGLES2 PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${OPENGLES2_INCLUDE_DIR})
endif()
mark_as_advanced(OPENGLES2_LIBRARY)

52
modules/FindOpenGLES3.cmake

@ -10,7 +10,10 @@
# Additionally these variables are defined for internal usage:
#
# OPENGLES3_LIBRARY - OpenGL ES 3 library
# OPENGLES3_INCLUDE_DIR - Include dir
#
# Please note this find module is tailored especially for the needs of Magnum.
# In particular, it depends on its platform definitions and doesn't look for
# OpenGL ES includes as Magnum has its own, generated using flextGL.
#
#
@ -38,9 +41,11 @@
# DEALINGS IN THE SOFTWARE.
#
# In Emscripten OpenGL ES 3 is linked automatically, thus no need to find the
# library.
if(NOT CORRADE_TARGET_EMSCRIPTEN)
# Under Emscripten, GL is linked implicitly. With MINIMAL_RUNTIME you need to
# specify -lGL. Simply set the library name to that.
if(CORRADE_TARGET_EMSCRIPTEN)
set(OPENGLES3_LIBRARY GL CACHE STRING "Path to a library." FORCE)
else()
find_library(OPENGLES3_LIBRARY NAMES
GLESv3
@ -53,41 +58,26 @@ if(NOT CORRADE_TARGET_EMSCRIPTEN)
# iOS
OpenGLES)
set(OPENGLES3_LIBRARY_NEEDED OPENGLES3_LIBRARY)
endif()
# Include dir
find_path(OPENGLES3_INCLUDE_DIR NAMES
GLES3/gl3.h
# iOS
ES3/gl.h)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args("OpenGLES3" DEFAULT_MSG
${OPENGLES3_LIBRARY_NEEDED}
OPENGLES3_INCLUDE_DIR)
OPENGLES3_LIBRARY)
if(NOT TARGET OpenGLES3::OpenGLES3)
if(OPENGLES3_LIBRARY_NEEDED)
# Work around BUGGY framework support on macOS
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html
if(CORRADE_TARGET_APPLE AND ${OPENGLES3_LIBRARY} MATCHES "\\.framework$")
add_library(OpenGLES3::OpenGLES3 INTERFACE IMPORTED)
set_property(TARGET OpenGLES3::OpenGLES3 APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${OPENGLES3_LIBRARY})
else()
add_library(OpenGLES3::OpenGLES3 UNKNOWN IMPORTED)
set_property(TARGET OpenGLES3::OpenGLES3 PROPERTY
IMPORTED_LOCATION ${OPENGLES3_LIBRARY})
endif()
else()
# Work around BUGGY framework support on macOS. Do this also in case of
# Emscripten, since there we don't have a location either.
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html
if((CORRADE_TARGET_APPLE AND ${OPENGLES3_LIBRARY} MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN)
add_library(OpenGLES3::OpenGLES3 INTERFACE IMPORTED)
set_property(TARGET OpenGLES3::OpenGLES3 APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${OPENGLES3_LIBRARY})
else()
add_library(OpenGLES3::OpenGLES3 UNKNOWN IMPORTED)
set_property(TARGET OpenGLES3::OpenGLES3 PROPERTY
IMPORTED_LOCATION ${OPENGLES3_LIBRARY})
endif()
set_property(TARGET OpenGLES3::OpenGLES3 PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${OPENGLES3_INCLUDE_DIR})
# Emscripten needs a special flag to use WebGL 2. CMake 3.13 allows to set
# this via INTERFACE_LINK_OPTIONS, for older versions we modify the global
# CMAKE_EXE_LINKER_FLAGS inside FindMagnum.cmake.
@ -98,3 +88,5 @@ if(NOT TARGET OpenGLES3::OpenGLES3)
INTERFACE_LINK_OPTIONS "SHELL:-s USE_WEBGL2=1")
endif()
endif()
mark_as_advanced(OPENGLES3_LIBRARY)

Loading…
Cancel
Save