3461: Link with -pthread instead of -lpthread r=def- a=yangfl

The canonical way to link with the thread library is to use -pthread, which
brings in additional libraries like libatomic.so on riscv64. However cmake
defaults to link with -lpthread which only bring the libpthread.so library.
Fortunately it has the option THREADS_PREFER_PTHREAD_FLAG for that, which is
"highly recommended" but not the default.

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Aurelien Jarno <aurel32@debian.org>
This commit is contained in:
bors[bot] 2020-12-30 14:12:47 +00:00 committed by GitHub
commit 71a371a4ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -367,6 +367,10 @@ find_package(Pnglite)
find_package(PythonInterp 3)
find_package(SDL2)
find_package(SQLite3)
if(UNIX)
# Use -pthread instead of -lpthread to draw dependencies other than libpthread
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
endif()
find_package(Threads)
find_package(Wavpack)
if(WEBSOCKETS)