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) set(CMAKE_PREFIX_PATH "C:/Qt/6.9.0/msvc2022_64") # # 设置 OpenSSL 安装路径 set(OPENSSL_ROOT_DIR "C:/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 Charts) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Mqtt Sql Network WebEngineWidgets SerialPort Charts) # 添加 Widgets # 定义源文件列表 set(SOURCES PageWidget.cpp blastJob/blastoperationfactory.cpp blastJob/blastopepage.cpp address/addressfactory.cpp address/addresspage.cpp pagefactory.cpp components/MultiSelectComboBox.cpp blastProject/blastprojectfactory.cpp blastProject/blastprojectpage.cpp blastProject/projectdialog.cpp blastProject/hproject.cpp blastProject/hprojectdao.cpp components/buttondelegate.cpp utils/databasemanager.cpp detInfo/detinfofactory.cpp detInfo/detinfopage.cpp detInfo/detdialog.cpp equipment/equipmentfactory.cpp equipment/equipmentpage.cpp utils/global.cpp utils/httpclient.cpp utils/logger.cpp login/loginwindow.cpp main.cpp mainwindow/mainwindow.cpp utils/jobs.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 blastJob/countdownwidget.cpp serial/serialtool.cpp serial/serialgps.cpp serial/serialgpsthread.cpp serial/paregnrmc.cpp worker/timeupdatethread.cpp components/loadingWidget.cpp utils/backendapimanager.cpp homepage/homepage.cpp homepage/homepagefactory.cpp ) # 定义头文件列表 set(HEADERS PageWidget.h blastJob/blastoperationfactory.h blastJob/blastopepage.h address/addressfactory.h address/addresspage.h pagefactory.h components/MultiSelectComboBox.h blastProject/blastprojectfactory.h blastProject/blastprojectpage.h blastProject/hproject.h blastProject/hprojectdao.h blastProject/projectdialog.h components/components/ utils/databasemanager.h detInfo/detinfofactory.h detInfo/detinfopage.h detInfo/detdialog.h equipment/equipmentfactory.h equipment/equipmentpage.h utils/global.h utils/httpclient.h utils/logger.h login/loginwindow.h mainwindow/mainwindow.h utils/jobs.h registryManager/registrymanager.h mqtt/mqttclient.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 blastJob/countdownwidget.h serial/serialtool.h serial/serialgps.h serial/serialgpsthread.h serial/paregnrmc.h homepage/homepage.h worker/timeupdatethread.h components/loadingWidget.h utils/backendapimanager.h ) # 定义 UI 文件列表 set(FORMS homepage/homepage.ui PageWidget.ui address/addresspage.ui blastProject/blastprojectpage.ui detInfo/detinfopage.ui detInfo/detdialog.ui equipment/equipmentpage.ui login/loginwindow.ui mainwindow/mainwindow.ui blastProject/projectdialog.ui blastJob/blastopepage.ui blastRecord/blastrecord.ui fireWidget/firingwidget.ui ) # 定义资源文件列表 set(RESOURCES media.qrc ) # 添加可执行文件 add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS} ${FORMS} ${RESOURCES} logo.rc ) # 创建测试可执行文件 add_executable(test_database tests/test_database.cpp utils/databasemanager.cpp utils/logger.cpp ) # 链接测试可执行文件的库 target_link_libraries(test_database Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Sql ${OPENSSL_LIBRARIES} ) # 设置测试可执行文件的输出目录 set_target_properties(test_database PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE FALSE ) 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}::Charts 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} )