mirror of https://gitee.com/cxasm/notepad--.git
repo: 通用 Windows 平台构建,一切的起始
This commit is contained in:
parent
4187a875c4
commit
4432551a1e
|
@ -39,8 +39,9 @@ option(USE_WINDOWS_UNIVERSAL "通用 Windows 平台构建" OFF)
|
|||
option(USE_WINDOWS_MINGW "通用 Windows 平台 MinGW 构建" OFF)
|
||||
option(USE_WINDOWS_MSVC "通用 Windows 平台 MSVC 构建" OFF)
|
||||
#
|
||||
option(WINDOWS_DEPLOY_QT5 "通用 Windows Qt5 构建 windeployqt" OFF)
|
||||
option(WINDOWS_DEPLOY_QT6 "通用 Windows Qt6 构建 windeployqt" OFF)
|
||||
option(WINDOWS_DEPLOY_QT "通用 Windows 平台 Qt 部署" OFF)
|
||||
option(WINDOWS_DEPLOY_QT5 "通用 Windows 平台指定 Qt5 部署 windeployqt" OFF)
|
||||
option(WINDOWS_DEPLOY_QT6 "通用 Windows 平台指定 Qt6 部署 windeployqt" OFF)
|
||||
|
||||
|
||||
# 使用 macos.cmake / linux.cmake / windows.cmake 维护构建.
|
||||
|
@ -79,7 +80,10 @@ elseif(WIN32)
|
|||
|
||||
# 通用 Windows 平台构建,一切的起始
|
||||
if(USE_WINDOWS_UNIVERSAL)
|
||||
# include(cmake/platforms/windows.cmake)
|
||||
include(cmake/platforms/windows-universal.cmake)
|
||||
|
||||
# 为 Windows 中构建的应用进行 windeployqt 的配方
|
||||
include(cmake/platforms/windows-deployqt.cmake)
|
||||
|
||||
# 通用平台的 Windows MinGW 构建
|
||||
if(USE_WINDOWS_MINGW)
|
||||
|
@ -93,7 +97,7 @@ elseif(WIN32)
|
|||
|
||||
# 其它 Windows 平台的构建
|
||||
else()
|
||||
# include(cmake/platforms/windows.cmake)
|
||||
# include(cmake/platforms/windows-other.cmake)
|
||||
endif(USE_WINDOWS_UNIVERSAL)
|
||||
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
# windows-deployqt.cmake
|
||||
|
||||
# Windows 平台 windeployqt 自动化模块
|
||||
# 在对项目进行构建时,是否需要配置 deployqt 来为项目进行构建部署设计
|
||||
|
||||
# 1. 如果需要进行 windeployqt,需要提供此 WINDOWS_DEPLOY_QT 开关
|
||||
# 2. 默认应用构建的内容将随附在此处
|
||||
# 3. 预先设置一个默认的 Windows Qt 目录变量
|
||||
set(WINDOWS_QT_DIR "")
|
||||
|
||||
option(WINDOWS_DEPLOY_QT "为 Windows 中构建的应用进行 windeployqt" OFF)
|
||||
option(WINDOWS_DEPLOY_QT5 "为 Windows 中构建的 QT5 应用进行 windeployqt" OFF)
|
||||
option(WINDOWS_DEPLOY_QT6 "为 Windows 中构建的 QT6 应用进行 windeployqt" OFF)
|
||||
|
||||
if(WINDOWS_DEPLOY_QT)
|
||||
|
||||
if(WINDOWS_DEPLOY_QT5)
|
||||
# 当使用 WINDOWS_DEPLOY_QT5 配方时,将使用来源于 Qt5 中提供的路径
|
||||
set(WINDOWS_QT_DIR "${Qt5_DIR}")
|
||||
elseif(WINDOWS_DEPLOY_QT6)
|
||||
# 当使用 WINDOWS_DEPLOY_QT6 配方时,将使用来源于 Qt6 中提供的路径
|
||||
set(WINDOWS_QT_DIR "${Qt6_DIR}")
|
||||
endif()
|
||||
|
||||
if (WINDOWS_DEPLOY_QT5 OR WINDOWS_DEPLOY_QT6)
|
||||
message(" -------- ${CMAKE_INSTALL_PREFIX} ---------- ")
|
||||
message("${WINDOWS_QT_DIR}/../../../bin/windeployqt")
|
||||
|
||||
# install(TARGETS ${PROJECT_NAME}
|
||||
# DESTINATION ${CMAKE_BINARY_DIR}/windows-deployqt)
|
||||
|
||||
|
||||
# 配置一个自动运行 windeployqt 配方的位置
|
||||
# 当使用 Windows Deploy Qt 时,可执行程序与即将部署的应用运行时将在此处出现
|
||||
set(WINDOWS_APPLICATION_DEPLOY_PATH
|
||||
${CMAKE_BINARY_DIR}/windows-deployqt/${PROJECT_NAME}.app/bin)
|
||||
|
||||
# 在开启支持 windeployqt 配方后,这部分将会改变默认构建的目标的一些行为
|
||||
# 这是 windeployqt,所以,它应该是一个 WIN32 程序
|
||||
# 它的输出目录将定义为
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
# 这是一个 WIN32 程序,即可执行文件不再出现黑窗口,转而使用 WinMain(某种 Windows 内部特性)
|
||||
WIN32_EXECUTABLE true
|
||||
# 静态库生成目录
|
||||
# ARCHIVE_OUTPUT_DIRECTORY ""
|
||||
# 动态库生成目录
|
||||
# LIBRARY_OUTPUT_DIRECTORY ""
|
||||
# 可执行文件生成目录
|
||||
RUNTIME_OUTPUT_DIRECTORY ${WINDOWS_APPLICATION_DEPLOY_PATH})
|
||||
|
||||
# 自动化构建 Windows Deploy Qt Application
|
||||
# 参考: windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>
|
||||
add_custom_command(TARGET ${PROJECT_NAME}
|
||||
# 在构建之后计划进行执行以下命令
|
||||
POST_BUILD
|
||||
# 即将在构建目录中
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
# 执行以下命令进行 windeployqt
|
||||
COMMAND ${WINDOWS_QT_DIR}/../../../bin/windeployqt
|
||||
#
|
||||
${WINDOWS_APPLICATION_DEPLOY_PATH}/${PROJECT_NAME}.exe
|
||||
|
||||
# 扫描QML-从目录开始导入。
|
||||
--qmlimport ${WINDOWS_QT_DIR}/../../../qml
|
||||
# 部署编译器运行时(仅限桌面)。
|
||||
--compiler-runtime
|
||||
# 详细级别(0-2)
|
||||
--verbose 2
|
||||
# 部署运行时使用指定的目录
|
||||
--dir ${WINDOWS_APPLICATION_DEPLOY_PATH}
|
||||
)
|
||||
|
||||
# 此部分为创建一个 windows-deployqt 的虚拟目标,用于对执行安装后的应用进行 windeployqt
|
||||
# 手动化构建 Windows Deploy Qt Application
|
||||
# 参考: windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>
|
||||
add_custom_target(windows-deployqt
|
||||
COMMAND ${WINDOWS_QT_DIR}/../../../bin/windeployqt
|
||||
#
|
||||
${WINDOWS_APPLICATION_DEPLOY_PATH}/${PROJECT_NAME}.exe
|
||||
|
||||
# 扫描QML-从目录开始导入。
|
||||
--qmlimport ${WINDOWS_QT_DIR}/../../../qml
|
||||
# 部署编译器运行时(仅限桌面)。
|
||||
--compiler-runtime
|
||||
# 详细级别(0-2)
|
||||
--verbose 2
|
||||
# 部署运行时使用指定的目录
|
||||
--dir ${CMAKE_INSTALL_PREFIX}/bin
|
||||
)
|
||||
|
||||
endif (WINDOWS_DEPLOY_QT5 OR WINDOWS_DEPLOY_QT6)
|
||||
|
||||
endif(WINDOWS_DEPLOY_QT)
|
|
@ -0,0 +1,93 @@
|
|||
# windows-universal.cmake
|
||||
|
||||
# 此构建表示,在 Windows 中以通用平台构建方式进行构建此内容
|
||||
# 为 Notepad-- 通用构建的设计安装结构
|
||||
#
|
||||
# /bin 在 Windows 中标准的程序位置
|
||||
# Notepad--.exe
|
||||
# plugin/
|
||||
# themes
|
||||
#
|
||||
# /include/ 在 Windows 中提供一系列可提供插件开发的头文件
|
||||
# NotepadPlugin/
|
||||
# pluginGl.h
|
||||
# QSci/
|
||||
# qscint/scintilla/
|
||||
#
|
||||
# /lib/ 在 Windows 中提供一个用于插件开发的核心依赖文件
|
||||
# NotepadPlugin/
|
||||
# libQSci.so
|
||||
#
|
||||
|
||||
|
||||
if(CMAKE_HOST_WIN32)
|
||||
include(cmake/SparkInstallMacrosConfig.cmake)
|
||||
# ------------------ INSTALL PLUGIN CONFIG ------------------ #
|
||||
# ------------------ INSTALL PLUGIN CONFIG ------------------ #
|
||||
# ------------------ INSTALL PLUGIN CONFIG ------------------ #
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# 定义插件配置安装位置
|
||||
# set(CMAKE_INSTALL_PREFIX "/usr") # 仅限 Linux ,Windows 中不使用
|
||||
set(NOTEPAD_PLUGIN NotepadPlugin)
|
||||
|
||||
# 定义开发插件时的配置目录与 CMake 模块文件名称
|
||||
set(NOTEPAD_PLUGIN_CONFIG ${NOTEPAD_PLUGIN}Config.cmake)
|
||||
# 定义一些扩展内容,主要是提供给 CMake 模块文件填充
|
||||
set(NOTEPAD_PLUGIN_CORELIB QSci) # QSci 为构建的 QScintllia 库
|
||||
|
||||
# 定义在插件开发的 CMake 模块中,Notepad-- 是否是基于 QT5 实现
|
||||
# 并自动为插件开发层自动开启相关 Qt 依赖组件
|
||||
# 此部分逻辑将自动提供给 add_notepad_plugin 自行处理
|
||||
set(NOTEPAD_BUILD_BY_QT5 TRUE)
|
||||
set(NOTEPAD_BUILD_BY_QT6 FALSE)
|
||||
|
||||
# 定义在平台中插件应该安装的位置(待确定)
|
||||
# 定义在插件开发的 CMake 模块中,Notepad-- 是否将提供 "插件安装目录(位置)"
|
||||
set(NOTEPAD_PLUGIN_EXTERNAL_PLUGIN_INSTALL_DIRECTORY "")
|
||||
|
||||
# 这些是在此部分安装时使用,但不被用于填充 NotepadPlugin.cmake.in 的内容
|
||||
set(NOTEPAD_PLUGIN_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${NOTEPAD_PLUGIN})
|
||||
set(NOTEPAD_PLUGIN_LIBDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${NOTEPAD_PLUGIN})
|
||||
|
||||
|
||||
# 将 NOTEPAD_PLUGIN_INCLUDEDIR NOTEPAD_PLUGIN_LIBDIR 填充到 cmake 文件
|
||||
configure_package_config_file(cmake/NotepadPluginConfig.cmake.in
|
||||
${CMAKE_BINARY_DIR}/${NOTEPAD_PLUGIN_CONFIG}
|
||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NOTEPAD_PLUGIN})
|
||||
# 安装 cmake 文件
|
||||
spark_install_file(${CMAKE_INSTALL_LIBDIR}/cmake/${NOTEPAD_PLUGIN}
|
||||
${CMAKE_BINARY_DIR}/${NOTEPAD_PLUGIN_CONFIG})
|
||||
# 安装头插件接口文件
|
||||
spark_install_file(${NOTEPAD_PLUGIN_INCLUDEDIR}
|
||||
src/include/pluginGl.h)
|
||||
# 安装插件所需要的Qsci文件
|
||||
spark_install_directory(${NOTEPAD_PLUGIN_INCLUDEDIR}
|
||||
src/qscint/src/Qsci)
|
||||
# 安装开发插件高级功能所需要的内容
|
||||
spark_install_directory(${NOTEPAD_PLUGIN_INCLUDEDIR}/qscint
|
||||
src/qscint/scintilla)
|
||||
|
||||
# 导出 QSci 的头文件(从插件实现层面来看,目前是使用*.h 与 pluginGl.h
|
||||
# 但从 Qsci 层面来看,*.h 使用的是 #include <Qsci/*.h> ,所以此部分不被使用)
|
||||
# spark_file_glob(QSci_HEADERS src/qscint/src/Qsci/*.h src/include/pluginGl.h)
|
||||
# set_target_properties(QSci PROPERTIES PUBLIC_HEADER "${QSci_HEADERS}")
|
||||
|
||||
# 导出 Notepad-- 的接口文件(从逻辑层面来看,目前已经在前面安装了接口文件,所以此部分不被使用)
|
||||
# spark_file_glob(Notepad_HEADERS src/include/pluginGl.h)
|
||||
# set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${QSci_HEADERS}")
|
||||
|
||||
# 安装项目文件与 QSci 文件
|
||||
install(TARGETS ${PROJECT_NAME} QSci
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${NOTEPAD_PLUGIN_LIBDIR}
|
||||
ARCHIVE DESTINATION ${NOTEPAD_PLUGIN_LIBDIR}
|
||||
PUBLIC_HEADER DESTINATION ${NOTEPAD_PLUGIN_INCLUDEDIR}
|
||||
)
|
||||
# ------------------ INSTALL PLUGIN CONFIG ------------------ #
|
||||
# ------------------ INSTALL PLUGIN CONFIG ------------------ #
|
||||
# ------------------ INSTALL PLUGIN CONFIG ------------------ #
|
||||
|
||||
endif(CMAKE_HOST_WIN32)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# windows-universal.mk
|
||||
# Windows Universal - 通用 Windows 平台构建方案
|
||||
|
||||
builddir := build
|
||||
sourcedir := .
|
||||
CMAKE_DEBUG := -DCMAKE_BUILD_TYPE=Debug
|
||||
CMAKE_RELEASE := -DCMAKE_BUILD_TYPE=Release
|
||||
CMAKE_OPTIONS := -DUSE_WINDOWS_UNIVERSAL=ON
|
||||
CMAKE_GENERATER := ""
|
||||
CMAKE_UNIVERSAL_QT := $(CMAKE_OPTIONS) -DWINDOWS_DEPLOY_QT=ON
|
||||
CMAKE_UNIVERSAL_QT5 := $(CMAKE_UNIVERSAL_QT) -DWINDOWS_DEPLOY_QT5=ON
|
||||
CMAKE_UNIVERSAL_QT6 := $(CMAKE_UNIVERSAL_QT) -DWINDOWS_DEPLOY_QT6=ON
|
||||
|
||||
JOBS=$(shell nproc)
|
||||
|
||||
|
||||
windows-universal:
|
||||
cmake -B$(builddir) $(CMAKE_DEBUG) $(CMAKE_GENERATER) $(CMAKE_OPTIONS)
|
||||
cmake --build $(builddir) -- -j$(JOBS)
|
||||
|
||||
windows-universal-release:
|
||||
cmake -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_GENERATER) $(CMAKE_OPTIONS)
|
||||
cmake --build $(builddir) -- -j$(JOBS)
|
||||
|
||||
windows-universal-release-qt5:
|
||||
cmake $(CMAKE_GENERATER) -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_UNIVERSAL_QT5)
|
||||
cmake --build $(builddir) -- -j$(JOBS)
|
||||
|
||||
windows-universal-release-qt6:
|
||||
cmake $(CMAKE_GENERATER) -B$(builddir) $(CMAKE_RELEASE) $(CMAKE_UNIVERSAL_QT6)
|
||||
cmake --build $(builddir) -- -j$(JOBS)
|
|
@ -1,4 +1,6 @@
|
|||
Msg := 'Build with the following configuration:'
|
||||
One := '1. make -f windows-universal.mk'
|
||||
|
||||
all:
|
||||
@echo -e $(Msg)
|
||||
@echo -e $(One) "\n\tThe default Universal Windows platform build"
|
||||
|
|
Loading…
Reference in New Issue