tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

websockets cmake woes



I just updated mosquitto, which uses websockets.  That exposed a bug in
the libwebsockets package.  This message is about that bug.

mosquitto has

  set (MOSQ_LIBS ${MOSQ_LIBS} websockets_shared)

when asked to use websockets.  This seemed bizarre to me, but apparently
this is how the cmake files installed by libwebsockets are supposed to
work.

In /usr/pkg/lib/cmake/libwebsockets/LibwebsocketsTargets.cmake
there is, apparently directly from upstream:

  set_target_properties(websockets_shared PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/usr/include"
    INTERFACE_LINK_LIBRARIES "dl;/usr/lib/libssl.so;/usr/lib/libcrypto.so;/usr/lib/libssl.so;/usr/lib/libcrypto.so"
  )

and the result is injecting -ldl into the mosquitto build.  That's wrong
on many systems, including *BSD.

objdump shows websockets needs

  NEEDED               libssl.so.15
  NEEDED               libcrypto.so.15
  NEEDED               libc.so.12

and websockets's bl3 includes openssl, so all is ok from the
straightforward pkgsrc viewpoint.

The question is then what is the root cause of this (besides "cmake", which
while not wrong, is unhelpful).

It seems websockets has defined some complicated scheme supporting
static and shared libs, but we aren't playing along.   But, I can't see
anything in the Makefile that tries to change upstream.

libwebsockets does install pkgconfig files, and that those look fine.

It seems mosquitto has fairly straightforward usage:

  option(WITH_WEBSOCKETS "Include websockets support?" OFF)
  option(STATIC_WEBSOCKETS "Use the static libwebsockets library?" OFF)
  if (WITH_WEBSOCKETS)
          find_package(libwebsockets)
          add_definitions("-DWITH_WEBSOCKETS")
  endif (WITH_WEBSOCKETS)
  
and then less straightforward:

  if (WITH_WEBSOCKETS)
          if (STATIC_WEBSOCKETS)
                  set (MOSQ_LIBS ${MOSQ_LIBS} websockets_static)
                  if (WIN32)
                          set (MOSQ_LIBS ${MOSQ_LIBS} iphlpapi)
                          link_directories(${mosquitto_SOURCE_DIR})
                  endif (WIN32)
          else (STATIC_WEBSOCKETS)
                  set (MOSQ_LIBS ${MOSQ_LIBS} websockets_shared)
          endif (STATIC_WEBSOCKETS)
  endif (WITH_WEBSOCKETS)

Overall, I lean to this being a bug in upstream websockets, which is
causing a cmake file to be installed that adds libraries that were not
determined to be ok during the websockets configure/build.


Home | Main Index | Thread Index | Old Index