CMakeLists.txt 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. blastJob/blastoperationfactory.cpp
  26. blastJob/blastopepage.cpp
  27. address/addressfactory.cpp
  28. address/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. components/buttondelegate.cpp
  37. utils/databasemanager.cpp
  38. detInfo/detinfofactory.cpp
  39. detInfo/detinfopage.cpp
  40. detInfo/detdialog.cpp
  41. equipment/equipmentfactory.cpp
  42. equipment/equipmentpage.cpp
  43. utils/global.cpp
  44. utils/httpclient.cpp
  45. utils/logger.cpp
  46. login/loginwindow.cpp
  47. main.cpp
  48. mainwindow/mainwindow.cpp
  49. utils/jobs.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. blastJob/countdownwidget.cpp
  63. serial/serialtool.cpp
  64. serial/serialgps.cpp
  65. serial/serialgpsthread.cpp
  66. serial/paregnrmc.cpp
  67. worker/timeupdatethread.cpp
  68. components/loadingWidget.cpp
  69. utils/backendapimanager.cpp
  70. homepage/homepage.cpp
  71. homepage/homepagefactory.cpp
  72. )
  73. # 定义头文件列表
  74. set(HEADERS
  75. PageWidget.h
  76. blastJob/blastoperationfactory.h
  77. blastJob/blastopepage.h
  78. address/addressfactory.h
  79. address/addresspage.h
  80. pagefactory.h
  81. components/MultiSelectComboBox.h
  82. blastProject/blastprojectfactory.h
  83. blastProject/blastprojectpage.h
  84. blastProject/hproject.h
  85. blastProject/hprojectdao.h
  86. blastProject/projectdialog.h
  87. components/components/
  88. utils/databasemanager.h
  89. detInfo/detinfofactory.h
  90. detInfo/detinfopage.h
  91. detInfo/detdialog.h
  92. equipment/equipmentfactory.h
  93. equipment/equipmentpage.h
  94. utils/global.h
  95. utils/httpclient.h
  96. utils/logger.h
  97. login/loginwindow.h
  98. mainwindow/mainwindow.h
  99. utils/jobs.h
  100. registryManager/registrymanager.h
  101. mqtt/mqttclient.h
  102. blastRecord/blastrecordfactory.h
  103. blastRecord/blastrecord.h
  104. blastRecord/hblastrecord.h
  105. blastRecord/hblastrecorddao.h
  106. blastRecordDet/hblastrecorddet.h
  107. blastRecordDet/hblastrecorddetdao.h
  108. blastRegRecord/hblastregrecord.h
  109. blastRegRecord/hblastregrecorddao.h
  110. fireWidget/firingwidget.h
  111. fireWidget/navprogress.h
  112. blastJob/countdownwidget.h
  113. serial/serialtool.h
  114. serial/serialgps.h
  115. serial/serialgpsthread.h
  116. serial/paregnrmc.h
  117. homepage/homepage.h
  118. worker/timeupdatethread.h
  119. components/loadingWidget.h
  120. utils/backendapimanager.h
  121. )
  122. # 定义 UI 文件列表
  123. set(FORMS
  124. homepage/homepage.ui
  125. PageWidget.ui
  126. address/addresspage.ui
  127. blastProject/blastprojectpage.ui
  128. detInfo/detinfopage.ui
  129. detInfo/detdialog.ui
  130. equipment/equipmentpage.ui
  131. login/loginwindow.ui
  132. mainwindow/mainwindow.ui
  133. blastProject/projectdialog.ui
  134. blastJob/blastopepage.ui
  135. blastRecord/blastrecord.ui
  136. fireWidget/firingwidget.ui
  137. )
  138. # 定义资源文件列表
  139. set(RESOURCES
  140. media.qrc
  141. )
  142. # 添加可执行文件
  143. add_executable(${PROJECT_NAME}
  144. ${SOURCES}
  145. ${HEADERS}
  146. ${FORMS}
  147. ${RESOURCES}
  148. logo.rc
  149. )
  150. # 创建测试可执行文件
  151. add_executable(test_database
  152. tests/test_database.cpp
  153. utils/databasemanager.cpp
  154. utils/logger.cpp
  155. )
  156. # 链接测试可执行文件的库
  157. target_link_libraries(test_database
  158. Qt${QT_VERSION_MAJOR}::Core
  159. Qt${QT_VERSION_MAJOR}::Widgets
  160. Qt${QT_VERSION_MAJOR}::Sql
  161. ${OPENSSL_LIBRARIES}
  162. )
  163. # 设置测试可执行文件的输出目录
  164. set_target_properties(test_database PROPERTIES
  165. RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
  166. )
  167. set_target_properties(${PROJECT_NAME} PROPERTIES
  168. WIN32_EXECUTABLE FALSE
  169. )
  170. target_link_libraries(pc_system Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui
  171. Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Sql Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Charts
  172. Qt${QT_VERSION_MAJOR}::Mqtt Qt${QT_VERSION_MAJOR}::WebEngineWidgets OpenSSL::Crypto OpenSSL::SSL Qt${QT_VERSION_MAJOR}::SerialPort)
  173. include(GNUInstallDirs)
  174. install(TARGETS pc_system
  175. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  176. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  177. )