首页 > 解决方案 > How to with CPack generate the WIX package?

问题描述

I used cmake 3.12.0. There are exists one cmake project that creates one console application. I add the ability of package generation to that cmake project:

# ... above cmake code for one console application creation
# below code that I add:

# pack
set (A_PACK_DESCRIPTION_SUMMARY "${PROJECT_NAME} - CMake Assistant Solution")
set (A_INSTALL_PREFIX Consolas)

set(CPACK_WIX_PRODUCT_GUID "F9AAAAE2-D6AF-4EA4-BF46-B3E265400CC8") 
set(CPACK_WIX_UPGRADE_GUID "F9AAAAE2-D6AF-4EA4-BF46-B3E265400CC7")

set(CPACK_GENERATOR "WIX")

include(CPack)

With other generators (NSIS, 7Z, ZIP, DEB) all works fine but with WIX appears followed error:

...path\files.wxs(11) : error LGHT0091 : Duplicate symbol 'Component:CM_C_EMPTY_INSTALL_ROOT' found. This typically means that an Id is duplicated. Check to make sure all your identifiers of a given type (File, Component, Feature) are unique.

Why it happens and how to fix it?

标签: cmakewixinstallationpackagingcpack

解决方案


This appears to be caused by this bug

Basically you use add_subdirectory(xxx EXCLUDE_FROM_ALL) where the subdirectory has a install(... COMPONENT ...) call. The installed files are excluded from the subdirectory, but still creates COMPONENTs, which are now empty and break wix.

As a workaround, you can add:

set(CPACK_COMPONENTS_ALL Unspecified)

in CMakeLists.txt to exclude all the empty components.


推荐阅读