适配Linux。

This commit is contained in:
luocai 2024-12-16 15:34:40 +08:00
parent fd494f2a03
commit 798962e8bb
3 changed files with 28 additions and 7 deletions

View File

@ -6,7 +6,12 @@ set(APPLICATION_NAME "视觉防夹设备上位机工具")
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(Libraries_ROOT E:/Projects/Libraries CACHE STRING "Libraries directory.") if(LINUX)
set(Libraries_ROOT /opt/Libraries CACHE STRING "Libraries directory.")
else()
set(Libraries_ROOT E:/Projects/Libraries CACHE STRING "Libraries directory.")
endif()
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Qml Quick Network QuickControls2) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Qml Quick Network QuickControls2)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Qml Quick Network QuickControls2) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Qml Quick Network QuickControls2)
@ -24,7 +29,11 @@ else()
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>") add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
set(BOOST_ROOT ${Libraries_ROOT}/boost_1_83_0_msvc2022_64bit) if(LINUX)
set(BOOST_ROOT ${Libraries_ROOT}/boost_1_83_0)
else()
set(BOOST_ROOT ${Libraries_ROOT}/boost_1_83_0_msvc2022_64bit)
endif()
set(Boost_INCLUDE_DIR ${BOOST_ROOT}/include/boost-1_83) set(Boost_INCLUDE_DIR ${BOOST_ROOT}/include/boost-1_83)
set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-6.1.1-full_build-shared) set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-6.1.1-full_build-shared)
endif() endif()
@ -39,8 +48,13 @@ set(FFmpeg_INCLUDE_DIR ${FFmpeg_ROOT}/include)
set(FFmpeg_LIB_DIR ${FFmpeg_ROOT}/lib) set(FFmpeg_LIB_DIR ${FFmpeg_ROOT}/lib)
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(JPEGTURBO_ROOT ${Libraries_ROOT}/libjpeg-turbo-3.0.3_msvc2022_64bit_debug) if(LINUX)
set(MBEDTLS_ROOT ${Libraries_ROOT}/mbedtls-3.6.2_msvc2022_64bit_debug) set(MBEDTLS_ROOT ${Libraries_ROOT}/mbedtls-3.6.2)
set(JPEGTURBO_ROOT ${Libraries_ROOT}/libjpeg-turbo-3.1.0)
else()
set(MBEDTLS_ROOT ${Libraries_ROOT}/mbedtls-3.6.2_msvc2022_64bit_debug)
set(JPEGTURBO_ROOT ${Libraries_ROOT}/libjpeg-turbo-3.0.3_msvc2022_64bit_debug)
endif()
else() else()
set(JPEGTURBO_ROOT ${Libraries_ROOT}/libjpeg-turbo-3.0.3_msvc2022_64bit_release) set(JPEGTURBO_ROOT ${Libraries_ROOT}/libjpeg-turbo-3.0.3_msvc2022_64bit_release)
set(MBEDTLS_ROOT ${Libraries_ROOT}/mbedtls-3.6.2_msvc2022_64bit_release) set(MBEDTLS_ROOT ${Libraries_ROOT}/mbedtls-3.6.2_msvc2022_64bit_release)
@ -137,8 +151,9 @@ target_link_libraries(AntiClipSettings
PRIVATE avformat PRIVATE avformat
PRIVATE Universal PRIVATE Universal
PRIVATE Encrypt PRIVATE Encrypt
PRIVATE turbojpeg-static $<$<PLATFORM_ID:Linux>:turbojpeg>
PRIVATE Ws2_32 $<$<PLATFORM_ID:Windows>:turbojpeg-static>
$<$<PLATFORM_ID:Windows>:Ws2_32>
) )
include(GNUInstallDirs) include(GNUInstallDirs)

View File

@ -5,13 +5,17 @@
#include <QPointF> #include <QPointF>
#include <QTimer> #include <QTimer>
#include <QTimerEvent> #include <QTimerEvent>
#include <WinSock2.h>
#include <boost/json/object.hpp> #include <boost/json/object.hpp>
#include <boost/json/parse.hpp> #include <boost/json/parse.hpp>
#include <boost/json/serialize.hpp> #include <boost/json/serialize.hpp>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <mbedtls/md5.h> #include <mbedtls/md5.h>
#ifdef Q_OS_LINUX
#include <arpa/inet.h>
#else
#include <WinSock2.h>
#endif
DeviceConnection::DeviceConnection(QObject *parent) : QObject{parent} { DeviceConnection::DeviceConnection(QObject *parent) : QObject{parent} {
} }

View File

@ -9,8 +9,10 @@
#include <QTcpSocket> #include <QTcpSocket>
#include <queue> #include <queue>
#include <string_view> #include <string_view>
#include <QPointF>
class NetworkInfomation; class NetworkInfomation;
class QTimer;
class DeviceConnection : public QObject { class DeviceConnection : public QObject {
Q_OBJECT Q_OBJECT