Use cross-platform threading library target

This commit is contained in:
Chris Thrasher 2023-09-22 11:35:40 -06:00
parent 3acb69e347
commit d6c18af926
3 changed files with 9 additions and 8 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)