В соответствии с https://blog.kitware.com/cmake-finding-qt5-the-right-way/, метод find_package(Qt5 COMPONENTS Core Qml Quick Svg Qt5WebSockets REQUIRED)
позволяет мне загружать много пакетов QT5, имея возможность установить корень QT только один раз, установив переменную Qt5_DIR
.Я пытаюсь скомпилировать минимальный проект CMake, который указан ниже, используя эту технику. Вы видите, что WebSockets не найден.В чем проблема?
PS: Мой домашний каталог на /home/lz/Qt5.11.2
действительно имеет новую установку Qt, которую установщик Qt только что установил для меня, и в ней действительно есть libwebsockets и включаемые файлы websocket.
Мой CMakeLists.txt:
find_package(Qt5 COMPONENTS Core Qml Quick Svg Qt5WebSockets REQUIRED)
Как мне его запустить:
cmake -DQt5_DIR=/home/lz/Qt5.11.2 .
-- The C compiler identification is GNU 7.2.0
-- The CXX compiler identification is GNU 7.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake:28 (find_package):
Could not find a package configuration file provided by "Qt5Qt5WebSockets"
with any of the following names:
Qt5Qt5WebSocketsConfig.cmake
qt5qt5websockets-config.cmake
Add the installation prefix of "Qt5Qt5WebSockets" to CMAKE_PREFIX_PATH or
set "Qt5Qt5WebSockets_DIR" to a directory containing one of the above
files. If "Qt5Qt5WebSockets" provides a separate development package or
SDK, be sure it has been installed.
Call Stack (most recent call first):
CMakeLists.txt:1 (find_package)
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.9)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring incomplete, errors occurred!
See also "/home/lz/c/CMakeFiles/CMakeOutput.log".
PS: без WebSockets cmake просто «компилирует», поэтому WebSocketsединственный модуль не найден
ОБНОВЛЕНИЕ:
После справки, приведенной ниже, у меня все еще есть ошибка, связанная с WebSocket:
/home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src/websocketmodule.cpp:12:10: fatal error: QWebSocket: No such file or directory
#include <QWebSocket>
и теперь я успешно использую свой QT, как вы можете видеть в подробном выводе:
[ 50%] Building CXX object CMakeFiles/m.dir/main.o
/usr/bin/c++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/include -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/include/QtWidgets -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/include/QtGui -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/include/QtCore -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/./mkspecs/linux-g++ -fPIC -std=gnu++11 -o CMakeFiles/m.dir/main.o -c /home/lz/c/main.cpp
/home/lz/c/main.cpp:1:10: fatal error: QWebSocket: No such file or directory
#include <QWebSocket>
^~~~~~~~~~~~
compilation terminated.