From 44d3da02a90c4148d34f18778370aa1c21463d02 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Thu, 14 Jan 2021 21:40:16 +0000 Subject: [PATCH] Fix osgViewer `USE_GRAPHICSWINDOW` without a windowing system There is no way for the user to know whether OSG was compiled with a windowing system. This means calling USE_GRAPHICSWINDOW() in client libraries was unsafe in the case of the "None" windowing system, as it would fail to link. Turns the call into a no-op in that case. --- CMakeLists.txt | 3 +++ include/osgViewer/GraphicsWindow | 4 +++- src/osg/Config.in | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d339b709..a097fe9b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,6 +121,9 @@ ELSE() SET(OSG_WINDOWING_SYSTEM "X11" CACHE STRING "Windowing system type for graphics window creation; options: X11 or None.") ENDIF() +IF(OSG_WINDOWING_SYSTEM STREQUAL "None") + SET(OSG_WINDOWING_SYSTEM_NONE ON INTERNAL "No windowing system") +ENDIF() SET(OPENSCENEGRAPH_VERSION ${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}) diff --git a/include/osgViewer/GraphicsWindow b/include/osgViewer/GraphicsWindow index c2eb6aacb..bc57f27d7 100644 --- a/include/osgViewer/GraphicsWindow +++ b/include/osgViewer/GraphicsWindow @@ -283,7 +283,9 @@ struct GraphicsWindowFunctionProxy extern "C" void graphicswindow_##ext(void); \ static osgViewer::GraphicsWindowFunctionProxy graphicswindowproxy_##ext(graphicswindow_##ext); -#if defined(_WIN32) +#if defined(OSG_WINDOWING_SYSTEM_NONE) + #define USE_GRAPHICS_WINDOW() +#elif defined(_WIN32) #define USE_GRAPHICSWINDOW() USE_GRAPICSWINDOW_IMPLEMENTATION(Win32) #elif defined(__APPLE__) #if defined(OSG_WINDOWING_SYSTEM_CARBON) diff --git a/src/osg/Config.in b/src/osg/Config.in index 342069a08..cfb5f8a77 100644 --- a/src/osg/Config.in +++ b/src/osg/Config.in @@ -37,5 +37,6 @@ #cmakedefine OSG_USE_DEPRECATED_API #cmakedefine OSG_ENVVAR_SUPPORTED #cmakedefine OSG_WINDOWING_SYSTEM_CARBON +#cmakedefine OSG_WINDOWING_SYSTEM_NONE #endif