Skip to content

Commit

Permalink
Prefer -pthread flag for pthread
Browse files Browse the repository at this point in the history
According to gcc doc, `-pthread` flag will link the program against
libraries like libatomic on demand. Using `-lpthread` in CFLAGS and
LDFLAGS causes absense of these libraries, thus failing to build on
architectures which needs soft atomic operation implementation.
  • Loading branch information
r-value committed Nov 24, 2021
1 parent 041935e commit 8ee4966
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions cmake/LinkHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ macro(target_link_static_threads TARGET)
# use a statically link winpthread
target_link_libraries("${TARGET}" PRIVATE "-Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive,-Bdynamic")
else()
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
target_link_libraries("${TARGET}" PRIVATE ${CMAKE_THREAD_LIBS_INIT})
endif()
Expand Down

0 comments on commit 8ee4966

Please sign in to comment.