Use X11's find module

Added in CMake 3.14 so this wasn't accessible in prior versions of
SFML
This commit is contained in:
Chris Thrasher 2023-02-05 17:23:57 -07:00
parent 938e90b7d2
commit eb162df723
3 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,7 @@
# in case of static linking, we must also define the list of all the dependencies of SFML libraries
if(SFML_STATIC_LIBRARIES)
include(CMakeFindDependencyMacro)
# detect the OS
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(FIND_SFML_OS_WINDOWS 1)
@ -40,9 +42,7 @@ if(SFML_STATIC_LIBRARIES)
list(FIND SFML_FIND_COMPONENTS "Window" FIND_SFML_WINDOW_COMPONENT_INDEX)
if(FIND_SFML_WINDOW_COMPONENT_INDEX GREATER -1)
if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
sfml_bind_dependency(TARGET X11 FRIENDLY_NAME "X11" SEARCH_NAMES "X11")
sfml_bind_dependency(TARGET X11 FRIENDLY_NAME "Xrandr" SEARCH_NAMES "Xrandr")
sfml_bind_dependency(TARGET X11 FRIENDLY_NAME "Xcursor" SEARCH_NAMES "Xcursor")
find_dependency(X11)
endif()
if(FIND_SFML_OS_LINUX)

View File

@ -1,10 +1,12 @@
find_package(X11 REQUIRED)
# all source files
set(SRC X11.cpp)
# define the X11 target
sfml_add_example(X11Example GUI_APP
SOURCES ${SRC}
DEPENDS SFML::Window X11)
DEPENDS SFML::Window X11::X11)
# external dependency headers
target_include_directories(X11Example SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/examples/include)

View File

@ -285,8 +285,8 @@ if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD)
sfml_find_package(GBM INCLUDE "GBM_INCLUDE_DIR" LINK "GBM_LIBRARY")
target_link_libraries(sfml-window PRIVATE drm gbm EGL)
else()
sfml_find_package(X11 INCLUDE "X11_INCLUDE_DIR" LINK "X11_X11_LIB" "X11_Xrandr_LIB" "X11_Xcursor_LIB")
target_link_libraries(sfml-window PRIVATE X11)
find_package(X11 REQUIRED)
target_link_libraries(sfml-window PRIVATE X11::X11 X11::Xrandr X11::Xcursor)
endif()
endif()
target_link_libraries(sfml-window PUBLIC SFML::System)