2025-03-14 16:06:20 +08:00
|
|
|
|
cmake_minimum_required(VERSION 3.5)
|
|
|
|
|
|
|
|
|
|
|
|
project(PowerModeler 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)
|
|
|
|
|
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Sql)
|
2025-05-30 18:51:23 +08:00
|
|
|
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Svg)
|
2025-03-14 16:06:20 +08:00
|
|
|
|
|
|
|
|
|
|
#默认ui文件要和.h头文件在一个目录,若不在一个目录,需要指定其所在目录
|
|
|
|
|
|
set(CMAKE_AUTOUIC_SEARCH_PATHS "ui")
|
|
|
|
|
|
|
|
|
|
|
|
set(H_HEADER_FILES
|
|
|
|
|
|
include/global.h
|
|
|
|
|
|
include/logger.h
|
2025-03-24 18:13:06 +08:00
|
|
|
|
include/mainwindow.h
|
2025-03-14 16:06:20 +08:00
|
|
|
|
include/dbManager.h
|
|
|
|
|
|
include/dbBrowser.h
|
|
|
|
|
|
include/dbStructureNode.h
|
|
|
|
|
|
include/dbStructureModel.h
|
|
|
|
|
|
include/dbStructureView.h
|
|
|
|
|
|
include/connectionDialog.h
|
|
|
|
|
|
include/messageDialog.h
|
2025-04-11 17:14:17 +08:00
|
|
|
|
include/messageBox.h
|
2025-03-14 16:06:20 +08:00
|
|
|
|
include/settings.h
|
|
|
|
|
|
include/tableWidgetHoverDelegate.h
|
2025-04-18 18:44:26 +08:00
|
|
|
|
include/textColorPreserveDelegate.h
|
2025-03-14 16:06:20 +08:00
|
|
|
|
include/customMenu.h
|
2025-03-28 17:40:59 +08:00
|
|
|
|
include/multiLineHeaderView.h
|
2025-03-14 16:06:20 +08:00
|
|
|
|
include/modelInfoEditDialog.h
|
|
|
|
|
|
include/sqlQueryExecutor.h
|
2025-04-08 20:02:38 +08:00
|
|
|
|
include/attributeNamespace.h
|
2025-03-24 18:13:06 +08:00
|
|
|
|
include/attributeTableModel.h
|
2025-03-27 14:47:51 +08:00
|
|
|
|
include/attributeTableDelegate.h
|
2025-03-24 18:13:06 +08:00
|
|
|
|
include/attributeView.h
|
2025-04-11 17:14:17 +08:00
|
|
|
|
include/attributeSelector.h
|
2025-04-21 14:29:20 +08:00
|
|
|
|
include/maskLayer.h
|
2025-04-14 12:10:07 +08:00
|
|
|
|
include/maskManager.h
|
2025-04-15 16:39:36 +08:00
|
|
|
|
include/customBorderContainer.h
|
2025-04-18 18:44:26 +08:00
|
|
|
|
include/groupSelectionDialog.h
|
2025-04-25 11:49:03 +08:00
|
|
|
|
include/dataSyncManager.h
|
2025-05-09 14:54:20 +08:00
|
|
|
|
include/importExportManager.h
|
2025-03-14 16:06:20 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
set(CPP_SOURCE_FILES
|
|
|
|
|
|
source/main.cpp
|
|
|
|
|
|
source/global.cpp
|
|
|
|
|
|
source/logger.cpp
|
2025-03-24 18:13:06 +08:00
|
|
|
|
source/mainwindow.cpp
|
2025-03-14 16:06:20 +08:00
|
|
|
|
source/dbManager.cpp
|
|
|
|
|
|
source/dbBrowser.cpp
|
|
|
|
|
|
source/dbStructureNode.cpp
|
|
|
|
|
|
source/dbStructureModel.cpp
|
|
|
|
|
|
source/dbStructureView.cpp
|
|
|
|
|
|
source/connectionDialog.cpp
|
|
|
|
|
|
source/messageDialog.cpp
|
2025-04-11 17:14:17 +08:00
|
|
|
|
source/messageBox.cpp
|
2025-03-14 16:06:20 +08:00
|
|
|
|
source/settings.cpp
|
|
|
|
|
|
source/tableWidgetHoverDelegate.cpp
|
2025-04-18 18:44:26 +08:00
|
|
|
|
source/textColorPreserveDelegate.cpp
|
2025-03-14 16:06:20 +08:00
|
|
|
|
source/customMenu.cpp
|
2025-03-28 17:40:59 +08:00
|
|
|
|
source/multiLineHeaderView.cpp
|
2025-03-14 16:06:20 +08:00
|
|
|
|
source/modelInfoEditDialog.cpp
|
|
|
|
|
|
source/sqlQueryExecutor.cpp
|
2025-03-24 18:13:06 +08:00
|
|
|
|
source/attributeTableModel.cpp
|
2025-03-27 14:47:51 +08:00
|
|
|
|
source/attributeTableDelegate.cpp
|
2025-03-24 18:13:06 +08:00
|
|
|
|
source/attributeView.cpp
|
2025-04-11 17:14:17 +08:00
|
|
|
|
source/attributeSelector.cpp
|
2025-04-21 14:29:20 +08:00
|
|
|
|
source/maskLayer.cpp
|
2025-04-14 12:10:07 +08:00
|
|
|
|
source/maskManager.cpp
|
2025-04-15 16:39:36 +08:00
|
|
|
|
source/customBorderContainer.cpp
|
2025-04-18 18:44:26 +08:00
|
|
|
|
source/groupSelectionDialog.cpp
|
2025-04-25 11:49:03 +08:00
|
|
|
|
source/dataSyncManager.cpp
|
2025-05-09 14:54:20 +08:00
|
|
|
|
source/importExportManager.cpp
|
2025-03-14 16:06:20 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
set(UI_FILES
|
2025-03-24 18:13:06 +08:00
|
|
|
|
ui/mainwindow.ui
|
2025-03-18 18:35:30 +08:00
|
|
|
|
ui/dbBrowser.ui
|
2025-03-14 16:06:20 +08:00
|
|
|
|
ui/connectionDialog.ui
|
|
|
|
|
|
ui/messageDialog.ui
|
|
|
|
|
|
ui/modelInfoEditDialog.ui
|
2025-04-08 20:02:38 +08:00
|
|
|
|
ui/textEditWidget.ui
|
2025-04-11 17:14:17 +08:00
|
|
|
|
ui/attributeSelector.ui
|
2025-04-18 18:44:26 +08:00
|
|
|
|
ui/groupSelectionDialog.ui
|
2025-03-14 16:06:20 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
2025-07-17 15:10:32 +08:00
|
|
|
|
set(APP_ICON "${CMAKE_CURRENT_SOURCE_DIR}/app_Logo.rc")
|
|
|
|
|
|
set(RESOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/resource/PowerModeler.qrc")
|
|
|
|
|
|
|
2025-03-14 16:06:20 +08:00
|
|
|
|
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
|
|
|
|
|
qt_add_executable(PowerModeler
|
|
|
|
|
|
MANUAL_FINALIZATION
|
|
|
|
|
|
${H_HEADER_FILES}
|
|
|
|
|
|
${CPP_SOURCE_FILES}
|
|
|
|
|
|
${UI_FILES}
|
2025-07-17 15:10:32 +08:00
|
|
|
|
${APP_ICON}
|
|
|
|
|
|
${RESOURCE_FILES}
|
2025-03-14 16:06:20 +08:00
|
|
|
|
)
|
|
|
|
|
|
# Define target properties for Android with Qt 6 as:
|
|
|
|
|
|
# set_property(TARGET PowerModeler 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(PowerModeler SHARED
|
|
|
|
|
|
${H_HEADER_FILES}
|
|
|
|
|
|
${CPP_SOURCE_FILES}
|
|
|
|
|
|
${UI_FILES}
|
2025-07-17 15:10:32 +08:00
|
|
|
|
${RESOURCE_FILES}
|
2025-03-14 16:06:20 +08:00
|
|
|
|
)
|
|
|
|
|
|
# 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(PowerModeler
|
|
|
|
|
|
${H_HEADER_FILES}
|
|
|
|
|
|
${CPP_SOURCE_FILES}
|
|
|
|
|
|
${UI_FILES}
|
2025-07-17 15:10:32 +08:00
|
|
|
|
${RESOURCE_FILES}
|
2025-03-14 16:06:20 +08:00
|
|
|
|
)
|
|
|
|
|
|
endif()
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
target_include_directories(PowerModeler PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
|
|
|
|
|
target_link_libraries(PowerModeler PRIVATE Qt${QT_VERSION_MAJOR}::Core
|
|
|
|
|
|
Qt${QT_VERSION_MAJOR}::Widgets
|
|
|
|
|
|
Qt${QT_VERSION_MAJOR}::Gui
|
2025-05-30 18:51:23 +08:00
|
|
|
|
Qt${QT_VERSION_MAJOR}::Sql
|
|
|
|
|
|
Qt${QT_VERSION_MAJOR}::Svg)
|
2025-03-14 16:06:20 +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.PowerModeler)
|
|
|
|
|
|
endif()
|
|
|
|
|
|
set_target_properties(PowerModeler 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 PowerModeler
|
|
|
|
|
|
BUNDLE DESTINATION .
|
|
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
#配置文件
|
|
|
|
|
|
set(CONFIG_FILE "app_config.ini")
|
|
|
|
|
|
set(CONFIG_FILE_DIR "${CMAKE_BINARY_DIR}")
|
|
|
|
|
|
if(NOT EXISTS "${CONFIG_FILE_DIR}/${CONFIG_FILE}")
|
|
|
|
|
|
file(COPY app_config.ini DESTINATION "${CONFIG_FILE_DIR}")
|
|
|
|
|
|
else()
|
|
|
|
|
|
message(STATUS "${CONFIG_FILE} already exists, skipping copy")
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
if(QT_VERSION_MAJOR EQUAL 6)
|
|
|
|
|
|
qt_finalize_executable(PowerModeler)
|
|
|
|
|
|
endif()
|