cmake_minimum_required(VERSION 3.16) project(pc_system LANGUAGES CXX) # 启用 Qt 的自动 UI、MOC 和资源处理 set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) # 设置 C++ 标准 set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) # # 设置 OpenSSL 安装路径 set(OPENSSL_ROOT_DIR "D:/qt/Tools/OpenSSLv3/Win_x64") # 查找 OpenSSL 库 find_package(OpenSSL REQUIRED) if(OpenSSL_FOUND) message(STATUS "OpenSSL found: ${OpenSSL_VERSION}") else() message(FATAL_ERROR "OpenSSL not found. Please install OpenSSL development libraries.") endif() find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets Mqtt Sql Network WebEngineWidgets SerialPort) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Mqtt Sql Network WebEngineWidgets SerialPort) # 添加 Widgets # 定义源文件列表 set(SOURCES PageWidget.cpp blastoperationfactory.cpp blastopepage.cpp addressfactory.cpp addresspage.cpp blastProject/blastprojectfactory.cpp blastProject/blastprojectpage.cpp blastProject/projectdialog.cpp blastProject/hproject.cpp blastProject/hprojectdao.cpp buttondelegate.cpp databasemanager.cpp detInfo/detinfofactory.cpp detInfo/detinfopage.cpp detInfo/detdialog.cpp equipment/equipmentfactory.cpp equipment/equipmentpage.cpp global.cpp httpclient.cpp jobs.cpp login/loginwindow.cpp main.cpp mainwindow.cpp registryManager/registrymanager.cpp mqtt/mqttclient.cpp blastRecord/blastrecordfactory.cpp blastRecord/blastrecord.cpp blastRecord/hblastrecord.cpp blastRecord/hblastrecorddao.cpp blastRecordDet/hblastrecorddet.cpp blastRecordDet/hblastrecorddetdao.cpp blastRegRecord/hblastregrecord.cpp blastRegRecord/hblastregrecorddao.cpp fireWidget/firingwidget.cpp fireWidget/navprogress.cpp ) # 定义头文件列表 set(HEADERS PageWidget.h blastoperationfactory.h blastopepage.h addressfactory.h addresspage.h blastProject/blastprojectfactory.h blastProject/blastprojectpage.h blastProject/hproject.h blastProject/hprojectdao.h blastProject/projectdialog.h buttondelegate.h databasemanager.h detInfo/detinfofactory.h detInfo/detinfopage.h detInfo/detdialog.h equipment/equipmentfactory.h equipment/equipmentpage.h global.h httpclient.h jobs.h login/loginwindow.h mainwindow.h registryManager/registrymanager.h mqtt/mqttclient.h regex.h blastRecord/blastrecordfactory.h blastRecord/blastrecord.h blastRecord/hblastrecord.h blastRecord/hblastrecorddao.h blastRecordDet/hblastrecorddet.h blastRecordDet/hblastrecorddetdao.h blastRegRecord/hblastregrecord.h blastRegRecord/hblastregrecorddao.h fireWidget/firingwidget.h fireWidget/navprogress.h ) # 定义 UI 文件列表 set(FORMS PageWidget.ui addresspage.ui blastProject/blastprojectpage.ui detInfo/detinfopage.ui detInfo/detdialog.ui equipment/equipmentpage.ui login/loginwindow.ui mainwindow.ui blastProject/projectdialog.ui blastopepage.ui blastRecord/blastrecord.ui fireWidget/firingwidget.ui ) # 定义资源文件列表 set(RESOURCES media.qrc ) # 添加可执行文件 add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS} ${FORMS} ${RESOURCES} des3encryption.h des3encryption.cpp countdownwidget.h countdownwidget.cpp mqttthread.cpp mqttthread.h serial/serialtool.h serial/serialtool.cpp serial/serialgps.h serial/serialgps.cpp paregnrmc.cpp paregnrmc.h serialgpsthread.h serialgpsthread.cpp worker/timeupdatethread.h worker/timeupdatethread.cpp logo.rc loadingdialog.h loadingdialog.cpp ) target_link_libraries(pc_system Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Sql Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Mqtt Qt${QT_VERSION_MAJOR}::WebEngineWidgets OpenSSL::Crypto OpenSSL::SSL Qt${QT_VERSION_MAJOR}::SerialPort) include(GNUInstallDirs) install(TARGETS pc_system LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )