cmake/platforms: 对 windows 平台的安装以及插件开发支持

This commit is contained in:
zinface 2023-02-09 11:55:48 +08:00
parent bfade94164
commit 8a464fa8ad
1 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,79 @@
if(CMAKE_HOST_WIN32)
# ------------------ 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 ------------------ #
message(" -------- ${CMAKE_INSTALL_PREFIX} ---------- ")
message("${Qt5_DIR}/../../../bin/windeployqt")
# 1. WindowsQtDeploy
# Windows Qt
add_custom_target(windeployqt
COMMAND ${Qt5_DIR}/../../../bin/windeployqt ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.exe --compiler-runtime --verbose 2 --dir ${CMAKE_BINARY_DIR}/winqt/)
endif(CMAKE_HOST_WIN32)