diff --git a/cmake/SFMLConfigDependencies.cmake.in b/cmake/SFMLConfigDependencies.cmake.in index 6762accff..7a67583e5 100644 --- a/cmake/SFMLConfigDependencies.cmake.in +++ b/cmake/SFMLConfigDependencies.cmake.in @@ -24,6 +24,9 @@ if(SFML_STATIC_LIBRARIES) # start with an empty list set(FIND_SFML_DEPENDENCIES_NOTFOUND) + # SFML::System + find_dependency(Threads) + # SFML::Window list(FIND SFML_FIND_COMPONENTS "Window" FIND_SFML_WINDOW_COMPONENT_INDEX) if(FIND_SFML_WINDOW_COMPONENT_INDEX GREATER -1) diff --git a/examples/island/CMakeLists.txt b/examples/island/CMakeLists.txt index 25ab69c77..a19660413 100644 --- a/examples/island/CMakeLists.txt +++ b/examples/island/CMakeLists.txt @@ -1,3 +1,5 @@ +find_package(Threads REQUIRED) + # all source files set(SRC Island.cpp) @@ -10,7 +12,4 @@ sfml_add_example(island GUI_APP # external dependency headers target_include_directories(island SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/examples/island) -# link against pthread -if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOS) - target_link_libraries(island PRIVATE pthread) -endif() +target_link_libraries(island PRIVATE Threads::Threads) diff --git a/src/SFML/System/CMakeLists.txt b/src/SFML/System/CMakeLists.txt index d69f3e70d..74d48531c 100644 --- a/src/SFML/System/CMakeLists.txt +++ b/src/SFML/System/CMakeLists.txt @@ -65,6 +65,8 @@ else() source_group("unix" FILES ${PLATFORM_SRC}) endif() +find_package(Threads REQUIRED) + # define the sfml-system target sfml_add_library(System SOURCES ${SRC} ${PLATFORM_SRC}) @@ -80,10 +82,7 @@ if(SFML_OS_ANDROID) target_include_directories(sfml-system SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/glad/include") endif() -# setup dependencies -if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOS) - target_link_libraries(sfml-system PRIVATE pthread) -endif() +target_link_libraries(sfml-system PRIVATE Threads::Threads) if(SFML_OS_LINUX) target_link_libraries(sfml-system PRIVATE rt)