diff --git a/cmake/SFMLConfigDependencies.cmake.in b/cmake/SFMLConfigDependencies.cmake.in index 8028c877..b816477d 100644 --- a/cmake/SFMLConfigDependencies.cmake.in +++ b/cmake/SFMLConfigDependencies.cmake.in @@ -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) diff --git a/examples/X11/CMakeLists.txt b/examples/X11/CMakeLists.txt index 6e56ba64..55ec52c4 100644 --- a/examples/X11/CMakeLists.txt +++ b/examples/X11/CMakeLists.txt @@ -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) diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index a622ffe3..4359c091 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -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)