cmake: Refactor threadlib linking

This commit is contained in:
Roger A. Light
2026-05-03 01:17:26 +01:00
committed by Roger Light
parent 0102b95af1
commit 53822b18eb
3 changed files with 7 additions and 12 deletions
+5
View File
@@ -119,6 +119,11 @@ if(WITH_THREADING)
add_definitions("-DWITH_THREADING")
if(WIN32)
find_package(PThreads4W REQUIRED)
set (THREADLIB PThreads4W::PThreads4W)
else()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set (THREADLIB Threads::Threads)
endif()
endif()
+1 -8
View File
@@ -100,14 +100,7 @@ target_include_directories(libmosquitto
)
if(WITH_THREADING)
if(WIN32)
set (LIBRARIES ${LIBRARIES} PThreads4W::PThreads4W)
else()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set (LIBRARIES ${LIBRARIES} Threads::Threads)
endif()
set (LIBRARIES ${LIBRARIES} ${THREADLIB})
endif()
target_link_libraries(libmosquitto PUBLIC ${LIBRARIES})
+1 -4
View File
@@ -19,10 +19,7 @@ target_link_libraries(mosquittopp
)
if (WITH_THREADING AND NOT WIN32)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(mosquittopp PRIVATE Threads::Threads)
target_link_libraries(mosquittopp PRIVATE ${THREADLIB})
endif()
set_target_properties(mosquittopp PROPERTIES