CMake: Use Threads instead of pthread directly

On some systems, such as Android, threads are not provided via
`-lpthread`.

CMake comes with a built-in module for finding the correct threads
library.

Use it to fix the linking issue on Android and possibly other systems.
This commit is contained in:
Gleb Mazovetskiy
2021-01-20 02:16:51 +00:00
parent 48514d038b
commit 6442613ba6
8 changed files with 22 additions and 11 deletions

View File

@@ -180,7 +180,8 @@ ELSE(WIN32)
ENDIF(BUILD_CLSOCKET)
IF(NOT APPLE)
LINK_LIBRARIES( pthread ${DL} )
FIND_PACKAGE(Threads)
LINK_LIBRARIES( ${CMAKE_THREAD_LIBS_INIT} ${DL} )
ENDIF(NOT APPLE)
ENDIF(WIN32)

View File

@@ -146,7 +146,8 @@ ELSE(WIN32)
ENDIF(BUILD_CLSOCKET)
IF(NOT APPLE)
LINK_LIBRARIES( pthread ${DL} )
FIND_PACKAGE(Threads)
LINK_LIBRARIES( ${CMAKE_THREAD_LIBS_INIT} ${DL} )
ENDIF(NOT APPLE)
ENDIF(WIN32)