# Windows SDK tools and matching Qt binaries are required on the build host. include_guard(GLOBAL) if(NOT WIN32) return() endif() set(DOCVIEW_EXTRA_WORKER_RUNTIME_DLLS "" CACHE STRING "Explicit additional redistributable DLLs approved for worker packaging") find_program(DOCVIEW_DUMPBIN_EXECUTABLE NAMES dumpbin REQUIRED) find_program(DOCVIEW_WINDEPLOYQT_EXECUTABLE NAMES windeployqt HINTS "${Qt6_DIR}/../../../bin" REQUIRED) function(docview_configure_windows_worker target) set(script "${CMAKE_CURRENT_BINARY_DIR}/stage-${target}-$.cmake") file(GENERATE OUTPUT "${script}" CONTENT " set(WORKER_EXECUTABLE [==[$]==]) set(RUNTIME_LIBRARIES [==[$]==]) set(SEARCH_DIRECTORIES [==[$;$;$;${DOCVIEW_PDFIUM_ROOT}/bin]==]) set(EXTRA_RUNTIME_LIBRARIES [==[${DOCVIEW_EXTRA_WORKER_RUNTIME_DLLS}]==]) set(CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL dumpbin) set(CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND [==[${DOCVIEW_DUMPBIN_EXECUTABLE}]==]) include([==[${CMAKE_CURRENT_FUNCTION_LIST_DIR}/StageWindowsWorker.cmake]==]) ") add_custom_command(TARGET ${target} POST_BUILD COMMAND "${CMAKE_COMMAND}" -P "${script}" VERBATIM COMMENT "Collecting and hashing the restricted runtime for ${target}") endfunction() function(docview_install_windows_worker target) set(script "${CMAKE_CURRENT_BINARY_DIR}/install-${target}-$.cmake") file(GENERATE OUTPUT "${script}" CONTENT " set(WORKER_EXECUTABLE [==[$]==]) set(WORKER_INSTALL_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/bin\") set(WORKER_VERIFY_ONLY FALSE) include([==[${CMAKE_CURRENT_FUNCTION_LIST_DIR}/InstallWindowsWorker.cmake]==]) ") install(SCRIPT "${script}") endfunction() function(docview_install_windows_gui target) set(script "${CMAKE_CURRENT_BINARY_DIR}/deploy-${target}-$.cmake") file(GENERATE OUTPUT "${script}" CONTENT " set(destination \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin\") execute_process(COMMAND [==[${DOCVIEW_WINDEPLOYQT_EXECUTABLE}]==] --$,debug,release> --no-compiler-runtime --nopatchqt --dir \"\${destination}\" --plugindir \"\${destination}/plugins\" --qml-deploy-dir \"\${destination}/qml\" --translationdir \"\${destination}/translations\" --qmldir [==[${CMAKE_SOURCE_DIR}/qml]==] \"\${destination}/$\" RESULT_VARIABLE deployed) if(NOT deployed EQUAL 0) message(FATAL_ERROR \"windeployqt failed: \${deployed}\") endif() file(WRITE \"\${destination}/qt.conf\" \"[Paths]\\nPrefix=.\\nPlugins=plugins\\nQmlImports=qml\\nLibraryExecutables=.\\nData=.\\nTranslations=translations\\n\") # windeployqt must not patch or replace any hashed worker dependency. set(WORKER_VERIFY_ONLY TRUE) foreach(name docview-pdf-worker.exe docview-archive-worker.exe) set(WORKER_EXECUTABLE \"\${destination}/\${name}\") include([==[${CMAKE_CURRENT_FUNCTION_LIST_DIR}/InstallWindowsWorker.cmake]==]) endforeach() ") install(SCRIPT "${script}") endfunction()