OneLevelXmlOpr/CMakeLists.txt

83 lines
2.4 KiB
CMake
Raw Permalink Normal View History

2025-01-17 10:44:17 +08:00
cmake_minimum_required(VERSION 3.16)
2024-05-15 08:34:54 +08:00
2025-06-13 10:23:43 +08:00
project(OneLevelXmlOpr VERSION 1.3.11 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2024-05-15 08:34:54 +08:00
# 获取环境变量 HOME
if (UNIX)
set(USER_HOME $ENV{HOME})
else()
set(USER_HOME "C:/Qt")
endif()
2024-08-08 17:05:57 +08:00
# 打印用户目录
message(STATUS "User home directory: ${USER_HOME}")
2024-05-20 23:36:44 +08:00
set(CMAKE_PREFIX_PATH
2024-08-27 20:15:41 +08:00
${CMAKE_PREFIX_PATH}
"${USER_HOME}/Qt5.14.2/5.14.2/gcc_64/"
"${USER_HOME}/Qt5.14.2/5.14.2/msvc2017_64/"
"D:/Qt/Qt5.14.2/5.14.2/msvc2017_64/"
"C:/Qt/6.7.2"
2024-09-16 08:32:20 +08:00
"/opt/homebrew/Cellar/qt/6.7.0_2/"
2025-06-07 01:50:29 +08:00
"D:/Dev/Qt6/msvc2022_64"
2024-05-20 23:36:44 +08:00
)
2024-05-15 08:34:54 +08:00
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
2025-06-13 10:23:43 +08:00
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network)
2024-05-15 08:34:54 +08:00
include_directories(3rd)
include_directories(src)
include_directories(form)
2025-06-13 10:23:43 +08:00
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
add_subdirectory(SingleApplication-3.5.2)
2024-05-15 08:34:54 +08:00
set(PROJECT_SOURCES
main.cpp
MainWidget.cpp
MainWidget.h
MainWidget.ui 3rd/tinyxml2.cpp
src/xml_opr.h src/xml_opr.cpp
2025-06-07 01:50:29 +08:00
src/config.h src/config.cpp public_def.cpp public_def.h
resource/ico.rc src/attribute_edit.ui src/attribute_edit.h
2025-06-07 10:22:08 +08:00
src/attribute_edit.cpp
src/data_edit.h src/data_edit.cpp src/data_edit.ui
src/QCustomQLineEdit.h src/QCustomQLineEdit.cpp
form/qformatset.h form/qformatset.cpp form/qformatset.ui
2025-06-07 01:50:29 +08:00
resource/QtTheme.qrc
resource.qrc
2025-06-07 10:22:08 +08:00
#flatgray.qrc
2024-05-15 08:34:54 +08:00
)
if (MSVC)
# if(${QT_VERSION_MAJOR} LESS 6)
# add_compile_options(/source-charset:utf-8)
# endif()
add_compile_options(/utf-8)
2024-05-28 09:17:23 +08:00
add_compile_options(/EHsc)
add_compile_options(/wd4267)
add_compile_options(-D_CRT_SECURE_NO_WARNINGS)
2024-05-15 08:34:54 +08:00
endif()
add_executable(OneLevelXmlOpr ${PROJECT_SOURCES}
conf_setting.h conf_setting.cpp conf_setting.ui
src/history.h src/history.cpp
src/uhistory.h src/uhistory.cpp src/uhistory.ui)
2025-06-13 10:23:43 +08:00
target_link_libraries(OneLevelXmlOpr PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network)
target_link_libraries(OneLevelXmlOpr PRIVATE SingleApplication::SingleApplication)
2024-05-15 08:34:54 +08:00
set_target_properties(OneLevelXmlOpr 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
)