CMakeLists.txt 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. cmake_minimum_required(VERSION 3.16)
  2. project(pc_system LANGUAGES CXX)
  3. # 启用 Qt 的自动 UI、MOC 和资源处理
  4. set(CMAKE_AUTOUIC ON)
  5. set(CMAKE_AUTOMOC ON)
  6. set(CMAKE_AUTORCC ON)
  7. # 设置 C++ 标准
  8. set(CMAKE_CXX_STANDARD 17)
  9. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  10. set(CMAKE_PREFIX_PATH "C:/Qt/6.9.0/msvc2022_64")
  11. # # 设置 OpenSSL 安装路径
  12. set(OPENSSL_ROOT_DIR "C:/Qt/Tools/OpenSSLv3/Win_x64")
  13. # 查找 OpenSSL 库
  14. find_package(OpenSSL REQUIRED)
  15. if(OpenSSL_FOUND)
  16. message(STATUS "OpenSSL found: ${OpenSSL_VERSION}")
  17. else()
  18. message(FATAL_ERROR "OpenSSL not found. Please install OpenSSL development libraries.")
  19. endif()
  20. find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets Mqtt Sql Network WebEngineWidgets SerialPort Charts)
  21. find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Mqtt Sql Network WebEngineWidgets SerialPort Charts) # 添加 Widgets
  22. # 定义源文件列表
  23. set(SOURCES
  24. PageWidget.cpp
  25. blastoperationfactory.cpp
  26. blastopepage.cpp
  27. addressfactory.cpp
  28. addresspage.cpp
  29. pagefactory.cpp
  30. components/MultiSelectComboBox.cpp
  31. blastProject/blastprojectfactory.cpp
  32. blastProject/blastprojectpage.cpp
  33. blastProject/projectdialog.cpp
  34. blastProject/hproject.cpp
  35. blastProject/hprojectdao.cpp
  36. buttondelegate.cpp
  37. databasemanager.cpp
  38. detInfo/detinfofactory.cpp
  39. detInfo/detinfopage.cpp
  40. detInfo/detdialog.cpp
  41. equipment/equipmentfactory.cpp
  42. equipment/equipmentpage.cpp
  43. global.cpp
  44. httpclient.cpp
  45. jobs.cpp
  46. logger.cpp
  47. login/loginwindow.cpp
  48. main.cpp
  49. mainwindow.cpp
  50. registryManager/registrymanager.cpp
  51. mqtt/mqttclient.cpp
  52. blastRecord/blastrecordfactory.cpp
  53. blastRecord/blastrecord.cpp
  54. blastRecord/hblastrecord.cpp
  55. blastRecord/hblastrecorddao.cpp
  56. blastRecordDet/hblastrecorddet.cpp
  57. blastRecordDet/hblastrecorddetdao.cpp
  58. blastRegRecord/hblastregrecord.cpp
  59. blastRegRecord/hblastregrecorddao.cpp
  60. fireWidget/firingwidget.cpp
  61. fireWidget/navprogress.cpp
  62. des3encryption.cpp
  63. countdownwidget.cpp
  64. serial/serialtool.cpp
  65. serial/serialgps.cpp
  66. paregnrmc.cpp
  67. serialgpsthread.cpp
  68. worker/timeupdatethread.cpp
  69. loadingWidget.cpp
  70. backendapimanager.cpp
  71. homepage.cpp
  72. homepagefactory.cpp
  73. )
  74. # 定义头文件列表
  75. set(HEADERS
  76. PageWidget.h
  77. blastoperationfactory.h
  78. blastopepage.h
  79. addressfactory.h
  80. addresspage.h
  81. pagefactory.h
  82. components/MultiSelectComboBox.h
  83. blastProject/blastprojectfactory.h
  84. blastProject/blastprojectpage.h
  85. blastProject/hproject.h
  86. blastProject/hprojectdao.h
  87. blastProject/projectdialog.h
  88. buttondelegate.h
  89. databasemanager.h
  90. detInfo/detinfofactory.h
  91. detInfo/detinfopage.h
  92. detInfo/detdialog.h
  93. equipment/equipmentfactory.h
  94. equipment/equipmentpage.h
  95. global.h
  96. httpclient.h
  97. jobs.h
  98. logger.h
  99. login/loginwindow.h
  100. mainwindow.h
  101. registryManager/registrymanager.h
  102. mqtt/mqttclient.h
  103. regex.h
  104. blastRecord/blastrecordfactory.h
  105. blastRecord/blastrecord.h
  106. blastRecord/hblastrecord.h
  107. blastRecord/hblastrecorddao.h
  108. blastRecordDet/hblastrecorddet.h
  109. blastRecordDet/hblastrecorddetdao.h
  110. blastRegRecord/hblastregrecord.h
  111. blastRegRecord/hblastregrecorddao.h
  112. fireWidget/firingwidget.h
  113. fireWidget/navprogress.h
  114. des3encryption.h
  115. countdownwidget.h
  116. serial/serialtool.h
  117. serial/serialgps.h
  118. paregnrmc.h
  119. serialgpsthread.h
  120. worker/timeupdatethread.h
  121. loadingWidget.h
  122. backendapimanager.h
  123. homepage.h
  124. )
  125. # 定义 UI 文件列表
  126. set(FORMS
  127. homepage.ui
  128. PageWidget.ui
  129. addresspage.ui
  130. blastProject/blastprojectpage.ui
  131. detInfo/detinfopage.ui
  132. detInfo/detdialog.ui
  133. equipment/equipmentpage.ui
  134. login/loginwindow.ui
  135. mainwindow.ui
  136. blastProject/projectdialog.ui
  137. blastopepage.ui
  138. blastRecord/blastrecord.ui
  139. fireWidget/firingwidget.ui
  140. )
  141. # 定义资源文件列表
  142. set(RESOURCES
  143. media.qrc
  144. )
  145. # 添加可执行文件
  146. add_executable(${PROJECT_NAME}
  147. ${SOURCES}
  148. ${HEADERS}
  149. ${FORMS}
  150. ${RESOURCES}
  151. logo.rc
  152. )
  153. # 创建测试可执行文件
  154. add_executable(test_database
  155. test_database.cpp
  156. databasemanager.cpp
  157. logger.cpp
  158. )
  159. # 链接测试可执行文件的库
  160. target_link_libraries(test_database
  161. Qt${QT_VERSION_MAJOR}::Core
  162. Qt${QT_VERSION_MAJOR}::Widgets
  163. Qt${QT_VERSION_MAJOR}::Sql
  164. ${OPENSSL_LIBRARIES}
  165. )
  166. # 设置测试可执行文件的输出目录
  167. set_target_properties(test_database PROPERTIES
  168. RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
  169. )
  170. set_target_properties(${PROJECT_NAME} PROPERTIES
  171. WIN32_EXECUTABLE FALSE
  172. )
  173. target_link_libraries(pc_system Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui
  174. Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Sql Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Charts
  175. Qt${QT_VERSION_MAJOR}::Mqtt Qt${QT_VERSION_MAJOR}::WebEngineWidgets OpenSSL::Crypto OpenSSL::SSL Qt${QT_VERSION_MAJOR}::SerialPort)
  176. include(GNUInstallDirs)
  177. install(TARGETS pc_system
  178. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  179. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  180. )