mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-23 16:43:49 +08:00
cmake: Refactor threadlib linking
This commit is contained in:
committed by
Roger Light
parent
0102b95af1
commit
53822b18eb
@@ -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
@@ -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})
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user