# Installer Has Qt Deploy Fixes But Archive Does Not

**URL:** https://discourse.cmake.org/t/installer-has-qt-deploy-fixes-but-archive-does-not/7594
**Category:** Code
**Tags:** os:windows, cpack:wix, cpack:archive
**Created:** [March 3, 2023, 8:37am UTC](https://discourse.cmake.org/t/installer-has-qt-deploy-fixes-but-archive-does-not/7594 "2023-03-03T08:37:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![JohnRED](https://discourse.cmake.org/user_avatar/discourse.cmake.org/johnred/32/3220_2.png) [@JohnRED](https://discourse.cmake.org/u/JohnRED)
#### Post date: [March 3, 2023, 8:37am UTC](https://discourse.cmake.org/t/installer-has-qt-deploy-fixes-but-archive-does-not/7594/1 "2023-03-03T08:37:19Z")

</div>

I have a Qt application that runs the deploy command during installation and packaging. This works  
correctly when generating a Wix installer. However, when trying to create an archive, e.g. 7z,  
command is ran but the files placed there do not appear in the archive. Those files do correctly  
appear in the installer.

Below is a small illustration of the CMake file exhibiting this behaviour this is using  
CMake 3.25.2.

The install directory in all cases contains the executable and the file `deployed-files.true`.  
The directory when using the Wix installer contains the executable and the file  
`deployed-files.true`.

The archive file only contains the executable, but does _not_ contain the file `deployed-files.true`.  
Looking at the directory inside `_CPack_Packages` it contains the executable and the file `deployed-files.true`.

What I would expect is that the archive file match the contents found in the `_CPack_Packages`  
directory. So that one could just extract the generated archive and have all files.

```cmake
cmake_minimum_required(VERSION 3.25)
 
project(CMakePackageIssue VERSION 1.0.0 LANGUAGES CXX)
 
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
macro (installAnyQtDependencies componentName destinationDirectory)
    file(GENERATE
        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qt-library-deploy.bat
        CONTENT "@echo off
echo \"Qt Deploy called\" > \"%1\"\\deployed-files.true
exit /b %errorlevel
"
    )
    install(
        CODE "
message(DEBUG \"Running the package command.\")
execute_process(
    COMMAND \"${CMAKE_CURRENT_BINARY_DIR}/qt-library-deploy.bat\" \"${CMAKE_INSTALL_PREFIX}/${destinationDirectory}\"
    COMMAND_ERROR_IS_FATAL ANY
)
"
        COMPONENT ${componentName}
    )
endmacro()
 
add_executable(CMakePackageIssue main.cpp)
 
install(TARGETS CMakePackageIssue)
 
installAnyQtDependencies(${PROJECT_NAME} ".")
 
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_VERBATIM_VARIABLES TRUE)
 
option(
    PACKAGE_ONLY
    "A flag to enable only archive packaging."
    OFF
)
 
if (PACKAGE_ONLY)
    set(CPACK_GENERATOR "7Z")
else ()
    set(CPACK_GENERATOR "WIX")
endif ()
 
 
file(GENERATE
    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/package.cmake
    CONTENT "
execute_process(
    COMMAND \"${CMAKE_CURRENT_BINARY_DIR}/qt-library-deploy.bat\" \"${CMAKE_BINARY_DIR}/_CPack_Packages/win64/${CPACK_GENERATOR}/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}-win64/Unspecified\"
    COMMAND_ERROR_IS_FATAL ANY
)
"
    )
 
list(APPEND CPACK_PRE_BUILD_SCRIPTS "${CMAKE_BINARY_DIR}/package.cmake")
include(CPack)

```

---

<div class="post-metadata">

### Author: ![JohnRED](https://discourse.cmake.org/user_avatar/discourse.cmake.org/johnred/32/3220_2.png) [@JohnRED](https://discourse.cmake.org/u/JohnRED)
#### Post date: [March 6, 2023, 10:08am UTC](https://discourse.cmake.org/t/installer-has-qt-deploy-fixes-but-archive-does-not/7594/2 "2023-03-06T10:08:08Z")

</div>

I have tried using other archive generators, e.g. zip, but it results in the same behaviour.

---

<div class="post-metadata">

### Author: ![oblivioncth](https://discourse.cmake.org/user_avatar/discourse.cmake.org/oblivioncth/32/2362_2.png) [@oblivioncth](https://discourse.cmake.org/u/oblivioncth)
#### Post date: [March 8, 2023, 6:18pm UTC](https://discourse.cmake.org/t/installer-has-qt-deploy-fixes-but-archive-does-not/7594/3 "2023-03-08T18:18:04Z")

</div>

> [@JohnRED](#):
>
> `deployed-files.true`.

While I’m not privy to the inner-workings of CPack to know what is happening here, and agree with you that it seems like that test file should be included in the package, I can at least note that the convenience method for handling Qt dependencies introduced in Qt 6.3 does result in the installed files ending up in the CPack package when using the ZIP generator:

```auto
qt_generate_deploy_app_script(
    TARGET "${_TARGET_NAME}"
    FILENAME_VARIABLE qt_runtime_deploy_script
    NO_UNSUPPORTED_PLATFORM_ERROR
)

install(SCRIPT ${qt_runtime_deploy_script}
    COMPONENT ${_TARGET_NAME}
)

```
