What do I have to add for the QT Websockets module in CMake?



  • In my current project, I only need the Qt Websocket module. What do I have to add to my CMake file to link it correctly?

    TARGET_LINK_LIBRARIES(main Qt5::WebSockets)
    qt5_use_modules(main WebSockets)
    

    does not seem to work. Any suggestions?


  • Lifetime Qt Champion

    Hi,

    Do you have find_package(Qt5WebSockets REQUIRED) in your CMakeList.txt file ?



  • sorry for the late answer, yes i have this in my CMakeLists.txt. Without this line, the output is something like " cannot use Websockets because it was not found yet".

    CMake Error at CMakeLists.txt:24 (find_package):
    By not providing "FindQt5WebSockets.cmake" in CMAKE_MODULE_PATH this
    project has asked CMake to find a package configuration file provided by
    "Qt5WebSockets", but CMake did not find one.
    Could not find a package configuration file provided by "Qt5WebSockets"
    with any of the following names:
    Qt5WebSocketsConfig.cmake
    qt5websockets-config.cmake
    Add the installation prefix of "Qt5WebSockets" to CMAKE_PREFIX_PATH or set
    "Qt5WebSockets_DIR" to a directory containing one of the above files.  If
    "Qt5WebSockets" provides a separate development package or SDK, be sure it
    has been installed.
    

    -- Configuring incomplete, errors occurred!

    I tried multiple installations on this machine including the online installer from the website and via apt-get. Is there an

    apt-get install libqt5websockets-dev
    

    or something available?


  • Lifetime Qt Champion

    What version of Qt are you using ? And how did you install it ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.