repo: 通用 Windows 平台构建,一切的起始

This commit is contained in:
zinface 2023-02-19 02:34:27 +08:00
parent 4187a875c4
commit 4432551a1e
5 changed files with 228 additions and 4 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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)

31
windows-universal.mk Normal file
View File

@ -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)

View File

@ -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"