2023-02-01 20:04:05 +08:00
|
|
|
cmake_minimum_required(VERSION 3.24)
|
|
|
|
project(notepad-- VERSION 1.22.0)
|
2023-01-31 22:17:32 +08:00
|
|
|
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
|
|
|
|
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport XmlPatterns)
|
|
|
|
|
2023-02-02 18:05:54 +08:00
|
|
|
# TODO: use system provided libraries to build
|
|
|
|
# current status: some header can not be found,for example: Scintilla.h
|
|
|
|
find_library(QSCINTILLA_LIB_PATH qscintilla2_qt5)
|
|
|
|
find_path(QSCINTILLA_INC_PATH qsciscintilla.h PATHS /usr/include/)
|
|
|
|
find_path(SCINTILLA_INC_PATH Scintilla.h PATHS /usr/include/)
|
2023-02-03 21:00:18 +08:00
|
|
|
if((${QSCINTILLA_LIB_PATH} STREQUAL "QSCINTILLA_LIB_PATH-NOTFOUND") OR
|
|
|
|
(${QSCINTILLA_INC_PATH} STREQUAL "QSCINTILLA_INC_PATH-NOTFOUND") OR
|
2023-02-02 18:05:54 +08:00
|
|
|
(${SCINTILLA_INC_PATH} STREQUAL "SCINTILLA_INC_PATH-NOTFOUND") )
|
|
|
|
set(NOTEPAD_USE_SYS_LIB OFF)
|
|
|
|
message("system libraries or header not found,build from local")
|
2023-01-31 22:17:32 +08:00
|
|
|
add_subdirectory(${PROJECT_SOURCE_DIR}/src/qscint)
|
2023-02-02 18:05:54 +08:00
|
|
|
else()
|
|
|
|
set(NOTEPAD_USE_SYS_LIB ON)
|
|
|
|
message("use system libraries")
|
|
|
|
message("QSCINTILLA_LIB_PATH:" ${QSCINTILLA_LIB_PATH})
|
|
|
|
message("QSCINTILLA_INC_PATH:" ${QSCINTILLA_INC_PATH})
|
|
|
|
message("SCINTILLA_INC_PATH:" ${SCINTILLA_INC_PATH})
|
|
|
|
endif()
|
2023-01-31 22:17:32 +08:00
|
|
|
|
|
|
|
file(GLOB UI_SRC ${PROJECT_SOURCE_DIR}/src/*.ui)
|
|
|
|
set(UI_SRC ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/cceditor/ccnotepad.ui)
|
|
|
|
aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC)
|
|
|
|
aux_source_directory(${PROJECT_SOURCE_DIR}/src/cceditor SRC)
|
|
|
|
|
|
|
|
add_executable(${PROJECT_NAME} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc)
|
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
|
|
|
${PROJECT_SOURCE_DIR}/src
|
|
|
|
${PROJECT_SOURCE_DIR}/src/cceditor
|
|
|
|
)
|
|
|
|
|
2023-02-02 18:05:54 +08:00
|
|
|
if(NOTEPAD_USE_SYS_LIB)
|
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${QSCINTILLA_INC_PATH} ${SCINTILLA_INC_PATH})
|
|
|
|
endif()
|
|
|
|
|
2023-02-01 18:08:29 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} qscintilla2_qt5 Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns)
|
|
|
|
|
|
|
|
install(
|
|
|
|
TARGETS ${PROJECT_NAME}
|
|
|
|
DESTINATION "bin"
|
|
|
|
)
|
|
|
|
|
|
|
|
install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/linux/usr
|
|
|
|
DESTINATION "/")
|
|
|
|
|
|
|
|
include(${PROJECT_SOURCE_DIR}/cmake/package_config.cmake)
|
|
|
|
include(CPack)
|
2023-01-31 22:17:32 +08:00
|
|
|
|
2023-02-01 20:04:05 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns)
|
|
|
|
|
|
|
|
if(CMAKE_HOST_UNIX)
|
|
|
|
include(cmake/SparkInstallMacrosConfig.cmake)
|
|
|
|
include(cmake/SparkDesktopMacros.cmake)
|
|
|
|
# 内容默认应用名称: Name= 应与项目名称相同
|
|
|
|
spark_desktop_macros(
|
|
|
|
# 应用名称: Name=
|
|
|
|
${PROJECT_NAME}
|
|
|
|
# 应用名称: Name[zh_CN]=
|
|
|
|
"Notepad--"
|
|
|
|
# 应用说明: Comment=
|
|
|
|
"Notepad-- 是一个国产跨平台、简单的文本编辑器。"
|
|
|
|
# 应用类型: Type=
|
|
|
|
"Application"
|
|
|
|
# 执行程序: Exec=
|
2023-02-02 14:00:54 +08:00
|
|
|
# 有关此 %F 参数可查看: https://gitee.com/zinface/z-tools/blob/desktop-dev/src/DesktopGenerater/desktopexecparamdialog.cpp
|
|
|
|
"notepad-- %F"
|
2023-02-01 20:04:05 +08:00
|
|
|
# 图标路径: Icon=
|
|
|
|
"/usr/share/notepad--/icons/spark.png"
|
|
|
|
# 应用分类: Category=
|
|
|
|
"Development"
|
|
|
|
)
|
|
|
|
spark_install_file(/usr/share/applications/ ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.desktop)
|
|
|
|
spark_install_file(/usr/share/notepad--/icons/ assets/spark.png)
|
|
|
|
spark_install_target(/usr/bin/ ${PROJECT_NAME})
|
|
|
|
|
2023-02-01 20:09:49 +08:00
|
|
|
|
|
|
|
# 1. 在顶层构建中导入 Appimage 的构建
|
|
|
|
include(cmake/SparkAppimageConfig.cmake) # 导入来自 Spark 构建的 Appimage 构建
|
|
|
|
add_appimage_icon(assets/spark.png) # 添加到 Appimage 中的默认的图标
|
|
|
|
add_appimage_desktop() # 添加到 Appimage 中的默认desktop(使用来自 Spark 构建的 Desktop 构建中配置的信息(必须要求 spark-desktop))
|
|
|
|
add_appimage() # 应用对 Appimage 的构建
|
|
|
|
|
|
|
|
|
2023-02-01 20:04:05 +08:00
|
|
|
# 注释行(使用方式)
|
|
|
|
find_package(DebPackage PATHS ${CMAKE_SOURCE_DIR})
|
|
|
|
add_package_descript(cmake/package-deb.descript)
|
|
|
|
|
|
|
|
endif(CMAKE_HOST_UNIX)
|