From 0dc500fe943f19912fb9f44a179f1b41e7a3ae12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 22 Nov 2016 08:34:59 +0100 Subject: [PATCH] Move linking to DL_LIBRARY to x11standalone platform Summary: It's only needed by the GLX backend, so only find if we have GLX at all and only link where needed. As it was handled incorrectly before, it's now using proper ifdef. Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3448 --- CMakeLists.txt | 13 ++++++++----- libkwineffects/kwinconfig.h.cmake | 1 + plugins/platforms/x11/standalone/CMakeLists.txt | 4 ++++ plugins/platforms/x11/standalone/glxbackend.cpp | 4 ++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77f369489d..e38befe435 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,6 +148,14 @@ set_package_properties(epoxy PROPERTIES DESCRIPTION "libepoxy" PURPOSE "OpenGL dispatch library" ) +set(HAVE_DL_LIBRARY FALSE) +if(epoxy_HAS_GLX) + find_library(DL_LIBRARY dl) + if(DL_LIBRARY) + set(HAVE_DL_LIBRARY TRUE) + endif() +endif() + find_package(Wayland 1.2 REQUIRED COMPONENTS Cursor OPTIONAL_COMPONENTS Egl) set_package_properties(Wayland PROPERTIES TYPE REQUIRED @@ -573,11 +581,6 @@ target_link_libraries(kwin ${kwinLibs}) generate_export_header(kwin EXPORT_FILE_NAME kwin_export.h) target_link_libraries(kwin kwinglutils ${epoxy_LIBRARY}) -# -ldl used by OpenGL code -find_library(DL_LIBRARY dl) -if (DL_LIBRARY) -target_link_libraries(kwin ${DL_LIBRARY}) -endif() kf5_add_kdeinit_executable(kwin_x11 main_x11.cpp) target_link_libraries(kdeinit_kwin_x11 kwin KF5::Crash) diff --git a/libkwineffects/kwinconfig.h.cmake b/libkwineffects/kwinconfig.h.cmake index 0ac607e7c7..4718cf0aaf 100644 --- a/libkwineffects/kwinconfig.h.cmake +++ b/libkwineffects/kwinconfig.h.cmake @@ -21,5 +21,6 @@ #cmakedefine01 HAVE_EPOXY_GLX +#cmakedefine01 HAVE_DL_LIBRARY #endif diff --git a/plugins/platforms/x11/standalone/CMakeLists.txt b/plugins/platforms/x11/standalone/CMakeLists.txt index e7f8c56648..98daa12208 100644 --- a/plugins/platforms/x11/standalone/CMakeLists.txt +++ b/plugins/platforms/x11/standalone/CMakeLists.txt @@ -21,6 +21,10 @@ if(X11_Xinput_FOUND) target_link_libraries(KWinX11Platform ${X11_Xinput_LIB}) endif() +if(HAVE_DL_LIBRARY) + target_link_libraries(KWinX11Platform ${DL_LIBRARY}) +endif() + install( TARGETS KWinX11Platform diff --git a/plugins/platforms/x11/standalone/glxbackend.cpp b/plugins/platforms/x11/standalone/glxbackend.cpp index 59599acd64..fc988eca26 100644 --- a/plugins/platforms/x11/standalone/glxbackend.cpp +++ b/plugins/platforms/x11/standalone/glxbackend.cpp @@ -43,7 +43,9 @@ along with this program. If not, see . #include #include +#if HAVE_DL_LIBRARY #include +#endif #ifndef XCB_GLX_BUFFER_SWAP_COMPLETE #define XCB_GLX_BUFFER_SWAP_COMPLETE 1 @@ -159,8 +161,10 @@ static glXFuncPtr getProcAddress(const char* name) #if HAVE_EPOXY_GLX ret = glXGetProcAddress((const GLubyte*) name); #endif +#if HAVE_DL_LIBRARY if (ret == nullptr) ret = (glXFuncPtr) dlsym(RTLD_DEFAULT, name); +#endif return ret; } glXSwapIntervalMESA_func glXSwapIntervalMESA;