From d863fbee30c8855244cd9a9d7b41cc063a65620a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 1 Mar 2018 23:34:57 +0100 Subject: [PATCH] Split the OpenGL layer out, pt 3: new MAGNUM_TARGET_GL variable. This will later enable conditional compilation of APIs that depend on the GL library (for example the Text library directly producing compiled meshes instead of just plain vertex data). --- CMakeLists.txt | 5 +++++ Doxyfile | 3 ++- doc/building.dox | 4 ++++ doc/cmake.dox | 2 ++ modules/FindMagnum.cmake | 2 ++ src/Magnum/Magnum.h | 12 ++++++++++++ src/Magnum/configure.h.cmake | 1 + 7 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dcdaff46d..56512c535 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,6 +116,8 @@ cmake_dependent_option(WITH_TEXTURETOOLS "Build TextureTools library" ON "NOT WI cmake_dependent_option(WITH_TRADE "Build Trade library" ON "NOT WITH_MESHTOOLS;NOT WITH_PRIMITIVES;NOT WITH_IMAGECONVERTER;NOT WITH_ANYIMAGEIMPORTER;NOT WITH_ANYIMAGECONVERTER;NOT WITH_ANYSCENEIMPORTER;NOT WITH_OBJIMPORTER;NOT WITH_TGAIMAGECONVERTER;NOT WITH_TGAIMPORTER" ON) cmake_dependent_option(WITH_GL "Build GL library" ON "NOT WITH_DEBUGTOOLS;NOT WITH_MESHTOOLS;NOT WITH_PRIMITIVES;NOT WITH_SHADERS;NOT WITH_TEXT;NOT WITH_TEXTURETOOLS;NOT WITH_TRADE;NOT WITH_MAGNUMINFO;NOT WITH_ANDROIDAPPLICATION;NOT WITH_WINDOWLESSIOSAPPLICATION;NOT WITH_CGLCONTEXT;NOT WITH_GLXAPPLICATION;NOT WITH_GLXCONTEXT;NOT WITH_XEGLAPPLICATION;NOT WITH_WINDOWLESSWGLAPPLICATION;NOT WITH_GLXCONTEXT;NOT WITH_XEGLAPPLICATION;NOT WITH_WINDOWLESSWGLAPPLICATION;NOT WITH_WGLCONTEXT;NOT WITH_WINDOWLESSWINDOWSEGLAPPLICATION;NOT WITH_GLFWAPPLICATION;NOT WITH_GLUTAPPLICATION;NOT WITH_SDL2APPLICATION;NOT WITH_DISTANCEFIELDCONVERTER;NOT WITH_FONTCONVERTER;NOT WITH_IMAGECONVERTER" ON) +cmake_dependent_option(TARGET_GL "Build libraries with OpenGL interoperability" ON "WITH_GL" OFF) + # Magnum AL Info cmake_dependent_option(WITH_AL_INFO "Build magnum-al-info utility" OFF "WITH_AUDIO" OFF) @@ -217,6 +219,9 @@ else() endif() # Configuration variables (saved later to configure.h) +if(TARGET_GL) + set(MAGNUM_TARGET_GL 1) +endif() if(TARGET_GLES) set(MAGNUM_TARGET_GLES 1) if(TARGET_GLES2) diff --git a/Doxyfile b/Doxyfile index 47de6931e..ca048063f 100644 --- a/Doxyfile +++ b/Doxyfile @@ -2052,7 +2052,8 @@ PREDEFINED = DOXYGEN_GENERATING_OUTPUT \ CORRADE_DEPRECATED_FILE(message)= CORRADE_VISIBILITY_EXPORT= \ CORRADE_VISIBILITY_LOCAL= CORRADE_VISIBILITY_IMPORT= \ CORRADE_IGNORE_DEPRECATED_PUSH= CORRADE_IGNORE_DEPRECATED_POP= \ - CORRADE_ENUMSET_OPERATORS(message)= MAGNUM_BUILD_DEPRECATED + CORRADE_ENUMSET_OPERATORS(message)= MAGNUM_BUILD_DEPRECATED \ + MAGNUM_TARGET_GL # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/doc/building.dox b/doc/building.dox index 3d9b373bf..27a3af344 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -383,6 +383,10 @@ By default the engine is built for desktop OpenGL. Using the `TARGET_*` CMake options you can target other platforms. Note that some features are available for desktop OpenGL only, see @ref requires-gl. +- `TARGET_GL` --- Build libraries with OpenGL interoperability enabled. + Enabled by default when `WITH_GL` is enabled. Disabling this will cause + libraries to not depend on the @ref GL library, but doesn't affect the + @ref GL library itself. - `TARGET_GLES` --- Target OpenGL ES. Available only when `WITH_GL` is enabled. - `TARGET_GLES2` --- Target OpenGL ES 2.0 instead of 3.0 and later. Available diff --git a/doc/cmake.dox b/doc/cmake.dox index 06a3d74db..12fbb499f 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -209,6 +209,8 @@ are also available as preprocessor variables if including are shared libraries. - `MAGNUM_BUILD_MULTITHREADED` --- Defined if compiled in a way that allows having multiple thread-local Magnum contexts. The default. +- `MAGNUM_TARGET_GL` --- Defined if compiled with OpenGL interoperability + enabled - `MAGNUM_TARGET_GLES` --- Defined if compiled for OpenGL ES - `MAGNUM_TARGET_GLES2` --- Defined if compiled for OpenGL ES 2.0 - `MAGNUM_TARGET_GLES3` --- Defined if compiled for OpenGL ES 3.0 diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index c613ec96d..f64b37b8b 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -120,6 +120,7 @@ # MAGNUM_BUILD_STATIC - Defined if compiled as static libraries # MAGNUM_BUILD_MULTITHREADED - Defined if compiled in a way that allows # having multiple thread-local Magnum contexts +# MAGNUM_TARGET_GL - Defined if compiled with OpenGL interop # MAGNUM_TARGET_GLES - Defined if compiled for OpenGL ES # MAGNUM_TARGET_GLES2 - Defined if compiled for OpenGL ES 2.0 # MAGNUM_TARGET_GLES3 - Defined if compiled for OpenGL ES 3.0 @@ -248,6 +249,7 @@ set(_magnumFlags BUILD_DEPRECATED BUILD_STATIC BUILD_MULTITHREADED + TARGET_GL TARGET_GLES TARGET_GLES2 TARGET_GLES3 diff --git a/src/Magnum/Magnum.h b/src/Magnum/Magnum.h index 33e392a19..8075b2d7b 100644 --- a/src/Magnum/Magnum.h +++ b/src/Magnum/Magnum.h @@ -95,6 +95,18 @@ Magnum contexts. Enabled by default. #define MAGNUM_BUILD_MULTITHREADED #undef MAGNUM_BUILD_MULTITHREADED +/** +@brief OpenGL interoperability + +Defined if the engine is built with OpenGL interoperability enabled --- extra +APIs in various libraries interacting with the @ref Magnum::GL "GL" library. +Enabled by default in case the @ref Magnum::GL "GL" library is built. +@see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_GLES3, + @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building, @ref cmake +*/ +#define MAGNUM_TARGET_GL +/* (enabled by default) */ + /** @brief OpenGL ES target diff --git a/src/Magnum/configure.h.cmake b/src/Magnum/configure.h.cmake index 12f24d5d7..8a0e6eaea 100644 --- a/src/Magnum/configure.h.cmake +++ b/src/Magnum/configure.h.cmake @@ -28,6 +28,7 @@ #cmakedefine MAGNUM_BUILD_DEPRECATED #cmakedefine MAGNUM_BUILD_STATIC #cmakedefine MAGNUM_BUILD_MULTITHREADED +#cmakedefine MAGNUM_TARGET_GL #cmakedefine MAGNUM_TARGET_GLES #cmakedefine MAGNUM_TARGET_GLES2 #cmakedefine MAGNUM_TARGET_GLES3