windows-deployqt: 处理构建动态 QSci 库时的自动 windeployqt

This commit is contained in:
zinface 2023-03-21 00:17:45 +08:00
parent ca73cc24b8
commit 1c261198f9
2 changed files with 55 additions and 56 deletions

View File

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

View File

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