eclipse-mosquitto / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
9.13k stars 2.41k forks source link

Please link thread library for static build (same as shared build) #3143

Open toge opened 1 month ago

toge commented 1 month ago

Mosquitto: 2.0.20 Pthreads4w: 3.0.0 OS: Windows10 Compiler: MSVC 19.40.33812

I met a compilation error on static build due to lack of pthread.h. It works fine with following hand patch.

if (WITH_THREADING)
  if(WIN32)
    target_link_libraries(libmosquitto_static PThreads4W::PThreads4W)
  else()
    set(THREADS_PREFER_PTHREAD_FLAG ON)
    find_package(Threads REQUIRED)
    target_link_libraries(libmosquitto_static Threads::Threads)
  endif()
endif()

Is it valid workaround or not?