Browse Source

Added TARGET_HEADLESS option.

Toggles between using CGL/GLX/WGL (requiring running graphical desktop
environment) or EGL (without display attachment) for command-line
utilities and GL tests. Also exposed to the user through
MAGNUM_TARGET_HEADLESS CMake and preprocessor variables.
pull/133/head
Vladimír Vondruš 10 years ago
parent
commit
4f94c26467
  1. 9
      CMakeLists.txt
  2. 5
      doc/building.dox
  3. 4
      doc/cmake.dox
  4. 4
      modules/FindMagnum.cmake
  5. 12
      src/Magnum/Magnum.h
  6. 4
      src/Magnum/Platform/CMakeLists.txt
  7. 11
      src/Magnum/Platform/magnum-info.cpp
  8. 4
      src/Magnum/Test/AbstractOpenGLTester.h
  9. 4
      src/Magnum/Text/CMakeLists.txt
  10. 4
      src/Magnum/Text/fontconverter.cpp
  11. 4
      src/Magnum/TextureTools/CMakeLists.txt
  12. 4
      src/Magnum/TextureTools/distancefieldconverter.cpp
  13. 1
      src/Magnum/configure.h.cmake

9
CMakeLists.txt

@ -52,6 +52,7 @@ endif()
cmake_dependent_option(TARGET_GLES2 "Build for OpenGL ES 2 / WebGL 1.0" ON "TARGET_GLES" OFF) cmake_dependent_option(TARGET_GLES2 "Build for OpenGL ES 2 / WebGL 1.0" ON "TARGET_GLES" OFF)
cmake_dependent_option(TARGET_DESKTOP_GLES "Build for OpenGL ES on desktop" OFF "TARGET_GLES" OFF) cmake_dependent_option(TARGET_DESKTOP_GLES "Build for OpenGL ES on desktop" OFF "TARGET_GLES" OFF)
option(TARGET_HEADLESS "Build command-line utilities for use on a headless machines" OFF)
# Magnum Info (currently only using GLX, CGL, WGL/EGL on Windows or on NaCl) # Magnum Info (currently only using GLX, CGL, WGL/EGL on Windows or on NaCl)
if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL OR CORRADE_TARGET_WINDOWS) if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL OR CORRADE_TARGET_WINDOWS)
@ -194,9 +195,15 @@ endif()
if(TARGET_DESKTOP_GLES) if(TARGET_DESKTOP_GLES)
set(MAGNUM_TARGET_DESKTOP_GLES 1) set(MAGNUM_TARGET_DESKTOP_GLES 1)
endif() endif()
if(TARGET_HEADLESS)
set(MAGNUM_TARGET_HEADLESS 1)
endif()
if(BUILD_GL_TESTS) if(BUILD_GL_TESTS)
if(CORRADE_TARGET_APPLE) if(MAGNUM_TARGET_HEADLESS)
set(WITH_WINDOWLESSEGLAPPLICATION ON)
set(GL_TEST_LIBRARIES Magnum MagnumWindowlessEglApplication)
elseif(CORRADE_TARGET_APPLE)
set(WITH_WINDOWLESSCGLAPPLICATION ON) set(WITH_WINDOWLESSCGLAPPLICATION ON)
set(GL_TEST_LIBRARIES Magnum MagnumWindowlessCglApplication) set(GL_TEST_LIBRARIES Magnum MagnumWindowlessCglApplication)
elseif(CORRADE_TARGET_UNIX AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES)) elseif(CORRADE_TARGET_UNIX AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES))

5
doc/building.dox

@ -167,6 +167,11 @@ available for desktop OpenGL only, see @ref requires-gl.
`TARGET_GLES` is set. `TARGET_GLES` is set.
- `TARGET_DESKTOP_GLES` -- Target OpenGL ES on desktop, i.e. use OpenGL ES - `TARGET_DESKTOP_GLES` -- Target OpenGL ES on desktop, i.e. use OpenGL ES
emulation in desktop OpenGL library. Might not be supported in all drivers. emulation in desktop OpenGL library. Might not be supported in all drivers.
- `TARGET_HEADLESS` -- Build command-line utilities for use on a headless
machine. Basically it means that EGL with no display attachment is being
used everywhere instead of platform-specific toolkits like CGL, GLX or WGL.
Supported mainly on OpenGL ES drivers, for desktop OpenGL the only driver
that supports this configuration is NVidia >= 355.
The features used can be conveniently detected in depending projects both in The features used can be conveniently detected in depending projects both in
CMake and C++ sources, see @ref cmake and @ref Magnum/Magnum.h for more CMake and C++ sources, see @ref cmake and @ref Magnum/Magnum.h for more

4
doc/cmake.dox

@ -183,7 +183,9 @@ are also available as preprocessor variables if including
- `MAGNUM_TARGET_GLES3` -- Defined if compiled for OpenGL ES 3.0 - `MAGNUM_TARGET_GLES3` -- Defined if compiled for OpenGL ES 3.0
- `MAGNUM_TARGET_DESKTOP_GLES` -- Defined if compiled with OpenGL ES - `MAGNUM_TARGET_DESKTOP_GLES` -- Defined if compiled with OpenGL ES
emulation on desktop OpenGL emulation on desktop OpenGL
- `MAGNUM_TARGET_WEBGL` --- Defined if compiled for WebGL - `MAGNUM_TARGET_WEBGL` -- Defined if compiled for WebGL
- `MAGNUM_TARGET_HEADLESS` -- Defined if compiled for headless machines. See
@ref MAGNUM_TARGET_HEADLESS documentation for more information.
Workflows without imported targets are deprecated and the following variables Workflows without imported targets are deprecated and the following variables
are included just for backwards compatibility and only if are included just for backwards compatibility and only if

4
modules/FindMagnum.cmake

@ -109,6 +109,7 @@
# MAGNUM_TARGET_DESKTOP_GLES - Defined if compiled with OpenGL ES # MAGNUM_TARGET_DESKTOP_GLES - Defined if compiled with OpenGL ES
# emulation on desktop OpenGL # emulation on desktop OpenGL
# MAGNUM_TARGET_WEBGL - Defined if compiled for WebGL # MAGNUM_TARGET_WEBGL - Defined if compiled for WebGL
# MAGNUM_TARGET_HEADLESS - Defined if compiled for headless machines
# #
# Additionally these variables are defined for internal usage: # Additionally these variables are defined for internal usage:
# #
@ -207,7 +208,8 @@ set(_magnumFlags
TARGET_GLES2 TARGET_GLES2
TARGET_GLES3 TARGET_GLES3
TARGET_DESKTOP_GLES TARGET_DESKTOP_GLES
TARGET_WEBGL) TARGET_WEBGL
TARGET_HEADLESS)
foreach(_magnumFlag ${_magnumFlags}) foreach(_magnumFlag ${_magnumFlags})
string(FIND "${_magnumConfigure}" "#define MAGNUM_${_magnumFlag}" _magnum_${_magnumFlag}) string(FIND "${_magnumConfigure}" "#define MAGNUM_${_magnumFlag}" _magnum_${_magnumFlag})
if(NOT _magnum_${_magnumFlag} EQUAL -1) if(NOT _magnum_${_magnumFlag} EQUAL -1)

12
src/Magnum/Magnum.h

@ -143,6 +143,18 @@ which you might want to be aware of. Implies also @ref MAGNUM_TARGET_GLES and
*/ */
#define MAGNUM_TARGET_WEBGL #define MAGNUM_TARGET_WEBGL
#undef MAGNUM_TARGET_WEBGL #undef MAGNUM_TARGET_WEBGL
/**
@brief Headless target
Defined if the engine is built for use on a headless machine (without any
graphical desktop environment). Basically it means that EGL with no display
attachment is being used everywhere instead of platform-specific toolkits like
CGL, GLX or WGL. Note that this might not be supported on all platforms, see
@ref Platform::WindowlessEglApplication for more information.
*/
#define MAGNUM_TARGET_HEADLESS
#undef MAGNUM_TARGET_HEADLESS
#endif #endif
/** @{ @name Basic type definitions /** @{ @name Basic type definitions

4
src/Magnum/Platform/CMakeLists.txt

@ -657,7 +657,9 @@ endif()
if(WITH_MAGNUMINFO) if(WITH_MAGNUMINFO)
add_executable(magnum-info magnum-info.cpp) add_executable(magnum-info magnum-info.cpp)
target_link_libraries(magnum-info Magnum) target_link_libraries(magnum-info Magnum)
if(CORRADE_TARGET_APPLE) if(MAGNUM_TARGET_HEADLESS)
target_link_libraries(magnum-info MagnumWindowlessEglApplication)
elseif(CORRADE_TARGET_APPLE)
target_link_libraries(magnum-info MagnumWindowlessCglApplication) target_link_libraries(magnum-info MagnumWindowlessCglApplication)
elseif(CORRADE_TARGET_NACL) elseif(CORRADE_TARGET_NACL)
target_link_libraries(magnum-info MagnumWindowlessNaClApplication) target_link_libraries(magnum-info MagnumWindowlessNaClApplication)

11
src/Magnum/Platform/magnum-info.cpp

@ -56,7 +56,9 @@
#include "Magnum/TransformFeedback.h" #include "Magnum/TransformFeedback.h"
#endif #endif
#ifdef CORRADE_TARGET_NACL #ifdef MAGNUM_TARGET_HEADLESS
#include "Magnum/Platform/WindowlessEglApplication.h"
#elif defined(CORRADE_TARGET_NACL)
#include "Magnum/Platform/WindowlessNaClApplication.h" #include "Magnum/Platform/WindowlessNaClApplication.h"
#elif defined(CORRADE_TARGET_APPLE) #elif defined(CORRADE_TARGET_APPLE)
#include "Magnum/Platform/WindowlessCglApplication.h" #include "Magnum/Platform/WindowlessCglApplication.h"
@ -168,7 +170,9 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat
Debug() << " +---------------------------------------------------------+"; Debug() << " +---------------------------------------------------------+";
Debug() << ""; Debug() << "";
#ifdef MAGNUM_WINDOWLESSNACLAPPLICATION_MAIN #ifdef MAGNUM_WINDOWLESSEGLAPPLICATION_MAIN
Debug() << "Used application: Platform::WindowlessEglApplication";
#elif defined(MAGNUM_WINDOWLESSNACLAPPLICATION_MAIN)
Debug() << "Used application: Platform::WindowlessNaClApplication"; Debug() << "Used application: Platform::WindowlessNaClApplication";
#elif defined(MAGNUM_WINDOWLESSCGLAPPLICATION_MAIN) #elif defined(MAGNUM_WINDOWLESSCGLAPPLICATION_MAIN)
Debug() << "Used application: Platform::WindowlessCglApplication"; Debug() << "Used application: Platform::WindowlessCglApplication";
@ -245,6 +249,9 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat
#ifdef MAGNUM_TARGET_WEBGL #ifdef MAGNUM_TARGET_WEBGL
Debug() << " MAGNUM_TARGET_WEBGL"; Debug() << " MAGNUM_TARGET_WEBGL";
#endif #endif
#ifdef MAGNUM_TARGET_HEADLESS
Debug() << " MAGNUM_TARGET_HEADLESS";
#endif
Debug() << ""; Debug() << "";
/* Create context here, so the context creation info is displayed at proper /* Create context here, so the context creation info is displayed at proper

4
src/Magnum/Test/AbstractOpenGLTester.h

@ -32,7 +32,9 @@
#include "Magnum/DebugOutput.h" #include "Magnum/DebugOutput.h"
#include "Magnum/Renderer.h" #include "Magnum/Renderer.h"
#if defined(CORRADE_TARGET_APPLE) #ifdef MAGNUM_TARGET_HEADLESS
#include "Magnum/Platform/WindowlessEglApplication.h"
#elif defined(CORRADE_TARGET_APPLE)
#include "Magnum/Platform/WindowlessCglApplication.h" #include "Magnum/Platform/WindowlessCglApplication.h"
#elif defined(CORRADE_TARGET_UNIX) && (!defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_DESKTOP_GLES)) #elif defined(CORRADE_TARGET_UNIX) && (!defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_DESKTOP_GLES))
#include "Magnum/Platform/WindowlessGlxApplication.h" #include "Magnum/Platform/WindowlessGlxApplication.h"

4
src/Magnum/Text/CMakeLists.txt

@ -63,7 +63,9 @@ if(WITH_FONTCONVERTER)
add_executable(magnum-fontconverter fontconverter.cpp) add_executable(magnum-fontconverter fontconverter.cpp)
target_include_directories(magnum-fontconverter PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(magnum-fontconverter PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(magnum-fontconverter Magnum MagnumText) target_link_libraries(magnum-fontconverter Magnum MagnumText)
if(CORRADE_TARGET_APPLE) if(MAGNUM_TARGET_HEADLESS)
target_link_libraries(magnum-fontconverter MagnumWindowlessEglApplication)
elseif(CORRADE_TARGET_APPLE)
target_link_libraries(magnum-fontconverter MagnumWindowlessCglApplication) target_link_libraries(magnum-fontconverter MagnumWindowlessCglApplication)
elseif(CORRADE_TARGET_UNIX AND NOT TARGET_GLES) elseif(CORRADE_TARGET_UNIX AND NOT TARGET_GLES)
target_link_libraries(magnum-fontconverter MagnumWindowlessGlxApplication) target_link_libraries(magnum-fontconverter MagnumWindowlessGlxApplication)

4
src/Magnum/Text/fontconverter.cpp

@ -32,7 +32,9 @@
#include "Magnum/Text/DistanceFieldGlyphCache.h" #include "Magnum/Text/DistanceFieldGlyphCache.h"
#include "Magnum/Trade/AbstractImageConverter.h" #include "Magnum/Trade/AbstractImageConverter.h"
#ifdef CORRADE_TARGET_APPLE #ifdef MAGNUM_TARGET_HEADLESS
#include "Magnum/Platform/WindowlessEglApplication.h"
#elif defined(CORRADE_TARGET_APPLE)
#include "Magnum/Platform/WindowlessCglApplication.h" #include "Magnum/Platform/WindowlessCglApplication.h"
#elif defined(CORRADE_TARGET_UNIX) #elif defined(CORRADE_TARGET_UNIX)
#include "Magnum/Platform/WindowlessGlxApplication.h" #include "Magnum/Platform/WindowlessGlxApplication.h"

4
src/Magnum/TextureTools/CMakeLists.txt

@ -53,7 +53,9 @@ if(WITH_DISTANCEFIELDCONVERTER)
add_executable(magnum-distancefieldconverter distancefieldconverter.cpp) add_executable(magnum-distancefieldconverter distancefieldconverter.cpp)
target_include_directories(magnum-distancefieldconverter PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(magnum-distancefieldconverter PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(magnum-distancefieldconverter Magnum MagnumTextureTools) target_link_libraries(magnum-distancefieldconverter Magnum MagnumTextureTools)
if(CORRADE_TARGET_APPLE) if(MAGNUM_TARGET_HEADLESS)
target_link_libraries(magnum-distancefieldconverter MagnumWindowlessEglApplication)
elseif(CORRADE_TARGET_APPLE)
target_link_libraries(magnum-distancefieldconverter MagnumWindowlessCglApplication) target_link_libraries(magnum-distancefieldconverter MagnumWindowlessCglApplication)
elseif(CORRADE_TARGET_UNIX AND NOT TARGET_GLES) elseif(CORRADE_TARGET_UNIX AND NOT TARGET_GLES)
target_link_libraries(magnum-distancefieldconverter MagnumWindowlessGlxApplication) target_link_libraries(magnum-distancefieldconverter MagnumWindowlessGlxApplication)

4
src/Magnum/TextureTools/distancefieldconverter.cpp

@ -38,7 +38,9 @@
#include "Magnum/Trade/AbstractImageConverter.h" #include "Magnum/Trade/AbstractImageConverter.h"
#include "Magnum/Trade/ImageData.h" #include "Magnum/Trade/ImageData.h"
#ifdef CORRADE_TARGET_APPLE #ifdef MAGNUM_TARGET_HEADLESS
#include "Magnum/Platform/WindowlessEglApplication.h"
#elif defined(CORRADE_TARGET_APPLE)
#include "Magnum/Platform/WindowlessCglApplication.h" #include "Magnum/Platform/WindowlessCglApplication.h"
#elif defined(CORRADE_TARGET_UNIX) #elif defined(CORRADE_TARGET_UNIX)
#include "Magnum/Platform/WindowlessGlxApplication.h" #include "Magnum/Platform/WindowlessGlxApplication.h"

1
src/Magnum/configure.h.cmake

@ -30,3 +30,4 @@
#cmakedefine MAGNUM_TARGET_GLES3 #cmakedefine MAGNUM_TARGET_GLES3
#cmakedefine MAGNUM_TARGET_DESKTOP_GLES #cmakedefine MAGNUM_TARGET_DESKTOP_GLES
#cmakedefine MAGNUM_TARGET_WEBGL #cmakedefine MAGNUM_TARGET_WEBGL
#cmakedefine MAGNUM_TARGET_HEADLESS

Loading…
Cancel
Save