PowerMaster/CMakeLists.txt

256 lines
8.2 KiB
CMake
Raw Normal View History

2024-10-10 16:59:51 +08:00
cmake_minimum_required(VERSION 3.5)
project(PowerMaster VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
2024-12-20 16:44:50 +08:00
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS PrintSupport)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Network)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Concurrent)
2024-10-10 16:59:51 +08:00
set(ADS_VERSION 4.3.1)
add_subdirectory(QtADS)
add_subdirectory(qamqp)
2024-10-10 16:59:51 +08:00
#默认ui文件要和.h头文件在一个目录若不在一个目录需要指定其所在目录
set(CMAKE_AUTOUIC_SEARCH_PATHS "ui")
set(H_HEADER_FILES
include/global.h
include/mainWindow.h
include/customBorderContainer.h
include/customLineEdit.h
2024-10-10 16:59:51 +08:00
include/customMenu.h
include/customTab.h
include/customTabBar.h
2024-10-10 16:59:51 +08:00
include/functionNavigationBar.h
include/dvieMainWindow.h
2024-11-07 12:08:56 +08:00
include/dvieSecondaryWindow.h
2024-10-10 16:59:51 +08:00
include/tccMainWindow.h
include/tccToolBox.h
include/transparentMask.h
include/messageDialog.h
include/dashboard.h
include/dashboardFrame.h
2024-10-10 16:59:51 +08:00
include/dashboardNamingDialog.h
include/dataPanel.h
include/dataLoader.h
include/dataManager.h
2024-10-10 16:59:51 +08:00
include/panelSelectionDialog.h
include/panelConfigurationWidget.h
include/dateTimeWidget.h
include/customCalendarWidget.h
include/dateTimeSelectionPanel.h
include/httpRequestManager.h
include/alarmEventGlobal.h
include/alarmEventMainDialog.h
include/alarmEventDataView.h
include/alarmEventRealTimeDock.h
include/alarmEventUtils.h
include/alarmEventDataService.h
2024-10-10 16:59:51 +08:00
)
set(CPP_SOURCE_FILES
source/global.cpp
source/main.cpp
source/mainWindow.cpp
source/customBorderContainer.cpp
source/customLineEdit.cpp
2024-10-10 16:59:51 +08:00
source/customMenu.cpp
source/customTab.cpp
source/customTabBar.cpp
2024-10-10 16:59:51 +08:00
source/functionNavigationBar.cpp
source/dvieMainWindow.cpp
2024-11-07 12:08:56 +08:00
source/dvieSecondaryWindow.cpp
2024-10-10 16:59:51 +08:00
source/tccMainWindow.cpp
source/tccToolBox.cpp
source/transparentMask.cpp
source/messageDialog.cpp
source/dashboard.cpp
source/dashboardFrame.cpp
2024-10-10 16:59:51 +08:00
source/dashboardNamingDialog.cpp
source/dataPanel.cpp
source/dataLoader.cpp
source/dataManager.cpp
2024-10-10 16:59:51 +08:00
source/panelSelectionDialog.cpp
source/panelConfigurationWidget.cpp
source/dateTimeWidget.cpp
source/customCalendarWidget.cpp
source/dateTimeSelectionPanel.cpp
source/httpRequestManager.cpp
source/alarmEventMainDialog.cpp
source/alarmEventDataView.cpp
source/alarmEventRealTimeDock.cpp
source/alarmEventUtils.cpp
source/alarmEventDataService.cpp
2024-10-10 16:59:51 +08:00
)
set(UI_FILES
ui/mainWindow.ui
ui/functionNavigationBar.ui
ui/dvieMainWindow.ui
2024-11-07 12:08:56 +08:00
ui/dvieSecondaryWindow.ui
2024-10-10 16:59:51 +08:00
ui/tccToolBox.ui
ui/transparentMask.ui
ui/messageDialog.ui
ui/dashboardFrame.ui
2024-10-10 16:59:51 +08:00
ui/dashboardNamingDialog.ui
ui/panelSelectionDialog.ui
ui/panelConfigurationWidget.ui
ui/panelToolWidget.ui
ui/dateTimeWidget.ui
ui/dateTimeSelectionPanel.ui
2025-01-14 18:39:52 +08:00
ui/dpConfigurationDialog.ui
ui/alarmEventMainDialog.ui
ui/alarmEventRealTimeDock.ui
2024-10-10 16:59:51 +08:00
)
set(UTIL_FILES
util/TimeLine/timeLine_globals.h
util/TimeLine/timeLineWidget.h
util/TimeLine/timeLineWidget.cpp
2024-11-27 16:39:25 +08:00
util/TimeLine/timeLineItem.h
util/TimeLine/timeLineItem.cpp
util/TimeLine/timeStampItem.h
util/TimeLine/timeStampItem.cpp
util/TimeLine/eventItem.h
util/TimeLine/eventItem.cpp
2024-12-20 16:44:50 +08:00
util/Chart/qcustomplot.h
util/Chart/qcustomplot.cpp
)
2024-12-24 20:17:42 +08:00
set(DATAPANEL_FILES
dataPanel/dpGlobals.h
2025-01-14 18:39:52 +08:00
dataPanel/dpConfigurationDialog.h
dataPanel/dpConfigurationDialog.cpp
2024-12-24 20:17:42 +08:00
dataPanel/dpBaseWidget.h
dataPanel/dpBaseWidget.cpp
dataPanel/dpBaseChart.h
dataPanel/dpBaseChart.cpp
2024-12-24 20:17:42 +08:00
dataPanel/dpLineChart.h
dataPanel/dpLineChart.cpp
2025-08-25 15:10:02 +08:00
dataPanel/dpBarsChart.h
dataPanel/dpBarsChart.cpp
2024-12-24 20:17:42 +08:00
)
2024-10-10 16:59:51 +08:00
# 包含源文件目录
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(PowerMaster
MANUAL_FINALIZATION
${H_HEADER_FILES}
${CPP_SOURCE_FILES}
${UI_FILES}
${UTIL_FILES}
2024-12-24 20:17:42 +08:00
${DATAPANEL_FILES}
2024-10-10 16:59:51 +08:00
resource/PowerMaster.qrc
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET PowerMaster APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(PowerMaster SHARED
${H_HEADER_FILES}
${CPP_SOURCE_FILES}
${UI_FILES}
${UTIL_FILES}
2024-10-10 16:59:51 +08:00
resource/PowerMaster.qrc
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(PowerMaster
${H_HEADER_FILES}
${CPP_SOURCE_FILES}
${UI_FILES}
${UTIL_FILES}
2024-10-10 16:59:51 +08:00
resource/PowerMaster.qrc
)
endif()
endif()
target_include_directories(PowerMaster PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_include_directories(PowerMaster PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/qamqp/src")
2024-12-20 16:44:50 +08:00
target_link_libraries(PowerMaster PRIVATE Qt${QT_VERSION_MAJOR}::PrintSupport)
target_link_libraries(PowerMaster PRIVATE Qt${QT_VERSION_MAJOR}::Network)
target_link_libraries(PowerMaster PRIVATE Qt${QT_VERSION_MAJOR}::Concurrent)
2024-10-10 16:59:51 +08:00
target_link_libraries(PowerMaster PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
target_link_libraries(PowerMaster PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
qamqp)
2024-10-10 16:59:51 +08:00
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.PowerMaster)
endif()
set_target_properties(PowerMaster PROPERTIES
${BUNDLE_ID_OPTION}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
include(GNUInstallDirs)
install(TARGETS PowerMaster
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# 定义配置文件和目标目录
set(CONFIG_FILES
alarmEventService_config.ini
realTimeDataService_config.ini
)
set(CONFIG_FILE_DIR "${CMAKE_BINARY_DIR}/config")
# 确保配置文件目录存在
if(NOT EXISTS "${CONFIG_FILE_DIR}")
message(STATUS "Creating confiuration directory: ${CONFIG_FILE_DIR}")
file(MAKE_DIRECTORY "${CONFIG_FILE_DIR}")
endif()
# 复制所有配置文件到目标目录
foreach(CONFIG_FILE ${CONFIG_FILES})
set(SOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_FILE}")
set(TARGET_FILE "${CONFIG_FILE_DIR}/${CONFIG_FILE}")
# 检查源文件是否存在
if(NOT EXISTS "${SOURCE_FILE}")
message(WARNING "Config file not found: ${CONFIG_FILE}")
continue()
endif()
# 拷贝
if(NOT EXISTS "${TARGET_FILE}")
message(STATUS "Copied ${CONFIG_FILE} to ${CONFIG_FILE_DIR}")
file(COPY "${SOURCE_FILE}" DESTINATION "${CONFIG_FILE_DIR}")
else()
# 可选:检查是否需要更新(基于时间戳并采用统一格式)
file(TIMESTAMP "${SOURCE_FILE}" SOURCE_TIME "%s")
file(TIMESTAMP "${TARGET_FILE}" TARGET_TIME "%s")
# message(STATUS "${SOURCE_FILE} timestamp: ${SOURCE_TIME}")
# message(STATUS "${TARGET_FILE} timestamp: ${TARGET_TIME}")
if(SOURCE_TIME GREATER TARGET_TIME)
message(STATUS "Updating ${CONFIG_FILE} (source is newer)")
file(COPY "${SOURCE_FILE}" DESTINATION "${CONFIG_FILE_DIR}")
else()
message(STATUS "${TARGET_FILE} already exists, skipping copy")
endif()
endif()
endforeach()
2024-10-10 16:59:51 +08:00
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(PowerMaster)
endif()