Commit 18b59f2e authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

CMake + DeployWin.cmake (parts of old PackIFW)

parent aaabf3e6
Pipeline #38926 failed with stage
in 16 seconds
# Extra code to deploy DLL dependences to Windows.
include(CPackIFW)
# Search for compiler-provided system runtime libraries and add install rules for them.
# Options must be given before the include.
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE) # install Windows Universal CRT libs for app-local deployment
include(InstallRequiredSystemLibraries)
# Find windeployqt.exe (a Qt tool, should be in ${Qt5_BIN}, along with qmake.exe, uic.exe etc)
if(NOT Qt5_BIN)
message(FATAL_ERROR
"Qt5_BIN=${Qt5_BIN} not defined -- should point to the directory that contains windeployqt.exe")
endif()
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS ${Qt5_BIN})
mark_as_advanced(WINDEPLOYQT_EXECUTABLE)
message(STATUS "found windeployqt tool at ${WINDEPLOYQT_EXECUTABLE}")
if(NOT WINDEPLOYQT_EXECUTABLE)
message(FATAL_ERROR "windeployqt not found")
endif()
cpack_add_component_group(Steca EXPANDED)
cpack_ifw_configure_component_group(Steca NAME fzj.jcns.scg.steca)
# Add commands that copy the Qt runtime to the target's output directory
# after build and install the Qt runtime to the specified directory
# Run windeployqt immediately after build
add_custom_command(TARGET steca POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E
env PATH="${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}"
--verbose 0
--no-compiler-runtime
\"$<TARGET_FILE:steca>\"
)
# install(CODE ...) doesn't support generator expressions, but
# file(GENERATE ...) does - store the path in a file
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/steca_$<CONFIG>"
CONTENT "$<TARGET_FILE:steca>"
CONDITION "$<CONFIG:Release>"
)
# Before installation, run a series of commands that copy each of the Qt
# runtime files to the appropriate directory for installation
install(CODE
"
file(READ \"${CMAKE_CURRENT_BINARY_DIR}/steca_Release\" _file)
execute_process(
COMMAND \"${CMAKE_COMMAND}\" -E
env PATH=\"${_qt_bin_dir}\" \"${WINDEPLOYQT_EXECUTABLE}\"
--dry-run
--no-compiler-runtime
--list mapping
\${_file}
OUTPUT_VARIABLE _output
OUTPUT_STRIP_TRAILING_WHITESPACE
)
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 \${_src} \"\${CMAKE_INSTALL_PREFIX}/bin/\${_dest}\"
)
list(REMOVE_AT _files 0 1)
endwhile()
"
COMPONENT "QtLibs"
)
# windeployqt doesn't work correctly with the system runtime libraries,
# so we fall back to one of CMake's own modules for copying them over
foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})
get_filename_component(filename "${lib}" NAME)
add_custom_command(TARGET steca POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E
copy_if_different "${lib}" \"$<TARGET_FILE_DIR:Steca>\"
)
endforeach()
cpack_add_component(Steca.exe ENABLED GROUP Steca)
cpack_ifw_configure_component(Steca.exe
NAME fzj.jcns.scg.steca.exe SCRIPT ${CMAKE_SOURCE_DIR}/StecaInstallScript.qs)
......@@ -29,3 +29,9 @@ install(
TARGETS ${app}
RUNTIME DESTINATION bin
)
### extra installs for Win ###
if(WIN32)
include(DeployWin)
endif()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment