Skip to content

Instantly share code, notes, and snippets.

@substring
Created March 11, 2022 13:42
Show Gist options
  • Save substring/85087485e71a3bc0db00ab0a3de2694a to your computer and use it in GitHub Desktop.
Save substring/85087485e71a3bc0db00ab0a3de2694a to your computer and use it in GitHub Desktop.
SFML
From 1e687457dcced7b5a3082edaf17d21fd5a25750d Mon Sep 17 00:00:00 2001
From: Substring <frog2wah@gmail.com>
Date: Fri, 11 Mar 2022 14:38:32 +0100
Subject: [PATCH] Fix examples linking errors
---
examples/CMakeLists.txt | 4 +++-
examples/window/CMakeLists.txt | 2 +-
src/SFML/Window/CMakeLists.txt | 6 +++---
src/SFML/Window/EglContext.cpp | 2 +-
src/SFML/Window/EglContext.hpp | 2 +-
5 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 48a799f8..e5374384 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -31,7 +31,9 @@ if(SFML_BUILD_GRAPHICS)
if(SFML_OS_WINDOWS)
add_subdirectory(win32)
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD)
- add_subdirectory(X11)
+ if(NOT SFML_USE_DRM)
+ add_subdirectory(X11)
+ endif()
elseif(SFML_OS_MACOSX AND ${CMAKE_GENERATOR} MATCHES "Xcode")
add_subdirectory(cocoa)
endif()
diff --git a/examples/window/CMakeLists.txt b/examples/window/CMakeLists.txt
index ccb1d6c5..d0af6ca5 100644
--- a/examples/window/CMakeLists.txt
+++ b/examples/window/CMakeLists.txt
@@ -10,4 +10,4 @@ sfml_add_example(window GUI_APP
DEPENDS sfml-window)
# external dependency headers
-target_include_directories(window SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/examples/window)
\ No newline at end of file
+target_include_directories(window SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/examples/window)
diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt
index 6b887e64..0493748e 100644
--- a/src/SFML/Window/CMakeLists.txt
+++ b/src/SFML/Window/CMakeLists.txt
@@ -258,10 +258,10 @@ sfml_add_library(sfml-window
if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD)
if(SFML_USE_DRM)
target_sources(sfml-window PRIVATE $<TARGET_OBJECTS:drm-common>)
- sfml_find_package(DRM INCLUDE "DRM_INCLUDE_DIR" LINK "DRM_LIB")
- target_link_libraries(sfml-window PRIVATE drm)
+ sfml_find_package(DRM INCLUDE "DRM_INCLUDE_DIR" LINK "DRM_LIBRARY")
target_include_directories(sfml-window PRIVATE ${PROJECT_SOURCE_DIR}/extlibs/headers/drm ${DRM_INCLUDE_DIR}/libdrm)
- sfml_find_package(GBM INCLUDE "GBM_INCLUDE_DIR" LINK "GBM_LIB")
+ sfml_find_package(GBM INCLUDE "GBM_INCLUDE_DIR" LINK "GBM_LIBRARY")
+ target_link_libraries(sfml-window PRIVATE drm gbm EGL)
add_library(drm-common OBJECT ${PROJECT_SOURCE_DIR}/extlibs/headers/drm/drm-common.c)
target_include_directories(drm-common PRIVATE ${PROJECT_SOURCE_DIR}/extlibs/headers/drm ${DRM_INCLUDE_DIR}/libdrm)
else()
diff --git a/src/SFML/Window/EglContext.cpp b/src/SFML/Window/EglContext.cpp
index 794c236f..a43a211a 100644
--- a/src/SFML/Window/EglContext.cpp
+++ b/src/SFML/Window/EglContext.cpp
@@ -361,7 +361,7 @@ void EglContext::updateSettings()
}
-#ifdef SFML_SYSTEM_LINUX
+#if defined(SFML_SYSTEM_LINUX) && !defined(SFML_USE_DRM)
////////////////////////////////////////////////////////////
XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsPerPixel, const ContextSettings& settings)
{
diff --git a/src/SFML/Window/EglContext.hpp b/src/SFML/Window/EglContext.hpp
index 3921cb99..7945c2ee 100644
--- a/src/SFML/Window/EglContext.hpp
+++ b/src/SFML/Window/EglContext.hpp
@@ -165,7 +165,7 @@ public:
////////////////////////////////////////////////////////////
static EGLConfig getBestConfig(EGLDisplay display, unsigned int bitsPerPixel, const ContextSettings& settings);
-#ifdef SFML_SYSTEM_LINUX
+#if defined(SFML_SYSTEM_LINUX) && !defined(SFML_USE_DRM)
////////////////////////////////////////////////////////////
/// \brief Select the best EGL visual for a given set of settings
///
--
2.17.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment