CMake系列:WIX打包
Posted 岬淢箫声
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CMake系列:WIX打包相关的知识,希望对你有一定的参考价值。
目录
背景
简化最终用户的安装配置过程,方便最终用户使用。同时保护代码安全,防止人为打包有意无意的错误。
实现方案
下载配置WIX
下载WIX 3.11版本,链接:https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip。设置环境变量WIX311的值为D:\\green-software\\wix-3.11。
启用CPack打包
set(CPACK_PACKAGE_NAME "Test Depploy1 Tool")
set(CPACK_PACKAGE_VENDOR "Test")
set(CPACK_PACKAGE_VERSION $PROJECT_VERSION)
set(CPACK_PACKAGE_ICON $CMAKE_SOURCE_DIR/src/resources/Depploy1.ico)
set(CPACK_PACKAGE_EXECUTABLES "Depploy1" "Test Depploy1")
set(CPACK_CREATE_DESKTOP_LINKS "Depploy1")
if(WIN32)
set(CPACK_GENERATOR WIX)
if(NOT DEFINED ENVWIX311)
message("WIX311 is missing.")
else()
file(TO_CMAKE_PATH $ENVWIX311 WIX311)
set(CPACK_WIX_ROOT $WIX311)
set(CPACK_WIX_ARCHITECTURE x64)
set(CPACK_WIX_PRODUCT_ICON $CMAKE_SOURCE_DIR/src/resources/Depploy1.ico)
# set(CPACK_WIX_PRODUCT_GUID XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)
set(CPACK_WIX_UPGRADE_GUID XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)
set(CPACK_WIX_CULTURES zh-CN)
set(CPACK_WIX_ROOT_FEATURE_TITLE "Depploy1 Installer")
set(CPACK_WIX_PATCH_FILE $CMAKE_SOURCE_DIR/wix-patch.xml)
endif()
elseif(APPLE)
set(CPACK_GENERATOR productbuild)
endif()
set(CPACK_RESOURCE_FILE_LICENSE $CMAKE_SOURCE_DIR/LICENSE.txt)
指定需要安装的文件
- 指定不需要打包的文件,保护代码安装
- 创建开始菜单
install(TARGETS $PROJECT_NAME DESTINATION Depploy1)
install(DIRECTORY $CMAKE_SOURCE_DIR/x64/Depploy1 DESTINATION .
PATTERN *.md EXCLUDE
PATTERN *.pdf EXCLUDE
PATTERN *.docx EXCLUDE
PATTERN *.zip EXCLUDE
PATTERN *.pdb EXCLUDE
PATTERN *.ilk EXCLUDE
PATTERN *.exe EXCLUDE
PATTERN *.exp EXCLUDE
PATTERN *.txt EXCLUDE
PATTERN *.log EXCLUDE
PATTERN *.lib EXCLUDE)
set_property(INSTALL Depploy1/Depploy1.exe PROPERTY CPACK_START_MENU_SHORTCUTS Depploy1)
作者:岬淢箫声
CMake系列:WIX打包_岬淢箫声的博客-CSDN博客https://caowei.blog.csdn.net/article/details/129087498转载请注明来源。
以上是关于CMake系列:WIX打包的主要内容,如果未能解决你的问题,请参考以下文章