summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLassi Lehikoinen <lassi.lehikoinen@qt.io>2021-01-20 08:39:59 +0200
committerDan Ackers <dan.ackers@qt.io>2021-05-28 10:31:35 +0300
commit72bd22db9f72c4d93774c79cae0760bdc39ce0de (patch)
treef22d4c27be9ec9e3227c551d7652b3476be1d63d
parent1ff0ec46770254328e5ec492cbce1364936eda72 (diff)
Build QDB with CMake
Also some Qt6 related changes. Task-number: QTBUG-86118 Change-Id: Id5bdf646071fcc10415945dfae73b2c66e53f7a7 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
-rw-r--r--.cmake.conf2
-rw-r--r--CMakeLists.txt45
-rw-r--r--cmake/FindlibUsb.cmake47
-rw-r--r--coin/dependencies.yaml2
-rw-r--r--coin/module_config.yaml8
-rw-r--r--coin/product_dependencies.yaml2
-rw-r--r--config.tests/libusb10/libusb10.cpp36
-rw-r--r--config.tests/libusb10/libusb10.pro5
-rw-r--r--libqdb/CMakeLists.txt32
-rw-r--r--libqdb/libqdb.pro33
-rw-r--r--libqdb/protocol/services.h1
-rw-r--r--libusb_setup.pri13
-rw-r--r--qdb.pro24
-rw-r--r--qdb/CMakeLists.txt34
-rw-r--r--qdb/client/client.cpp3
-rw-r--r--qdb/qdb.pro76
-rw-r--r--qdb/server/usb-host/usbdeviceenumerator.cpp2
-rw-r--r--qdbd/CMakeLists.txt23
-rw-r--r--qdbd/qdbd.pro50
-rw-r--r--tests/CMakeLists.txt9
-rw-r--r--tests/qdbmessagetest/CMakeLists.txt10
-rw-r--r--tests/qdbmessagetest/tst_qdbmessage.cpp (renamed from tests/tst_qdbmessage.cpp)0
-rw-r--r--tests/servicetest.pro47
-rw-r--r--tests/servicetest/CMakeLists.txt20
-rw-r--r--tests/servicetest/servicetest.cpp (renamed from tests/servicetest.cpp)0
-rw-r--r--tests/stream/CMakeLists.txt12
-rw-r--r--tests/stream/tst_stream.cpp (renamed from tests/tst_stream.cpp)4
-rw-r--r--tests/streamtest.pro41
-rw-r--r--tests/streamtest/CMakeLists.txt17
-rw-r--r--tests/streamtest/streamtest.cpp (renamed from tests/streamtest.cpp)0
-rw-r--r--tests/subnet/CMakeLists.txt9
-rw-r--r--tests/subnet/tst_subnet.cpp (renamed from tests/tst_subnet.cpp)0
-rw-r--r--tests/tests.pro13
-rw-r--r--tests/tst_qdbmessage.pro21
-rw-r--r--tests/tst_stream.pro28
-rw-r--r--tests/tst_subnet.pro20
-rw-r--r--version.pri1
37 files changed, 275 insertions, 415 deletions
diff --git a/.cmake.conf b/.cmake.conf
new file mode 100644
index 0000000..32a6d92
--- /dev/null
+++ b/.cmake.conf
@@ -0,0 +1,2 @@
+set(QT_REPO_MODULE_VERSION "6.0.0")
+set(QDB_VERSION "1.3.0")
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..7b40adb
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.15.0)
+include(.cmake.conf)
+
+project(QtDebugBridge
+ VERSION "${QT_REPO_MODULE_VERSION}"
+ DESCRIPTION "Qt Debug Bridge Libraries"
+ HOMEPAGE_URL "https://qt.io/"
+ LANGUAGES CXX C
+)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
+
+find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core DBus Network)
+find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS)
+
+find_package(libUsb REQUIRED)
+
+set(CMAKE_AUTOMOC ON)
+
+qt_build_repo_begin()
+
+if (QT_BUILD_TESTS AND NOT QT_BUILD_STANDALONE_TESTS)
+ find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test)
+endif()
+
+if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libqdb/CMakeLists.txt")
+ add_subdirectory(libqdb)
+endif()
+
+if(NOT QT_BUILD_STANDALONE_TESTS)
+ if (DAEMON_ONLY AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/qdbd/CMakeLists.txt")
+ add_subdirectory(qdbd)
+ elseif(NOT DAEMON_ONLY AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/qdb/CMakeLists.txt")
+ add_subdirectory(qdb)
+ endif()
+endif()
+
+if (QT_BUILD_TESTS AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt")
+ add_subdirectory(tests)
+ if(NOT QT_BUILD_TESTS_BY_DEFAULT)
+ set_property(DIRECTORY tests PROPERTY EXCLUDE_FROM_ALL TRUE)
+ endif()
+endif()
+
+qt_build_repo_end()
diff --git a/cmake/FindlibUsb.cmake b/cmake/FindlibUsb.cmake
new file mode 100644
index 0000000..a915a61
--- /dev/null
+++ b/cmake/FindlibUsb.cmake
@@ -0,0 +1,47 @@
+if (MSVC)
+ set(WINDOWS_LIBUSB_PATH "$ENV{LIBUSB_PATH}/VS2019/MS64/static")
+
+ # check if we're using something else than 64bit..
+ if (NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
+ set(WINDOWS_LIBUSB_PATH "$ENV{LIBUSB_PATH}/VS2019/MS32/static")
+ endif()
+endif()
+
+if (MINGW)
+ set(WINDOWS_LIBUSB_PATH "$ENV{LIBUSB_PATH}/MinGW64/static")
+ # check if we're using something else than 64bit..
+ if (NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
+ set(WINDOWS_LIBUSB_PATH "$ENV{LIBUSB_PATH}/MinGW32/static")
+ endif()
+endif()
+
+find_library (LIBUSB_LIBRARY
+ NAMES libusb libusb-1.0 usb-1.0
+ PATHS "/usr/lib" "/usr/local/lib/" "${WINDOWS_LIBUSB_PATH}")
+
+find_path (LIBUSB_INCLUDEDIR
+ NAMES libusb.h libusb-1.0.h
+ PATHS "/usr/local/include/" "$ENV{LIBUSB_PATH}/include/libusb-1.0"
+ PATH_SUFFIXES "include" "libusb" "libusb-1.0")
+
+include(FindPackageHandleStandardArgs)
+
+find_package_handle_standard_args(libUsb DEFAULT_MSG
+ LIBUSB_LIBRARY
+ LIBUSB_INCLUDEDIR)
+
+if (LIBUSB_FOUND AND NOT TARGET libUsb::libUsb)
+ add_library(libUsb::libUsb STATIC IMPORTED)
+ set_target_properties(
+ libUsb::libUsb
+ PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${LIBUSB_INCLUDEDIR}"
+ IMPORTED_LOCATION "${LIBUSB_LIBRARY}")
+ if (MSVC OR MINGW)
+ set_target_properties(
+ libUsb::libUsb
+ PROPERTIES
+ IMPORTED_IMPLIB "${LIBUSB_LIBRARY}"
+ )
+ endif()
+endif()
diff --git a/coin/dependencies.yaml b/coin/dependencies.yaml
index bb16e29..791bbc8 100644
--- a/coin/dependencies.yaml
+++ b/coin/dependencies.yaml
@@ -1,4 +1,4 @@
dependencies:
../../qt/qtbase:
- ref: 3a6d8df5219653b043bd642668cee193f563ec84
+ ref: 516316e9a24fc3a290ce220a9a6cda0af541ca4c
required: true
diff --git a/coin/module_config.yaml b/coin/module_config.yaml
new file mode 100644
index 0000000..4dc430e
--- /dev/null
+++ b/coin/module_config.yaml
@@ -0,0 +1,8 @@
+version: 2
+
+instructions:
+ Build:
+ - !include "{{qt/qtbase}}/coin_module_build_template_v2.yaml"
+
+ Test:
+ - !include "{{qt/qtbase}}/coin_module_test_template_v3.yaml"
diff --git a/coin/product_dependencies.yaml b/coin/product_dependencies.yaml
index 51fbd2d..f2ad3b9 100644
--- a/coin/product_dependencies.yaml
+++ b/coin/product_dependencies.yaml
@@ -1,3 +1,3 @@
dependencies:
../../qt/qt5.git:
- ref: "5.15"
+ ref: "6.1"
diff --git a/config.tests/libusb10/libusb10.cpp b/config.tests/libusb10/libusb10.cpp
deleted file mode 100644
index 53fc2a1..0000000
--- a/config.tests/libusb10/libusb10.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the config tests for Qt Debug Bridge.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <libusb.h>
-
-int main()
-{
- int ret = libusb_init(nullptr);
- libusb_exit(nullptr);
- return ret;
-}
diff --git a/config.tests/libusb10/libusb10.pro b/config.tests/libusb10/libusb10.pro
deleted file mode 100644
index 03315d8..0000000
--- a/config.tests/libusb10/libusb10.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-win32: CONFIG += console
-
-include($$PWD/../../libusb_setup.pri)
-
-SOURCES = libusb10.cpp
diff --git a/libqdb/CMakeLists.txt b/libqdb/CMakeLists.txt
new file mode 100644
index 0000000..7454a2c
--- /dev/null
+++ b/libqdb/CMakeLists.txt
@@ -0,0 +1,32 @@
+qt_internal_add_cmake_library(libqdb
+ INSTALL_DIRECTORY "$$[QT_INSTALL_LIBS]"
+ STATIC
+ SOURCES
+ abstractconnection.cpp abstractconnection.h
+ interruptsignalhandler.h
+ protocol/protocol.h
+ protocol/qdbmessage.cpp protocol/qdbmessage.h
+ protocol/qdbtransport.cpp protocol/qdbtransport.h
+ protocol/services.h
+ stream.cpp stream.h
+ streampacket.cpp streampacket.h
+ INCLUDE_DIRECTORIES
+ ..
+ PUBLIC_LIBRARIES
+ Qt::Core
+)
+
+qt_extend_target(libqdb CONDITION WIN32
+ SOURCES
+ interruptsignalhandler_win.cpp
+)
+
+qt_extend_target(libqdb CONDITION WIN64
+ SOURCES
+ interruptsignalhandler_win.cpp
+)
+
+qt_extend_target(libqdb CONDITION UNIX
+ SOURCES
+ interruptsignalhandler_unix.cpp
+)
diff --git a/libqdb/libqdb.pro b/libqdb/libqdb.pro
deleted file mode 100644
index 042a621..0000000
--- a/libqdb/libqdb.pro
+++ /dev/null
@@ -1,33 +0,0 @@
-QT -= gui
-
-TARGET = qdb
-TEMPLATE = lib
-CONFIG += staticlib
-
-SOURCES += \
- abstractconnection.cpp \
- protocol/qdbmessage.cpp \
- protocol/qdbtransport.cpp \
- stream.cpp \
- streampacket.cpp \
-
-win32 {
- SOURCES += interruptsignalhandler_win.cpp
-} else {
- SOURCES += interruptsignalhandler_unix.cpp
-}
-
-HEADERS += \
- abstractconnection.h \
- interruptsignalhandler.h \
- protocol/protocol.h \
- protocol/qdbmessage.h \
- protocol/qdbtransport.h \
- protocol/services.h \
- stream.h \
- streampacket.h \
-
-target.path = $$[QT_INSTALL_LIBS]
-INSTALLS += target
-
-INCLUDEPATH += $$PWD/..
diff --git a/libqdb/protocol/services.h b/libqdb/protocol/services.h
index 525a8bb..f34ffd9 100644
--- a/libqdb/protocol/services.h
+++ b/libqdb/protocol/services.h
@@ -31,6 +31,7 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qdatastream.h>
+#include <QtCore/qiodevice.h>
#include <cstdint>
diff --git a/libusb_setup.pri b/libusb_setup.pri
deleted file mode 100644
index 7b4f8ed..0000000
--- a/libusb_setup.pri
+++ /dev/null
@@ -1,13 +0,0 @@
-unix {
- CONFIG += link_pkgconfig
- PKGCONFIG += libusb-1.0
-}
-win32 {
- INCLUDEPATH += $$(LIBUSB_PATH)\include\libusb-1.0
- contains(QT_ARCH, x86_64) {
- LIBS += -L$$(LIBUSB_PATH)\MS64\static
- } else {
- LIBS += -L$$(LIBUSB_PATH)\MS32\static
- }
- LIBS += -llibusb-1.0
-}
diff --git a/qdb.pro b/qdb.pro
deleted file mode 100644
index 0ab7fbe..0000000
--- a/qdb.pro
+++ /dev/null
@@ -1,24 +0,0 @@
-load(configure)
-!daemon_only:!qtCompileTest(libusb10): error("Could not find libusb-1.0, which is mandatory for host parts of QDB")
-
-load(qt_parts)
-
-CONFIG -= qt_example_installs
-
-SUBDIRS += libqdb
-sub_tests.depends += libqdb
-
-!daemon_only {
- SUBDIRS += qdb
-
- qdb.depends += libqdb
- # Tests share files with qdb and parallel compilation in that case may lead to error C1083
- # with MSVC. Avoid that by building tests after the main project.
- sub_tests.depends += qdb
-}
-
-linux {
- SUBDIRS += qdbd
-
- qdbd.depends += libqdb
-}
diff --git a/qdb/CMakeLists.txt b/qdb/CMakeLists.txt
new file mode 100644
index 0000000..56ae9c8
--- /dev/null
+++ b/qdb/CMakeLists.txt
@@ -0,0 +1,34 @@
+qt_internal_add_executable(qdb
+ SOURCES
+ client/client.cpp client/client.h
+ hostmessages.cpp hostmessages.h
+ main.cpp
+ server/connection.cpp server/connection.h
+ server/connectionpool.cpp server/connectionpool.h
+ server/deviceinformationfetcher.cpp server/deviceinformationfetcher.h
+ server/devicemanager.cpp server/devicemanager.h
+ server/echoservice.cpp server/echoservice.h
+ server/handshakeservice.cpp server/handshakeservice.h
+ server/hostserver.cpp server/hostserver.h
+ server/hostservlet.cpp server/hostservlet.h
+ server/logging.cpp server/logging.h
+ server/networkconfigurationservice.cpp server/networkconfigurationservice.h
+ server/networkconfigurator.cpp server/networkconfigurator.h
+ server/service.cpp server/service.h
+ server/subnet.cpp server/subnet.h
+ server/usb-host/libusbcontext.cpp
+ server/usb-host/usbcommon.h
+ server/usb-host/usbconnection.cpp server/usb-host/usbconnection.h
+ server/usb-host/usbconnectionreader.cpp server/usb-host/usbconnectionreader.h
+ server/usb-host/usbdevice.cpp server/usb-host/usbdevice.h
+ server/usb-host/usbdeviceenumerator.cpp server/usb-host/usbdeviceenumerator.h
+ DEFINES
+ QDB_VERSION="${QDB_VERSION}"
+ INCLUDE_DIRECTORIES
+ ${PROJECT_SOURCE_DIR}
+ PUBLIC_LIBRARIES
+ Qt::DBus
+ Qt::Network
+ libqdb
+ libUsb::libUsb
+)
diff --git a/qdb/client/client.cpp b/qdb/client/client.cpp
index 556043a..fc345c1 100644
--- a/qdb/client/client.cpp
+++ b/qdb/client/client.cpp
@@ -238,8 +238,7 @@ void Client::setupSocketAndConnect(Client::ConnectedSlot handleConnection, Clien
{
m_socket = make_unique<QLocalSocket>();
connect(m_socket.get(), &QLocalSocket::connected, this, handleConnection);
- connect(m_socket.get(), QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error),
- this, handleError);
+ connect(m_socket.get(), &QLocalSocket::errorOccurred, this, handleError);
m_socket->connectToServer(qdbSocketName);
}
diff --git a/qdb/qdb.pro b/qdb/qdb.pro
deleted file mode 100644
index 14b674b..0000000
--- a/qdb/qdb.pro
+++ /dev/null
@@ -1,76 +0,0 @@
-QT -= gui
-QT += dbus network
-
-CONFIG += c++11
-
-TARGET = qdb
-win32: CONFIG += console
-CONFIG -= app_bundle
-
-TEMPLATE = app
-
-include($$PWD/../libusb_setup.pri)
-include($$PWD/../version.pri)
-
-HEADERS += \
- client/client.h \
- hostmessages.h \
- server/connection.h \
- server/connectionpool.h \
- server/deviceinformationfetcher.h \
- server/devicemanager.h \
- server/echoservice.h \
- server/handshakeservice.h \
- server/hostserver.h \
- server/hostservlet.h \
- server/logging.h \
- server/networkconfigurationservice.h \
- server/networkconfigurator.h \
- server/service.h \
- server/subnet.h \
- server/usb-host/usbcommon.h \
- server/usb-host/usbconnection.h \
- server/usb-host/usbconnectionreader.h \
- server/usb-host/usbdeviceenumerator.h \
- server/usb-host/usbdevice.h \
-
-SOURCES += \
- client/client.cpp \
- hostmessages.cpp \
- main.cpp \
- server/connection.cpp \
- server/connectionpool.cpp \
- server/deviceinformationfetcher.cpp \
- server/devicemanager.cpp \
- server/echoservice.cpp \
- server/handshakeservice.cpp \
- server/hostserver.cpp \
- server/hostservlet.cpp \
- server/logging.cpp \
- server/networkconfigurationservice.cpp \
- server/networkconfigurator.cpp \
- server/service.cpp \
- server/subnet.cpp \
- server/usb-host/libusbcontext.cpp \
- server/usb-host/usbconnection.cpp \
- server/usb-host/usbconnectionreader.cpp \
- server/usb-host/usbdevice.cpp \
- server/usb-host/usbdeviceenumerator.cpp \
-
-INCLUDEPATH += $$PWD/../
-
-target.path = $$[QT_INSTALL_BINS]
-INSTALLS += target
-
-unix {
- LIBS += -L$$OUT_PWD/../libqdb -lqdb
-}
-
-win32 {
- CONFIG(debug, debug|release) {
- LIBS += -L$$OUT_PWD/../libqdb/debug
- } else {
- LIBS += -L$$OUT_PWD/../libqdb/release
- }
- LIBS += -lqdb
-}
diff --git a/qdb/server/usb-host/usbdeviceenumerator.cpp b/qdb/server/usb-host/usbdeviceenumerator.cpp
index e49c87e..25dee2a 100644
--- a/qdb/server/usb-host/usbdeviceenumerator.cpp
+++ b/qdb/server/usb-host/usbdeviceenumerator.cpp
@@ -108,7 +108,7 @@ QString getSerialNumber(libusb_device *device, libusb_device_handle *handle)
}
// length is the length in bytes and UTF-16 characters consist of two bytes
Q_ASSERT(length % 2 == 0);
- serial = QString::fromUtf16(reinterpret_cast<unsigned short*>(buffer), length / 2);
+ serial = QString::fromUtf16(reinterpret_cast<char16_t*>(buffer), length / 2);
// Strip non-ASCII characters
serial = QString::fromLatin1(serial.toLatin1());
serial.remove(QChar{'?'});
diff --git a/qdbd/CMakeLists.txt b/qdbd/CMakeLists.txt
new file mode 100644
index 0000000..f4b06b1
--- /dev/null
+++ b/qdbd/CMakeLists.txt
@@ -0,0 +1,23 @@
+qt_internal_add_executable(qdbd
+ SOURCES
+ configuration.cpp configuration.h
+ createexecutor.cpp createexecutor.h
+ echoexecutor.cpp echoexecutor.h
+ executor.cpp executor.h
+ handshakeexecutor.cpp handshakeexecutor.h
+ main.cpp
+ networkconfiguration.cpp networkconfiguration.h
+ networkconfigurationexecutor.cpp networkconfigurationexecutor.h
+ server.cpp server.h
+ usb-gadget/usbgadget.cpp usb-gadget/usbgadget.h
+ usb-gadget/usbgadgetcontrol.cpp usb-gadget/usbgadgetcontrol.h
+ usb-gadget/usbgadgetreader.cpp usb-gadget/usbgadgetreader.h
+ usb-gadget/usbgadgetwriter.cpp usb-gadget/usbgadgetwriter.h
+ DEFINES
+ QDB_VERSION="${QDB_VERSION}"
+ INCLUDE_DIRECTORIES
+ ${PROJECT_SOURCE_DIR}
+ PUBLIC_LIBRARIES
+ Qt::Network
+ libqdb
+)
diff --git a/qdbd/qdbd.pro b/qdbd/qdbd.pro
deleted file mode 100644
index 1254d04..0000000
--- a/qdbd/qdbd.pro
+++ /dev/null
@@ -1,50 +0,0 @@
-QT += core network
-QT -= gui
-
-CONFIG += c++11
-
-TARGET = qdbd
-CONFIG += console
-CONFIG -= app_bundle
-
-TEMPLATE = app
-
-include($$PWD/../version.pri)
-
-SOURCES += \
- configuration.cpp \
- createexecutor.cpp \
- echoexecutor.cpp \
- executor.cpp \
- handshakeexecutor.cpp \
- main.cpp \
- networkconfiguration.cpp \
- networkconfigurationexecutor.cpp \
- server.cpp \
- usb-gadget/usbgadget.cpp \
- usb-gadget/usbgadgetcontrol.cpp \
- usb-gadget/usbgadgetreader.cpp \
- usb-gadget/usbgadgetwriter.cpp \
-
-HEADERS += \
- configuration.h \
- createexecutor.h \
- echoexecutor.h \
- executor.h \
- handshakeexecutor.h \
- networkconfigurationexecutor.h \
- networkconfiguration.h \
- server.h \
- usb-gadget/usbgadget.h \
- usb-gadget/usbgadgetcontrol.h \
- usb-gadget/usbgadgetreader.h \
- usb-gadget/usbgadgetwriter.h \
-
-INCLUDEPATH += $$PWD/../
-
-LIBS += -L$$OUT_PWD/../libqdb -lqdb
-
-unix {
- target.path = $$[QT_INSTALL_BINS]
- INSTALLS += target
-}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 0000000..d250aea
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,9 @@
+find_package(Qt6 COMPONENTS Test REQUIRED)
+
+add_subdirectory(qdbmessagetest)
+add_subdirectory(stream)
+add_subdirectory(subnet)
+add_subdirectory(servicetest)
+add_subdirectory(streamtest)
+
+qt_build_tests()
diff --git a/tests/qdbmessagetest/CMakeLists.txt b/tests/qdbmessagetest/CMakeLists.txt
new file mode 100644
index 0000000..27f609b
--- /dev/null
+++ b/tests/qdbmessagetest/CMakeLists.txt
@@ -0,0 +1,10 @@
+qt_internal_add_test(tst_qdbmessage
+ SOURCES
+ ../../libqdb/protocol/protocol.h
+ ../../libqdb/protocol/qdbmessage.cpp ../../libqdb/protocol/qdbmessage.h
+ tst_qdbmessage.cpp
+ INCLUDE_DIRECTORIES
+ ..
+ PUBLIC_LIBRARIES
+ Qt::Test
+)
diff --git a/tests/tst_qdbmessage.cpp b/tests/qdbmessagetest/tst_qdbmessage.cpp
index 148d91d..148d91d 100644
--- a/tests/tst_qdbmessage.cpp
+++ b/tests/qdbmessagetest/tst_qdbmessage.cpp
diff --git a/tests/servicetest.pro b/tests/servicetest.pro
deleted file mode 100644
index ef8f047..0000000
--- a/tests/servicetest.pro
+++ /dev/null
@@ -1,47 +0,0 @@
-QT -= gui
-QT += testlib
-
-win32: CONFIG += console
-CONFIG -= app_bundle
-
-TEMPLATE = app
-
-include($$PWD/../libusb_setup.pri)
-
-HEADERS += \
- ../qdb/server/connection.h \
- ../qdb/server/echoservice.h \
- ../qdb/server/service.h \
- ../qdb/server/usb-host/usbcommon.h \
- ../qdb/server/usb-host/usbconnection.h \
- ../qdb/server/usb-host/usbconnectionreader.h \
- ../qdb/server/usb-host/usbdevice.h \
- ../qdb/server/usb-host/usbdeviceenumerator.h \
-
-SOURCES += \
- ../qdb/server/connection.cpp \
- ../qdb/server/echoservice.cpp \
- ../qdb/server/service.cpp \
- ../qdb/server/usb-host/libusbcontext.cpp \
- ../qdb/server/usb-host/usbconnection.cpp \
- ../qdb/server/usb-host/usbconnectionreader.cpp \
- ../qdb/server/usb-host/usbdevice.cpp \
- ../qdb/server/usb-host/usbdeviceenumerator.cpp \
- servicetest.cpp \
-
-INCLUDEPATH += $$PWD/../
-
-LIBS += -L$$[QT_INSTALL_LIBS]
-
-unix {
- LIBS += -L$$OUT_PWD/../libqdb -lqdb
-}
-
-win32 {
- CONFIG(debug, debug|release) {
- LIBS += -L$$OUT_PWD/../libqdb/debug
- } else {
- LIBS += -L$$OUT_PWD/../libqdb/release
- }
- LIBS += -lqdb
-}
diff --git a/tests/servicetest/CMakeLists.txt b/tests/servicetest/CMakeLists.txt
new file mode 100644
index 0000000..f9a391c
--- /dev/null
+++ b/tests/servicetest/CMakeLists.txt
@@ -0,0 +1,20 @@
+qt_internal_add_executable(servicetest
+ SOURCES
+ ../../qdb/server/connection.cpp ../../qdb/server/connection.h
+ ../../qdb/server/echoservice.cpp ../../qdb/server/echoservice.h
+ ../../qdb/server/service.cpp ../../qdb/server/service.h
+ ../../qdb/server/usb-host/libusbcontext.cpp
+ ../../qdb/server/usb-host/usbcommon.h
+ ../../qdb/server/usb-host/usbconnection.cpp ../../qdb/server/usb-host/usbconnection.h
+ ../../qdb/server/usb-host/usbconnectionreader.cpp ../../qdb/server/usb-host/usbconnectionreader.h
+ ../../qdb/server/usb-host/usbdevice.cpp ../../qdb/server/usb-host/usbdevice.h
+ ../../qdb/server/usb-host/usbdeviceenumerator.cpp ../../qdb/server/usb-host/usbdeviceenumerator.h
+ servicetest.cpp
+ INCLUDE_DIRECTORIES
+ ${LIBUSB_INCLUDE_DIR}
+ ../../
+ PUBLIC_LIBRARIES
+ Qt::Test
+ libUsb::libUsb
+ libqdb
+)
diff --git a/tests/servicetest.cpp b/tests/servicetest/servicetest.cpp
index 947d395..947d395 100644
--- a/tests/servicetest.cpp
+++ b/tests/servicetest/servicetest.cpp
diff --git a/tests/stream/CMakeLists.txt b/tests/stream/CMakeLists.txt
new file mode 100644
index 0000000..a7d8b5d
--- /dev/null
+++ b/tests/stream/CMakeLists.txt
@@ -0,0 +1,12 @@
+qt_internal_add_test(tst_stream
+ SOURCES
+ ../../libqdb/abstractconnection.cpp ../../libqdb/abstractconnection.h
+ ../../libqdb/protocol/protocol.h
+ ../../libqdb/protocol/qdbmessage.cpp ../../libqdb/protocol/qdbmessage.h
+ ../../libqdb/protocol/qdbtransport.cpp ../../libqdb/protocol/qdbtransport.h
+ ../../libqdb/stream.cpp ../../libqdb/stream.h
+ ../../libqdb/streampacket.cpp ../../libqdb/streampacket.h
+ tst_stream.cpp
+ INCLUDE_DIRECTORIES
+ ../../
+)
diff --git a/tests/tst_stream.cpp b/tests/stream/tst_stream.cpp
index 2fbef39..f9d6b68 100644
--- a/tests/tst_stream.cpp
+++ b/tests/stream/tst_stream.cpp
@@ -119,7 +119,7 @@ void tst_Stream::singleMessagePacket()
QByteArray{"\x00\x00\x00\x02OK", 6}});
QCOMPARE(spy.count(), 1);
- QCOMPARE(static_cast<int>(spy[0][0].type()), QMetaType::type("StreamPacket"));
+ QCOMPARE(spy[0][0].metaType().id(), QMetaType::fromType<StreamPacket>().id());
auto packet = spy[0][0].value<StreamPacket>();
QCOMPARE(packet.buffer(), QByteArray{"OK"});
}
@@ -135,7 +135,7 @@ void tst_Stream::splitPacket()
QByteArray{"DE"}});
QCOMPARE(spy.count(), 1);
- QCOMPARE(static_cast<int>(spy[0][0].type()), QMetaType::type("StreamPacket"));
+ QCOMPARE(spy[0][0].metaType().id(), QMetaType::fromType<StreamPacket>().id());
auto packet = spy[0][0].value<StreamPacket>();
QCOMPARE(packet.buffer(), QByteArray{"ABCDE"});
}
diff --git a/tests/streamtest.pro b/tests/streamtest.pro
deleted file mode 100644
index d7ee0fd..0000000
--- a/tests/streamtest.pro
+++ /dev/null
@@ -1,41 +0,0 @@
-QT -= gui
-QT += testlib
-
-win32: CONFIG += console
-CONFIG -= app_bundle
-
-TEMPLATE = app
-
-include($$PWD/../libusb_setup.pri)
-
-HEADERS += \
- ../qdb/server/usb-host/usbcommon.h \
- ../qdb/server/usb-host/usbconnection.h \
- ../qdb/server/usb-host/usbconnectionreader.h \
- ../qdb/server/usb-host/usbdevice.h \
- ../qdb/server/usb-host/usbdeviceenumerator.h \
-
-SOURCES += \
- ../qdb/server/usb-host/libusbcontext.cpp \
- ../qdb/server/usb-host/usbconnection.cpp \
- ../qdb/server/usb-host/usbconnectionreader.cpp \
- ../qdb/server/usb-host/usbdevice.cpp \
- ../qdb/server/usb-host/usbdeviceenumerator.cpp \
- streamtest.cpp \
-
-INCLUDEPATH += $$PWD/../
-
-LIBS += -L$$[QT_INSTALL_LIBS]
-
-unix {
- LIBS += -L$$OUT_PWD/../libqdb -lqdb
-}
-
-win32 {
- CONFIG(debug, debug|release) {
- LIBS += -L$$OUT_PWD/../libqdb/debug
- } else {
- LIBS += -L$$OUT_PWD/../libqdb/release
- }
- LIBS += -lqdb
-}
diff --git a/tests/streamtest/CMakeLists.txt b/tests/streamtest/CMakeLists.txt
new file mode 100644
index 0000000..804f175
--- /dev/null
+++ b/tests/streamtest/CMakeLists.txt
@@ -0,0 +1,17 @@
+qt_internal_add_executable(streamtest
+ SOURCES
+ ../../qdb/server/usb-host/libusbcontext.cpp
+ ../../qdb/server/usb-host/usbcommon.h
+ ../../qdb/server/usb-host/usbconnection.cpp ../../qdb/server/usb-host/usbconnection.h
+ ../../qdb/server/usb-host/usbconnectionreader.cpp ../../qdb/server/usb-host/usbconnectionreader.h
+ ../../qdb/server/usb-host/usbdevice.cpp ../../qdb/server/usb-host/usbdevice.h
+ ../../qdb/server/usb-host/usbdeviceenumerator.cpp ../../qdb/server/usb-host/usbdeviceenumerator.h
+ streamtest.cpp
+ INCLUDE_DIRECTORIES
+ ${LIBUSB_INCLUDE_DIR}
+ ../../
+ PUBLIC_LIBRARIES
+ Qt::Test
+ libqdb
+ libUsb::libUsb
+)
diff --git a/tests/streamtest.cpp b/tests/streamtest/streamtest.cpp
index 6edcc03..6edcc03 100644
--- a/tests/streamtest.cpp
+++ b/tests/streamtest/streamtest.cpp
diff --git a/tests/subnet/CMakeLists.txt b/tests/subnet/CMakeLists.txt
new file mode 100644
index 0000000..7bdd1be
--- /dev/null
+++ b/tests/subnet/CMakeLists.txt
@@ -0,0 +1,9 @@
+qt_internal_add_test(tst_subnet
+ SOURCES
+ ../../qdb/server/subnet.cpp ../../qdb/server/subnet.h
+ tst_subnet.cpp
+ INCLUDE_DIRECTORIES
+ ..
+ PUBLIC_LIBRARIES
+ Qt::Network
+)
diff --git a/tests/tst_subnet.cpp b/tests/subnet/tst_subnet.cpp
index bf0a6e1..bf0a6e1 100644
--- a/tests/tst_subnet.cpp
+++ b/tests/subnet/tst_subnet.cpp
diff --git a/tests/tests.pro b/tests/tests.pro
deleted file mode 100644
index 7de79f3..0000000
--- a/tests/tests.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = subdirs
-CONFIG += ordered
-
-SUBDIRS = \
- tst_qdbmessage.pro \
- tst_stream.pro \
- tst_subnet.pro \
-
-config_libusb10 {
- SUBDIRS += \
- servicetest.pro \
- streamtest.pro
-}
diff --git a/tests/tst_qdbmessage.pro b/tests/tst_qdbmessage.pro
deleted file mode 100644
index 735ba96..0000000
--- a/tests/tst_qdbmessage.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-QT -= gui
-QT += testlib
-
-CONFIG += c++11
-CONFIG += testcase
-
-TARGET = tst_qdbmessage
-CONFIG += console
-CONFIG -= app_bundle
-
-TEMPLATE = app
-
-HEADERS += \
- ../libqdb/protocol/protocol.h \
- ../libqdb/protocol/qdbmessage.h
-
-SOURCES += \
- tst_qdbmessage.cpp \
- ../libqdb/protocol/qdbmessage.cpp
-
-INCLUDEPATH += $$PWD/..
diff --git a/tests/tst_stream.pro b/tests/tst_stream.pro
deleted file mode 100644
index f9bcb39..0000000
--- a/tests/tst_stream.pro
+++ /dev/null
@@ -1,28 +0,0 @@
-QT -= gui
-QT += testlib
-
-CONFIG += c++11
-CONFIG += testcase
-
-CONFIG += console
-CONFIG -= app_bundle
-
-TEMPLATE = app
-
-HEADERS += \
- ../libqdb/abstractconnection.h \
- ../libqdb/stream.h \
- ../libqdb/streampacket.h \
- ../libqdb/protocol/protocol.h \
- ../libqdb/protocol/qdbmessage.h \
- ../libqdb/protocol/qdbtransport.h \
-
-SOURCES += \
- ../libqdb/abstractconnection.cpp \
- ../libqdb/stream.cpp \
- ../libqdb/streampacket.cpp \
- ../libqdb/protocol/qdbmessage.cpp \
- ../libqdb/protocol/qdbtransport.cpp \
- tst_stream.cpp \
-
-INCLUDEPATH += $$PWD/../
diff --git a/tests/tst_subnet.pro b/tests/tst_subnet.pro
deleted file mode 100644
index 9a5a1bc..0000000
--- a/tests/tst_subnet.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-QT -= gui
-QT += network testlib
-
-CONFIG += c++11
-CONFIG += testcase
-
-TARGET = tst_subnet
-CONFIG += console
-CONFIG -= app_bundle
-
-TEMPLATE = app
-
-INCLUDEPATH += $$PWD/../
-
-HEADERS += \
- ../qdb/server/subnet.h \
-
-SOURCES += \
- ../qdb/server/subnet.cpp \
- tst_subnet.cpp \
diff --git a/version.pri b/version.pri
deleted file mode 100644
index bd869d3..0000000
--- a/version.pri
+++ /dev/null
@@ -1 +0,0 @@
-DEFINES += QDB_VERSION=\\\"1.2.1\\\"