Browse Source

modules: explicitly link to Emscripten GL and OpenAL libraries.

Emscripten's MINIMAL_RUNTIME requires -lGL or -lopenal to be specified
(the default does that implicitly). It doesn't hurt to do that every
time and it makes the Find modules slightly simpler.
pull/364/head
Vladimír Vondruš 7 years ago
parent
commit
fa50929c78
  1. 3
      doc/changelog.dox
  2. 33
      modules/FindEGL.cmake
  3. 12
      modules/FindOpenAL.cmake
  4. 34
      modules/FindOpenGLES2.cmake
  5. 34
      modules/FindOpenGLES3.cmake

3
doc/changelog.dox

@ -396,6 +396,9 @@ See also:
scripts and `FindMagnum.cmake` always forced GLVND)
- `FindMagnum.cmake` now correctly finds debug versions of statically built
plugins when using Vcpkg
- `FindEGL.cmake`, `FindOpenAL.cmake`, `FindOpenGLES2.cmake` and
`FindOpenGLES3.cmake` now explicitly link to the `GL` and `openal`
libraries on Emscripten, which is needed for `MINIMAL_BUILD`
- Fixed linking of static `Any*` plugins when the libraries are otherwise
build as dynamic
- Removed mention of the outdated Ubuntu PPA from @ref building as it doesn't

33
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,24 +62,21 @@ 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

12
modules/FindOpenAL.cmake

@ -90,8 +90,9 @@
# This version is modified for Magnum and was forked from
# https://github.com/Kitware/CMake/blob/v3.6.1/Modules/FindOpenAL.cmake
# The file was modified to add a new path suffix for finding OpenAL for
# Emscripten on macOS and, in case of Emscripten, the library is not looked for
# as it is linked in implicitly.
# Emscripten on macOS. Additionally, in case of Emscripten, there's no library
# to find but instead one says -lopenal (and if MINIMAL_RUNTIME is not
# specified, this is implicit).
find_path(OPENAL_INCLUDE_DIR al.h
HINTS
@ -115,7 +116,9 @@ else()
set(_OpenAL_ARCH_DIR libs/Win32)
endif()
if(NOT CORRADE_TARGET_EMSCRIPTEN)
if(CORRADE_TARGET_EMSCRIPTEN)
set(OPENAL_LIBRARY openal CACHE STRING "Path to a library." FORCE)
else()
find_library(OPENAL_LIBRARY
NAMES OpenAL al openal OpenAL32
HINTS
@ -130,7 +133,6 @@ if(NOT CORRADE_TARGET_EMSCRIPTEN)
/opt
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir]
)
set(OPENAL_LIBRARY_NEEDED OPENAL_LIBRARY)
endif()
unset(_OpenAL_ARCH_DIR)
@ -138,6 +140,6 @@ unset(_OpenAL_ARCH_DIR)
# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG ${OPENAL_LIBRARY_NEEDED} OPENAL_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
mark_as_advanced(OPENAL_LIBRARY OPENAL_INCLUDE_DIR)

34
modules/FindOpenGLES2.cmake

@ -38,9 +38,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,7 +51,6 @@ if(NOT CORRADE_TARGET_EMSCRIPTEN)
# iOS
OpenGLES)
set(OPENGLES2_LIBRARY_NEEDED OPENGLES2_LIBRARY)
endif()
# Include dir
@ -61,24 +62,21 @@ find_path(OPENGLES2_INCLUDE_DIR NAMES
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenGLES2 DEFAULT_MSG
${OPENGLES2_LIBRARY_NEEDED}
OPENGLES2_LIBRARY
OPENGLES2_INCLUDE_DIR)
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

34
modules/FindOpenGLES3.cmake

@ -38,9 +38,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,7 +55,6 @@ if(NOT CORRADE_TARGET_EMSCRIPTEN)
# iOS
OpenGLES)
set(OPENGLES3_LIBRARY_NEEDED OPENGLES3_LIBRARY)
endif()
# Include dir
@ -65,24 +66,21 @@ find_path(OPENGLES3_INCLUDE_DIR NAMES
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args("OpenGLES3" DEFAULT_MSG
${OPENGLES3_LIBRARY_NEEDED}
OPENGLES3_LIBRARY
OPENGLES3_INCLUDE_DIR)
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

Loading…
Cancel
Save