Skip to content

Commit 7b34dcb

Browse files
Link c11 threading library on BSD operating systems.
1 parent efe2a04 commit 7b34dcb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,20 @@ target_include_directories(qthread
7676
PRIVATE "../include"
7777
)
7878
set_target_properties(qthread PROPERTIES C_VISIBILITY_PRESET hidden)
79+
80+
# Link pthreads.
7981
target_link_libraries(qthread PUBLIC Threads::Threads)
82+
83+
# The c11 threading library has to be linked
84+
# via a separate library on BSD OSs.
85+
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD" OR
86+
"${CMAKE_SYSTEM_NAME}" STREQUAL "kFreeBSD" OR
87+
"${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD" OR
88+
"${CMAKE_SYSTEM_NAME}" STREQUAL "NetBSD" OR
89+
"${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")
90+
target_link_libraries(qthread PUBLIC "stdthreads")
91+
endif()
92+
8093
if ("${QTHREADS_TOPOLOGY}" STREQUAL "hwloc" OR "${QTHREADS_TOPOLOGY}" STREQUAL "binders")
8194
find_package(hwloc REQUIRED)
8295
target_include_directories(qthread PRIVATE "${hwloc_INCLUDE_DIR}")

0 commit comments

Comments
 (0)