# CPack \`REQUIRED\` in \`cpack\_add\_component\` is not working as intended with WiX

**URL:** https://discourse.cmake.org/t/cpack-required-in-cpack-add-component-is-not-working-as-intended-with-wix/15074
**Category:** Usage
**Tags:** os:windows, cpack:wix
**Created:** [August 19, 2025, 11:20pm UTC](https://discourse.cmake.org/t/cpack-required-in-cpack-add-component-is-not-working-as-intended-with-wix/15074 "2025-08-19T23:20:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alina](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@alina](https://discourse.cmake.org/u/alina)
#### Post date: [August 19, 2025, 11:20pm UTC](https://discourse.cmake.org/t/cpack-required-in-cpack-add-component-is-not-working-as-intended-with-wix/15074/1 "2025-08-19T23:20:04Z")

</div>

I am passing keyword `REQUIRED` to `cpack_add_component`, but the component `my_lib` still shows as optional with the WiX msi installer, meaning the user can still select “feature will be installed when required,” and selecting this option causes the component to not get installed. The same `cpack_add_component` command works as intended with NSIS installer generator on CPack. Adding `set(CPACK_COMPONENT_MY_LIB_REQUIRED TRUE)` before `include(CPack)` also doesn’t help with this issue.

I am able to reproduce the same issue with WiX toolset v6, v5, and v4. I would like to use `CPACK_WIX_VERSION 4` instead of version 3. I have not tested with WiX v3.11.

Could someone please tell me what am I missing here, and could this be a bug with CPack WiX integration?

A snippet of my CMakeLists.txt for reproduction

```auto
  if(WIN32)
    set(CPACK_GENERATOR "WIX")
    set(CPACK_WIX_VERSION 4)
    set(CPACK_WIX_UPGRADE_GUID "<real-guid-redacted>")
  endif()
  include(CPack)
  cpack_add_component(my_lib
                      REQUIRED
                      DISPLAY_NAME "My Library"
                      DESCRIPTION "Library bin, required to install")

```

---

<div class="post-metadata">

### Author: ![alina](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@alina](https://discourse.cmake.org/u/alina)
#### Post date: [August 19, 2025, 11:20pm UTC](https://discourse.cmake.org/t/cpack-required-in-cpack-add-component-is-not-working-as-intended-with-wix/15074/2 "2025-08-19T23:20:49Z")

</div>

Feel free to comment if you have faced the same issue!
