[Bf-blender-cvs] [d7d140ec7ff] master: CMake: add WITH_GHOST_X11 option

Campbell Barton noreply at git.blender.org
Fri May 1 12:08:53 CEST 2020


Commit: d7d140ec7ffa4d84433c3075a4cc909ce584a3ab
Author: Campbell Barton
Date:   Fri May 1 20:07:01 2020 +1000
Branches: master
https://developer.blender.org/rBd7d140ec7ffa4d84433c3075a4cc909ce584a3ab

CMake: add WITH_GHOST_X11 option

- Support building only with Wayland.
- In this case, show useful error messages
  when Wayland fails to load.

===================================================================

M	CMakeLists.txt
M	intern/ghost/intern/GHOST_ISystem.cpp
M	intern/ghost/intern/GHOST_SystemWayland.cpp

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f4ccd8483ca..a168bff2377 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -138,11 +138,6 @@ get_blender_version()
 #-----------------------------------------------------------------------------
 # Options
 
-# First platform specific non-cached vars
-if(UNIX AND NOT (APPLE OR HAIKU))
-  set(WITH_GHOST_X11 ON)
-endif()
-
 # Blender internal features
 option(WITH_BLENDER "Build blender (disable to build only the blender player)" ON)
 mark_as_advanced(WITH_BLENDER)
@@ -207,8 +202,12 @@ mark_as_advanced(WITH_GHOST_DEBUG)
 option(WITH_GHOST_SDL    "Enable building Blender against SDL for windowing rather than the native APIs" OFF)
 mark_as_advanced(WITH_GHOST_SDL)
 
-if(UNIX AND NOT APPLE)
-  option(WITH_GHOST_WAYLAND   "Enable building Blender against Wayland for windowing" OFF)
+if(UNIX AND NOT (APPLE OR HAIKU))
+  option(WITH_GHOST_X11 "Enable building Blender against X11 for windowing" ON)
+  mark_as_advanced(WITH_GHOST_X11)
+
+  option(WITH_GHOST_WAYLAND "Enable building Blender against Wayland for windowing (under development)" OFF)
+  mark_as_advanced(WITH_GHOST_WAYLAND)
 endif()
 
 if(WITH_GHOST_X11)
@@ -693,6 +692,7 @@ if(WITH_INSTALL_PORTABLE)
 endif()
 
 if(WITH_GHOST_SDL OR WITH_HEADLESS)
+  set(WITH_GHOST_WAYLAND OFF)
   set(WITH_GHOST_X11     OFF)
   set(WITH_X11_XINPUT    OFF)
   set(WITH_X11_XF86VMODE OFF)
diff --git a/intern/ghost/intern/GHOST_ISystem.cpp b/intern/ghost/intern/GHOST_ISystem.cpp
index 11d1c501d04..9e3bf66d925 100644
--- a/intern/ghost/intern/GHOST_ISystem.cpp
+++ b/intern/ghost/intern/GHOST_ISystem.cpp
@@ -54,30 +54,30 @@ GHOST_TSuccess GHOST_ISystem::createSystem()
 {
   GHOST_TSuccess success;
   if (!m_system) {
-#if defined(WITH_GHOST_X11) || defined(WITH_GHOST_WAYLAND)
-#  ifdef WITH_GHOST_WAYLAND
+#if defined(WITH_GHOST_X11) && defined(WITH_GHOST_WAYLAND)
+    /* Special case, try Wayland, fall back to X11. */
     try {
       m_system = new GHOST_SystemWayland();
     }
-    catch (const std::exception &) {
+    catch (const std::runtime_error &) {
+      /* fallback to X11. */
     }
-#  endif
-#  ifdef WITH_GHOST_X11
     if (!m_system) {
       m_system = new GHOST_SystemX11();
     }
-#  endif
-#else
-#  ifdef WITH_HEADLESS
+#elif defined(WITH_GHOST_X11)
+    m_system = new GHOST_SystemX11();
+#elif defined(WITH_GHOST_WAYLAND)
+    m_system = new GHOST_SystemWayland();
+#elif defined(WITH_HEADLESS)
     m_system = new GHOST_SystemNULL();
-#  elif defined(WITH_GHOST_SDL)
+#elif defined(WITH_GHOST_SDL)
     m_system = new GHOST_SystemSDL();
-#  elif defined(WIN32)
+#elif defined(WIN32)
     m_system = new GHOST_SystemWin32();
-#  else
-#    ifdef __APPLE__
+#else
+#  ifdef __APPLE__
     m_system = new GHOST_SystemCocoa();
-#    endif
 #  endif
 #endif
     success = m_system != NULL ? GHOST_kSuccess : GHOST_kFailure;
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 9030a02abb1..666515ed088 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -1197,7 +1197,7 @@ GHOST_SystemWayland::GHOST_SystemWayland() : GHOST_System(), d(new display_t)
   d->display = wl_display_connect(nullptr);
   if (!d->display) {
     display_destroy(d);
-    throw std::exception();
+    throw std::runtime_error("Wayland: unable to connect to display!");
   }
 
   /* Register interfaces. */
@@ -1211,7 +1211,7 @@ GHOST_SystemWayland::GHOST_SystemWayland() : GHOST_System(), d(new display_t)
 
   if (!d->xdg_shell) {
     display_destroy(d);
-    throw std::exception();
+    throw std::runtime_error("Wayland: unable to access xdg_shell!");
   }
 
   /* Register data device per seat for IPC between Wayland clients. */
@@ -1230,7 +1230,7 @@ GHOST_SystemWayland::GHOST_SystemWayland() : GHOST_System(), d(new display_t)
   d->cursor_theme = wl_cursor_theme_load(theme, sizei, d->shm);
   if (!d->cursor_theme) {
     display_destroy(d);
-    throw std::exception();
+    throw std::runtime_error("Wayland: unable to access cursor themes!");
   }
 }



More information about the Bf-blender-cvs mailing list