summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorStenzek <stenzek@gmail.com>2018-10-14 23:17:31 +1000
committerStenzek <stenzek@gmail.com>2018-10-20 21:11:34 +1000
commitc95802afeb2ebc702bed61a9437f6e85e4f833e0 (patch)
tree780446eda726457d4f8716a7024fea3286d13f7b /Source/Core
parent0559311f929d62904c6f14c67d3944fb4142aaaf (diff)
CMake: Make X11 and EGL optional
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/CMakeLists.txt13
-rw-r--r--Source/Core/Common/GL/GLContext.cpp63
-rw-r--r--Source/Core/UICommon/CMakeLists.txt2
3 files changed, 50 insertions, 28 deletions
diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt
index 62fbb9d0d3..b75c88d013 100644
--- a/Source/Core/Common/CMakeLists.txt
+++ b/Source/Core/Common/CMakeLists.txt
@@ -113,12 +113,15 @@ target_sources(common PRIVATE
GL/GLContext.cpp
)
-if(ENABLE_EGL)
+if(ENABLE_EGL AND EGL_FOUND)
target_sources(common PRIVATE GL/GLInterface/EGL.cpp)
if(ANDROID)
target_sources(common PRIVATE GL/GLInterface/EGLAndroid.cpp)
+ elseif(ENABLE_X11 AND X11_FOUND)
+ target_sources(common PRIVATE GL/GLInterface/EGLX11.cpp)
endif()
- target_link_libraries(common PUBLIC EGL)
+ target_include_directories(common PRIVATE ${EGL_INCLUDE_DIRS})
+ target_link_libraries(common PUBLIC ${EGL_LIBRARIES})
endif()
if(WIN32)
@@ -128,7 +131,7 @@ if(WIN32)
)
elseif(APPLE)
target_sources(common PRIVATE GL/GLInterface/AGL.mm)
-elseif(ENABLE_X11)
+elseif(ENABLE_X11 AND X11_FOUND)
target_sources(common PRIVATE
GL/GLX11Window.cpp
GL/GLInterface/GLX.cpp)
@@ -136,10 +139,6 @@ elseif(ENABLE_X11)
# GLX has a hard dependency on libGL.
# Make sure to link to it if using GLX.
target_link_libraries(common PUBLIC ${OPENGL_LIBRARIES})
-
- if (ENABLE_EGL)
- target_sources(common PRIVATE GL/GLInterface/EGLX11.cpp)
- endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
diff --git a/Source/Core/Common/GL/GLContext.cpp b/Source/Core/Common/GL/GLContext.cpp
index 81bf4e12b6..d4a9ed2e7a 100644
--- a/Source/Core/Common/GL/GLContext.cpp
+++ b/Source/Core/Common/GL/GLContext.cpp
@@ -8,15 +8,21 @@
#if defined(__APPLE__)
#include "Common/GL/GLInterface/AGL.h"
-#elif defined(_WIN32)
+#endif
+#if defined(WIN32)
#include "Common/GL/GLInterface/WGL.h"
-#elif defined(ANDROID)
-#include "Common/GL/GLInterface/EGLAndroid.h"
-#elif HAVE_X11
-#include "Common/GL/GLInterface/EGLX11.h"
+#endif
+#if HAVE_X11
#include "Common/GL/GLInterface/GLX.h"
-#elif HAVE_EGL
+#endif
+#if HAVE_EGL
#include "Common/GL/GLInterface/EGL.h"
+#if HAVE_X11
+#include "Common/GL/GLInterface/EGLX11.h"
+#endif
+#if defined(ANDROID)
+#include "Common/GL/GLInterface/EGLAndroid.h"
+#endif
#endif
GLContext::~GLContext() = default;
@@ -72,22 +78,39 @@ std::unique_ptr<GLContext> GLContext::Create(const WindowSystemInfo& wsi, bool s
{
std::unique_ptr<GLContext> context;
#if defined(__APPLE__)
- context = std::make_unique<GLContextAGL>();
-#elif defined(_WIN32)
- context = std::make_unique<GLContextWGL>();
-#elif defined(ANDROID)
- context = std::make_unique<GLContextEGLAndroid>();
-#elif HAVE_X11
- // GLES is not supported via GLX?
- if (prefer_egl || prefer_gles)
- context = std::make_unique<GLContextEGLX11>();
- else
- context = std::make_unique<GLContextGLX>();
-#elif HAVE_EGL
- context = std::make_unique<GLContextEGL>();
+ if (wsi.type == WindowSystemType::MacOS || wsi.type == WindowSystemType::Headless)
+ context = std::make_unique<GLContextAGL>();
+#endif
+#if defined(_WIN32)
+ if (wsi.type == WindowSystemType::Windows)
+ context = std::make_unique<GLContextWGL>();
+#endif
+#if defined(ANDROID)
+ if (wsi.type == WindowSystemType::Android)
+ context = std::make_unique<GLContextEGLAndroid>();
+#endif
+#if HAVE_X11
+ if (wsi.type == WindowSystemType::X11)
+ {
+ // GLES 3 is not supported via GLX.
+ const bool use_egl = prefer_egl || prefer_gles;
+#if defined(HAVE_EGL)
+ if (use_egl)
+ context = std::make_unique<GLContextEGLX11>();
+ else
+ context = std::make_unique<GLContextGLX>();
#else
- return nullptr;
+ context = std::make_unique<GLContextGLX>();
#endif
+ }
+#endif
+#if HAVE_EGL
+ if (wsi.type == WindowSystemType::Headless)
+ context = std::make_unique<GLContextEGL>();
+#endif
+
+ if (!context)
+ return nullptr;
// Option to prefer GLES on desktop platforms, useful for testing.
if (prefer_gles)
diff --git a/Source/Core/UICommon/CMakeLists.txt b/Source/Core/UICommon/CMakeLists.txt
index 5956031531..f5ef5d6f11 100644
--- a/Source/Core/UICommon/CMakeLists.txt
+++ b/Source/Core/UICommon/CMakeLists.txt
@@ -24,7 +24,7 @@ if ((DEFINED CMAKE_ANDROID_ARCH_ABI AND CMAKE_ANDROID_ARCH_ABI MATCHES "x86|x86_
target_link_libraries(uicommon PRIVATE bdisasm)
endif()
-if(ENABLE_X11)
+if(ENABLE_X11 AND X11_FOUND)
target_include_directories(uicommon PRIVATE ${X11_INCLUDE_DIR})
target_sources(uicommon PRIVATE X11Utils.cpp)
target_link_libraries(uicommon PUBLIC ${XRANDR_LIBRARIES})