mirror of https://gitee.com/cxasm/notepad--.git
windows-deployqt: 处理构建动态 QSci 库时的自动 windeployqt
This commit is contained in:
parent
ca73cc24b8
commit
1c261198f9
|
@ -52,3 +52,52 @@ function(qt5_qt6_compatible_check _CHECK_FILE _VAR)
|
||||||
set(${_VAR} false PARENT_SCOPE)
|
set(${_VAR} false PARENT_SCOPE)
|
||||||
endif(_index LESS 0)
|
endif(_index LESS 0)
|
||||||
endfunction(qt5_qt6_compatible_check _CHECK_FILE _VAR)
|
endfunction(qt5_qt6_compatible_check _CHECK_FILE _VAR)
|
||||||
|
|
||||||
|
|
||||||
|
# windeployqt_install
|
||||||
|
# Windows 在 install 目标时进行 windeployqt 的自动化
|
||||||
|
# 根据
|
||||||
|
# https://blog.nathanosman.com/2017/11/24/using-windeployqt-with-cpack.html
|
||||||
|
function(windeployqt_install TARGET)
|
||||||
|
# string(TOLOWER "${ALIAS}_file" _file)
|
||||||
|
# string(TOLOWER "${ALIAS}_output" _output)
|
||||||
|
|
||||||
|
set(WINDEPLOYQT_EXECUTABLE "${WINDOWS_QT_DIR}/../../../bin/windeployqt")
|
||||||
|
#
|
||||||
|
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/${TARGET}_PATH"
|
||||||
|
CONTENT "$<TARGET_FILE:${TARGET}>"
|
||||||
|
)
|
||||||
|
install(CODE
|
||||||
|
"
|
||||||
|
file(READ \"${CMAKE_BINARY_DIR}/${TARGET}_PATH\" _file)
|
||||||
|
execute_process(
|
||||||
|
COMMAND \"${WINDEPLOYQT_EXECUTABLE}\"
|
||||||
|
# 虚假的运行 windeployqt 而不复制任何内容
|
||||||
|
--dry-run
|
||||||
|
# 扫描QML-从目录开始导入。
|
||||||
|
--qmlimport ${WINDOWS_QT_DIR}/../../../qml
|
||||||
|
# 部署编译器运行时(仅限桌面)。
|
||||||
|
--compiler-runtime
|
||||||
|
# 以源 目标的输出形成映射关系,以便用于解析内容
|
||||||
|
--list mapping
|
||||||
|
\${_file}
|
||||||
|
OUTPUT_VARIABLE _output
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
# 将内容转为一个列表,使用 WINDOWS_COMMAND 类型的处理方式
|
||||||
|
separate_arguments(_files WINDOWS_COMMAND \${_output})
|
||||||
|
|
||||||
|
while(_files)
|
||||||
|
list(GET _files 0 _src)
|
||||||
|
list(GET _files 1 _dest)
|
||||||
|
execute_process(
|
||||||
|
COMMAND \"\${CMAKE_COMMAND}\" -E
|
||||||
|
copy_if_different \${_src} \"\${CMAKE_INSTALL_PREFIX}/bin/\${_dest}\"
|
||||||
|
)
|
||||||
|
message(\"COPY \${_src} \${CMAKE_INSTALL_PREFIX}/bin/\${_dest}\")
|
||||||
|
list(REMOVE_AT _files 0 1)
|
||||||
|
endwhile(_files)
|
||||||
|
"
|
||||||
|
)
|
||||||
|
endfunction(windeployqt_install TARGET)
|
||||||
|
|
|
@ -98,45 +98,8 @@ if(WINDOWS_DEPLOY_QT)
|
||||||
|
|
||||||
|
|
||||||
# ---------- Windeployqt With Install Target ---------- #
|
# ---------- Windeployqt With Install Target ---------- #
|
||||||
#
|
include(cmake/platforms/utils.cmake)
|
||||||
set(WINDEPLOYQT_EXECUTABLE "${WINDOWS_QT_DIR}/../../../bin/windeployqt")
|
windeployqt_install(${PROJECT_NAME})
|
||||||
#
|
|
||||||
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/${PROJECT_NAME}_PATH"
|
|
||||||
CONTENT "$<TARGET_FILE:${PROJECT_NAME}>"
|
|
||||||
)
|
|
||||||
install(CODE
|
|
||||||
"
|
|
||||||
file(READ \"${CMAKE_BINARY_DIR}/${PROJECT_NAME}_PATH\" _file)
|
|
||||||
execute_process(
|
|
||||||
COMMAND \"${WINDEPLOYQT_EXECUTABLE}\"
|
|
||||||
# 虚假的运行 windeployqt 而不复制任何内容
|
|
||||||
--dry-run
|
|
||||||
# 扫描QML-从目录开始导入。
|
|
||||||
--qmlimport ${WINDOWS_QT_DIR}/../../../qml
|
|
||||||
# 部署编译器运行时(仅限桌面)。
|
|
||||||
--compiler-runtime
|
|
||||||
# 以源 目标的输出形成映射关系,以便用于解析内容
|
|
||||||
--list mapping
|
|
||||||
\${_file}
|
|
||||||
OUTPUT_VARIABLE _output
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
|
|
||||||
# 将内容转为一个列表,使用 WINDOWS_COMMAND 类型的处理方式
|
|
||||||
separate_arguments(_files WINDOWS_COMMAND \${_output})
|
|
||||||
|
|
||||||
while(_files)
|
|
||||||
list(GET _files 0 _src)
|
|
||||||
list(GET _files 1 _dest)
|
|
||||||
execute_process(
|
|
||||||
COMMAND \"\${CMAKE_COMMAND}\" -E
|
|
||||||
copy_if_different \${_src} \"\${CMAKE_INSTALL_PREFIX}/bin/\${_dest}\"
|
|
||||||
)
|
|
||||||
message(\"COPY \${_src} \${CMAKE_INSTALL_PREFIX}/bin/\${_dest}\")
|
|
||||||
list(REMOVE_AT _files 0 1)
|
|
||||||
endwhile(_files)
|
|
||||||
"
|
|
||||||
)
|
|
||||||
|
|
||||||
# ---------------------------------- QSci ---------------------------------- #
|
# ---------------------------------- QSci ---------------------------------- #
|
||||||
|
|
||||||
|
@ -173,21 +136,8 @@ if(WINDOWS_DEPLOY_QT)
|
||||||
--dir ${WINDOWS_APPLICATION_DEPLOY_PATH}
|
--dir ${WINDOWS_APPLICATION_DEPLOY_PATH}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_command(TARGET windows-deployqt
|
# ---------- Windeployqt With Install Target ---------- #
|
||||||
POST_BUILD
|
windeployqt_install(QSci)
|
||||||
COMMAND ${WINDOWS_QT_DIR}/../../../bin/windeployqt
|
|
||||||
#
|
|
||||||
${WINDOWS_APPLICATION_DEPLOY_PATH}/QSci.dll
|
|
||||||
|
|
||||||
# 扫描QML-从目录开始导入。
|
|
||||||
--qmlimport ${WINDOWS_QT_DIR}/../../../qml
|
|
||||||
# 部署编译器运行时(仅限桌面)。
|
|
||||||
--compiler-runtime
|
|
||||||
# 详细级别(0-2)
|
|
||||||
--verbose 2
|
|
||||||
# 部署运行时使用指定的目录
|
|
||||||
--dir ${CMAKE_INSTALL_PREFIX}/bin
|
|
||||||
)
|
|
||||||
|
|
||||||
endif(NOTEPAD_BUILD_BY_SHARED)
|
endif(NOTEPAD_BUILD_BY_SHARED)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue