Browse Source

CMake: fix a bug where TARGET_GLES2 was forced on mobile platforms.

I'll be happy once I can delete all this brittle backwards compatibility
post-release. The problem is as follows -- when running CMake without
any options on Android, iOS, Emscripten or UWP, such as

    cmake .. \
        -DCMAKE_TOOLCHAIN_FILE=path/to/toolchains/generic/Emscripten.cmake

It sees that no MAGNUM_-prefixed options were used, and thus assumes the
backwards compatibility for unprefixed WITH_, TARGET_ etc is still
desired, which is the right thing to do.

But then, there was a branch that enables TARGET_GLES *unconditionally*
on mobile platforms, if the backwards compatibility mode is enabled.
That alone would be harmless on its own, just causing garbage in the
CMake cache, unfortunately right after it sees that TARGET_GLES was set
and enables also TARGET_GLES2, because that's the default behavior. So
then, when one does

    cmake . -DMAGNUM_TARGET_GLES2=ON

It'll ignore that option and instead yells at the users that TARGET_GLES
was set by them and it's deprecated, even though none of that was
actually intended:

    CMake Deprecation Warning at CMakeLists.txt:501 (message):
      Unprefixed options such as TARGET_GLES2 are deprecated, use
      MAGNUM_TARGET_GLES2 instead.  Delete the unprefixed variable from
      CMake cache or set both to the same value to silence this warning.

The fix is that it's no longer setting TARGET_GLES implicitly on mobile
platforms, but instead considers the mobile platforms as well in
addition to checking if TARGET_GLES is set. Which means the backwards
compatibility variable dependencies only get set if there's at least one
of them coming from the user, never by default.
pull/610/head
Vladimír Vondruš 4 years ago
parent
commit
e76405e0e0
  1. 11
      CMakeLists.txt

11
CMakeLists.txt

@ -369,11 +369,6 @@ if(_MAGNUM_ACCEPT_DEPRECATED_UNPREFIXED_OPTIONS AND MAGNUM_BUILD_DEPRECATED)
# Doing this before propagating the unprefixed options to avoid a
# false-positive warning when e.g. MAGNUM_BUILD_STATIC_PIC is implicitly ON
# but BUILD_STATIC_PIC not yet.
if(CORRADE_TARGET_IOS OR CORRADE_TARGET_ANDROID OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_WINDOWS_RT)
if(NOT DEFINED TARGET_GLES)
set(TARGET_GLES ON)
endif()
endif()
if(TARGET_GLES)
if(NOT DEFINED TARGET_GLES2)
set(TARGET_GLES2 ON)
@ -426,7 +421,7 @@ if(_MAGNUM_ACCEPT_DEPRECATED_UNPREFIXED_OPTIONS AND MAGNUM_BUILD_DEPRECATED)
if(NOT DEFINED WITH_WINDOWLESSIOSAPPLICATION)
set(WITH_WINDOWLESSIOSAPPLICATION ON)
endif()
elseif(CORRADE_TARGET_APPLE AND NOT TARGET_GLES)
elseif(CORRADE_TARGET_APPLE AND NOT TARGET_GLES AND NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_WINDOWS_RT)
if(NOT DEFINED WITH_WINDOWLESSCGLAPPLICATION)
set(WITH_WINDOWLESSCGLAPPLICATION ON)
endif()
@ -434,7 +429,7 @@ if(_MAGNUM_ACCEPT_DEPRECATED_UNPREFIXED_OPTIONS AND MAGNUM_BUILD_DEPRECATED)
# Checking the old deprecated options here, checking
# MAGNUM_TARGET_EGL wouldn't make sense as that's an option the
# old code definitely won't use.
if((NOT TARGET_GLES AND NOT TARGET_HEADLESS) OR TARGET_DESKTOP_GLES)
if((NOT TARGET_GLES AND NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_WINDOWS_RT AND NOT TARGET_HEADLESS) OR TARGET_DESKTOP_GLES)
if(NOT DEFINED WITH_WINDOWLESSGLXAPPLICATION)
set(WITH_WINDOWLESSGLXAPPLICATION ON)
endif()
@ -444,7 +439,7 @@ if(_MAGNUM_ACCEPT_DEPRECATED_UNPREFIXED_OPTIONS AND MAGNUM_BUILD_DEPRECATED)
endif()
endif()
elseif(CORRADE_TARGET_WINDOWS)
if(NOT TARGET_GLES OR TARGET_DESKTOP_GLES)
if((NOT TARGET_GLES AND NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_WINDOWS_RT) OR TARGET_DESKTOP_GLES)
if(NOT DEFINED WITH_WINDOWLESSWGLAPPLICATION)
set(WITH_WINDOWLESSWGLAPPLICATION ON)
endif()

Loading…
Cancel
Save