Browse Source

modules: update Magnum Find modules.

next
Vladimír Vondruš 3 years ago
parent
commit
a9174def9b
  1. 5
      modules/FindCorrade.cmake
  2. 8
      modules/FindEGL.cmake
  3. 37
      modules/FindMagnum.cmake
  4. 2
      modules/FindOpenGLES2.cmake
  5. 2
      modules/FindOpenGLES3.cmake

5
modules/FindCorrade.cmake

@ -474,8 +474,9 @@ foreach(_component ${Corrade_FIND_COMPONENTS})
# Interconnect library # Interconnect library
if(_component STREQUAL Interconnect) if(_component STREQUAL Interconnect)
# Disable /OPT:ICF on MSVC, which merges functions with identical # Disable /OPT:ICF on MSVC, which merges functions with identical
# contents and thus breaks signal comparison # contents and thus breaks signal comparison. Same case is for
if(CORRADE_TARGET_WINDOWS AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # clang-cl which uses the MSVC linker by default.
if(CORRADE_TARGET_WINDOWS AND (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC"))
if(CMAKE_VERSION VERSION_LESS 3.13) if(CMAKE_VERSION VERSION_LESS 3.13)
set_property(TARGET Corrade::${_component} PROPERTY set_property(TARGET Corrade::${_component} PROPERTY
INTERFACE_LINK_LIBRARIES "-OPT:NOICF,REF") INTERFACE_LINK_LIBRARIES "-OPT:NOICF,REF")

8
modules/FindEGL.cmake

@ -38,10 +38,10 @@
# DEALINGS IN THE SOFTWARE. # DEALINGS IN THE SOFTWARE.
# #
# Under Emscripten, GL is linked implicitly. With MINIMAL_RUNTIME you need to # Under Emscripten, EGL is linked implicitly. With MINIMAL_RUNTIME you need to
# specify -lGL. Simply set the library name to that. # specify -lEGL. Simply set the library name to that.
if(CORRADE_TARGET_EMSCRIPTEN) if(CORRADE_TARGET_EMSCRIPTEN)
set(EGL_LIBRARY GL CACHE STRING "Path to a library." FORCE) set(EGL_LIBRARY EGL CACHE STRING "Path to a library." FORCE)
else() else()
find_library(EGL_LIBRARY NAMES find_library(EGL_LIBRARY NAMES
EGL EGL
@ -69,7 +69,7 @@ if(NOT TARGET EGL::EGL)
# Work around BUGGY framework support on macOS. Do this also in case of # Work around BUGGY framework support on macOS. Do this also in case of
# Emscripten, since there we don't have a location either. # Emscripten, since there we don't have a location either.
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html # http://public.kitware.com/pipermail/cmake/2016-April/063179.html
if((APPLE AND ${EGL_LIBRARY} MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN) if((APPLE AND EGL_LIBRARY MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN)
add_library(EGL::EGL INTERFACE IMPORTED) add_library(EGL::EGL INTERFACE IMPORTED)
set_property(TARGET EGL::EGL APPEND PROPERTY set_property(TARGET EGL::EGL APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${EGL_LIBRARY}) INTERFACE_LINK_LIBRARIES ${EGL_LIBRARY})

37
modules/FindMagnum.cmake

@ -227,6 +227,15 @@
# DEALINGS IN THE SOFTWARE. # DEALINGS IN THE SOFTWARE.
# #
# CMake policies used by FindMagnum are popped again at the end.
cmake_policy(PUSH)
# Prefer GLVND when finding OpenGL. If this causes problems (known to fail with
# NVidia drivers in Debian Buster, reported on 2019-04-09), users can override
# this by setting OpenGL_GL_PREFERENCE to LEGACY.
if(POLICY CMP0072)
cmake_policy(SET CMP0072 NEW)
endif()
# Corrade library dependencies # Corrade library dependencies
set(_MAGNUM_CORRADE_DEPENDENCIES ) set(_MAGNUM_CORRADE_DEPENDENCIES )
foreach(_magnum_component ${Magnum_FIND_COMPONENTS}) foreach(_magnum_component ${Magnum_FIND_COMPONENTS})
@ -309,14 +318,6 @@ if(MAGNUM_BUILD_DEPRECATED)
endif() endif()
endif() endif()
# OpenGL library preference. Prefer to use GLVND, since that's the better
# approach nowadays, but allow the users to override it from outside in case
# it is broken for some reason (Nvidia drivers in Debian's testing (Buster) --
# reported on 2019-04-09).
if(NOT CMAKE_VERSION VERSION_LESS 3.10 AND NOT OpenGL_GL_PREFERENCE)
set(OpenGL_GL_PREFERENCE GLVND)
endif()
# Base Magnum library # Base Magnum library
if(NOT TARGET Magnum::Magnum) if(NOT TARGET Magnum::Magnum)
add_library(Magnum::Magnum UNKNOWN IMPORTED) add_library(Magnum::Magnum UNKNOWN IMPORTED)
@ -726,7 +727,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS})
INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}) INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS})
endif() endif()
# With GLVND (since CMake 3.11) we need to explicitly link to # With GLVND (since CMake 3.10) we need to explicitly link to
# GLX/EGL because libOpenGL doesn't provide it. For EGL we have # GLX/EGL because libOpenGL doesn't provide it. For EGL we have
# our own EGL find module, which makes things simpler. The # our own EGL find module, which makes things simpler. The
# upstream FindOpenGL is anything but simple. Also can't use # upstream FindOpenGL is anything but simple. Also can't use
@ -773,7 +774,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS})
INTERFACE_LINK_LIBRARIES "--js-library ${MAGNUM_PLATFORM_JS}") INTERFACE_LINK_LIBRARIES "--js-library ${MAGNUM_PLATFORM_JS}")
endif() endif()
# With GLVND (since CMake 3.11) we need to explicitly link to # With GLVND (since CMake 3.10) we need to explicitly link to
# GLX/EGL because libOpenGL doesn't provide it. For EGL we have # GLX/EGL because libOpenGL doesn't provide it. For EGL we have
# our own EGL find module, which makes things simpler. The # our own EGL find module, which makes things simpler. The
# upstream FindOpenGL is anything but simple. Also can't use # upstream FindOpenGL is anything but simple. Also can't use
@ -803,12 +804,19 @@ foreach(_component ${Magnum_FIND_COMPONENTS})
set_property(TARGET Magnum::${_component} APPEND PROPERTY set_property(TARGET Magnum::${_component} APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${X11_LIBRARIES}) INTERFACE_LINK_LIBRARIES ${X11_LIBRARIES})
# With GLVND (since CMake 3.11) we need to explicitly link to # With GLVND (since CMake 3.10) we need to explicitly link to
# GLX because libOpenGL doesn't provide it. Also can't use # GLX because libOpenGL doesn't provide it. Also can't use
# OpenGL_OpenGL_FOUND, because that one is set also if GLVND is # OpenGL_OpenGL_FOUND, because that one is set also if GLVND is
# *not* found. WTF. Also can't just check for # *not* found. WTF. Also can't just check for
# OPENGL_opengl_LIBRARY because that's set even if # OPENGL_opengl_LIBRARY because that's set even if
# OpenGL_GL_PREFERENCE is explicitly set to LEGACY. # OpenGL_GL_PREFERENCE is explicitly set to LEGACY.
#
# If MAGNUM_TARGET_GLES and MAGNUM_TARGET_EGL is set, these
# applications can be built only if GLVND is available as
# otherwise there would be a conflict between libGL and
# libGLES. Thus, if GLVND is not available, it won't link
# libGLX here, but that shouldn't be a problem since the
# application library won't exist either.
find_package(OpenGL) find_package(OpenGL)
if(OPENGL_opengl_LIBRARY AND OpenGL_GL_PREFERENCE STREQUAL GLVND) if(OPENGL_opengl_LIBRARY AND OpenGL_GL_PREFERENCE STREQUAL GLVND)
set_property(TARGET Magnum::${_component} APPEND PROPERTY set_property(TARGET Magnum::${_component} APPEND PROPERTY
@ -851,7 +859,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS})
# GLX context dependencies # GLX context dependencies
if(_component STREQUAL GlxContext) if(_component STREQUAL GlxContext)
# With GLVND (since CMake 3.11) we need to explicitly link to # With GLVND (since CMake 3.10) we need to explicitly link to
# GLX because libOpenGL doesn't provide it. Also can't use # GLX because libOpenGL doesn't provide it. Also can't use
# OpenGL_OpenGL_FOUND, because that one is set also if GLVND is # OpenGL_OpenGL_FOUND, because that one is set also if GLVND is
# *not* found. If GLVND is not used, link to X11 instead. Also # *not* found. If GLVND is not used, link to X11 instead. Also
@ -890,7 +898,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS})
# GL library # GL library
elseif(_component STREQUAL GL) elseif(_component STREQUAL GL)
if(NOT MAGNUM_TARGET_GLES OR (MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_EGL AND NOT CORRADE_TARGET_IOS)) if(NOT MAGNUM_TARGET_GLES OR (MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_EGL AND NOT CORRADE_TARGET_IOS))
# If the GLVND library (CMake 3.11+) was found, link to the # If the GLVND library (CMake 3.10+) was found, link to the
# imported target. Otherwise (and also on all systems except # imported target. Otherwise (and also on all systems except
# Linux) link to the classic libGL. Can't use # Linux) link to the classic libGL. Can't use
# OpenGL_OpenGL_FOUND, because that one is set also if GLVND is # OpenGL_OpenGL_FOUND, because that one is set also if GLVND is
@ -1292,3 +1300,6 @@ if(MAGNUM_PLUGINS_RELEASE_DIR)
set(MAGNUM_PLUGINS_SCENECONVERTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/sceneconverters) set(MAGNUM_PLUGINS_SCENECONVERTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/sceneconverters)
set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/audioimporters) set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/audioimporters)
endif() endif()
# Resets CMake policies set at the top of the file to not affect other code.
cmake_policy(POP)

2
modules/FindOpenGLES2.cmake

@ -64,7 +64,7 @@ if(NOT TARGET OpenGLES2::OpenGLES2)
# Work around BUGGY framework support on macOS. Do this also in case of # Work around BUGGY framework support on macOS. Do this also in case of
# Emscripten, since there we don't have a location either. # Emscripten, since there we don't have a location either.
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html # http://public.kitware.com/pipermail/cmake/2016-April/063179.html
if((CORRADE_TARGET_APPLE AND ${OPENGLES2_LIBRARY} MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN) if((CORRADE_TARGET_APPLE AND OPENGLES2_LIBRARY MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN)
add_library(OpenGLES2::OpenGLES2 INTERFACE IMPORTED) add_library(OpenGLES2::OpenGLES2 INTERFACE IMPORTED)
set_property(TARGET OpenGLES2::OpenGLES2 APPEND PROPERTY set_property(TARGET OpenGLES2::OpenGLES2 APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${OPENGLES2_LIBRARY}) INTERFACE_LINK_LIBRARIES ${OPENGLES2_LIBRARY})

2
modules/FindOpenGLES3.cmake

@ -69,7 +69,7 @@ if(NOT TARGET OpenGLES3::OpenGLES3)
# Work around BUGGY framework support on macOS. Do this also in case of # Work around BUGGY framework support on macOS. Do this also in case of
# Emscripten, since there we don't have a location either. # Emscripten, since there we don't have a location either.
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html # http://public.kitware.com/pipermail/cmake/2016-April/063179.html
if((CORRADE_TARGET_APPLE AND ${OPENGLES3_LIBRARY} MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN) if((CORRADE_TARGET_APPLE AND OPENGLES3_LIBRARY MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN)
add_library(OpenGLES3::OpenGLES3 INTERFACE IMPORTED) add_library(OpenGLES3::OpenGLES3 INTERFACE IMPORTED)
set_property(TARGET OpenGLES3::OpenGLES3 APPEND PROPERTY set_property(TARGET OpenGLES3::OpenGLES3 APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${OPENGLES3_LIBRARY}) INTERFACE_LINK_LIBRARIES ${OPENGLES3_LIBRARY})

Loading…
Cancel
Save