DiagramDesigner/CMakeLists.txt

166 lines
4.9 KiB
CMake
Raw Normal View History

2024-12-03 20:07:25 +08:00
cmake_minimum_required(VERSION 3.5)
project(DiagramDesigner LANGUAGES CXX VERSION 1.0)
2025-02-06 16:36:50 +08:00
2024-12-03 20:07:25 +08:00
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
2025-11-21 19:22:41 +08:00
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Sql Xml REQUIRED Charts)
2024-12-03 20:07:25 +08:00
find_package(Qt6 REQUIRED COMPONENTS SvgWidgets)
2025-02-06 16:36:50 +08:00
find_package(Qt6 COMPONENTS Network REQUIRED)
2025-10-24 21:11:07 +08:00
find_package(PostgreSQL REQUIRED)
2024-12-03 20:07:25 +08:00
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# 默认 ui 文件要和 .h 头文件在一个目录,若不在一个目录,需要指定其所在目录
set(CMAKE_AUTOUIC_SEARCH_PATHS "ui")
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
set(dd_PlatformDir "x86")
else()
if(DEFINED CMAKE_SYSTEM_PROCESSOR)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
set(dd_PlatformDir "x64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64")
set(dd_PlatformDir "aarch64")
else()
set(dd_PlatformDir "x64")
endif()
else()
set(dd_PlatformDir "x64")
endif()
endif()
set(H_HEADER_FILES
include/mainwindow.h
include/graphicElementsPanel.h
include/electricElementsPanel.h
include/electricElementsBox.h
include/electricElementsListwidget.h
include/operationCommand.h
include/toolPage.h
include/toolBox.h
2025-02-06 16:36:50 +08:00
include/loadPageDlg.h
2025-03-04 09:44:03 +08:00
include/projectModelDlg.h
2025-04-17 16:51:20 +08:00
include/projectTableDelegate.h
include/selectorDialog.h
2025-04-30 16:29:17 +08:00
include/topologyView.h
2025-05-09 19:36:32 +08:00
include/diagramView.h
include/topologyTree.h
2025-05-30 16:28:51 +08:00
include/createEditor.h
2025-11-14 19:31:09 +08:00
include/monitorItemsDlg.h
include/monitorPagesDlg.h
2025-02-06 16:36:50 +08:00
common/include/global.h
2025-04-17 16:51:20 +08:00
common/include/tools.h
2025-02-06 16:36:50 +08:00
common/include/httpInterface.h
2025-05-23 10:30:52 +08:00
common/include/baseProperty.h
2025-02-06 16:36:50 +08:00
common/include/compiler.hpp
common/include/export.hpp
common/include/operatingSystem.hpp
2024-12-03 20:07:25 +08:00
)
set(CPP_SOURCE_FILES
source/main.cpp
source/mainwindow.cpp
source/graphicElementsPanel.cpp
source/electricElementsPanel.cpp
source/electricElementsBox.cpp
source/electricElementsListwidget.cpp
source/operationCommand.cpp
source/toolPage.cpp
source/toolBox.cpp
2025-02-06 16:36:50 +08:00
source/loadPageDlg.cpp
2025-03-04 09:44:03 +08:00
source/projectModelDlg.cpp
2025-04-17 16:51:20 +08:00
source/projectTableDelegate.cpp
source/selectorDialog.cpp
2025-04-30 16:29:17 +08:00
source/topologyView.cpp
2025-05-09 19:36:32 +08:00
source/diagramView.cpp
source/topologyTree.cpp
2025-05-30 16:28:51 +08:00
source/createEditor.cpp
2025-11-14 19:31:09 +08:00
source/monitorItemsDlg.cpp
source/monitorPagesDlg.cpp
2025-02-06 16:36:50 +08:00
common/source/httpInterface.cpp
2025-03-28 18:08:21 +08:00
common/source/global.cpp
2025-04-30 16:29:17 +08:00
common/source/tools.cpp
2025-05-23 10:30:52 +08:00
common/source/baseProperty.cpp
2024-12-03 20:07:25 +08:00
)
set(UI_FILES
ui/mainwindow.ui
ui/graphicElementsPanel.ui
2025-02-06 16:36:50 +08:00
ui/loadPageDlg.ui
2025-03-04 09:44:03 +08:00
ui/projectModelDlg.ui
2025-04-30 16:29:17 +08:00
ui/topologyView.ui
2025-05-09 19:36:32 +08:00
ui/diagramView.ui
2025-05-30 16:28:51 +08:00
ui/createEditor.ui
2025-11-14 19:31:09 +08:00
ui/monitorItemsDlg.ui
ui/monitorPagesDlg.ui
2024-12-03 20:07:25 +08:00
)
# 包含源文件目录
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(DiagramDesigner
MANUAL_FINALIZATION
${H_HEADER_FILES}
${CPP_SOURCE_FILES}
${UI_FILES}
resource/DiagramDesigner.qrc
)
else()
if(ANDROID)
add_library(DiagramDesigner SHARED
${H_HEADER_FILES}
${CPP_SOURCE_FILES}
${UI_FILES}
resource/DiagramDesigner.qrc
)
else()
add_executable(DiagramDesigner WIN32
${H_HEADER_FILES}
${CPP_SOURCE_FILES}
${UI_FILES}
resource/DiagramDesigner.qrc
)
endif()
endif()
include_directories(include)
2025-02-06 16:36:50 +08:00
include_directories(common/include)
2025-10-24 21:11:07 +08:00
include_directories(${PostgreSQL_INCLUDE_DIRS})
2024-12-03 20:07:25 +08:00
target_include_directories(DiagramDesigner PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(DiagramDesigner PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets)
target_link_libraries(DiagramDesigner PRIVATE Qt6::SvgWidgets)
2025-02-06 16:36:50 +08:00
target_link_libraries(DiagramDesigner PRIVATE Qt6::Xml)
target_link_libraries(DiagramDesigner PRIVATE Qt6::Network)
2025-10-24 21:11:07 +08:00
target_link_libraries(DiagramDesigner PRIVATE Qt6::Sql ${PostgreSQL_LIBRARIES})
message(STATUS "POSTGRESQL_LIBRARIES: ${PostgreSQL_LIBRARIES}")
2024-12-03 20:07:25 +08:00
set_target_properties(DiagramDesigner PROPERTIES
AUTOMOC ON
AUTORCC ON
AUTOUIC ON
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
VERSION 1.0
EXPORT_NAME "DiagramDesigner with Qt Advanced Docking System"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${dd_PlatformDir}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${dd_PlatformDir}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${dd_PlatformDir}/bin"
)
2025-03-21 12:53:45 +08:00
target_link_libraries(DiagramDesigner PRIVATE diagramCavas diagramUtils)
2025-02-06 16:36:50 +08:00
add_subdirectory(diagramCavas)
2025-03-21 12:53:45 +08:00
add_subdirectory(diagramUtils)
2025-02-06 16:36:50 +08:00
file(COPY setting.xml DESTINATION "${CMAKE_BINARY_DIR}/${dd_PlatformDir}/bin")