您如何从Visual Studio中运行cpack? [英] How do you run cpack from visual studio?

查看:105
本文介绍了您如何从Visual Studio中运行cpack?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一些软件包从Linux移植到Windows,我发现Visual Studio与cmake具有很好的集成. 我可以使用cmake来配置和构建项目,但是 我无法弄清楚如何运行cpack来创建安装包 .

I am porting some packages from Linux to windows and I've found that visual studio has quite good integration with cmake. I am able to configure and build the project using cmake but I cannot figure out how to run cpack to create the installation package.

此问题-如何创建Windows上具有CMake + CPack + NSIS的安装程序?-建议在构建过程中创建一个 PACKAGE.vcxproj 文件.是的,但是似乎没有从Visual Studio内部构建/运行它的方法

This question - How to create an installer with CMake + CPack + NSIS on Windows? - suggests that a PACKAGE.vcxproj file should be created by the build. It is but there doesn't appear to be anyway to build/run it from inside visual studio

这似乎是一个奇怪的疏忽,因为:

It seems a strange oversight as:

  • cmake集成非常好
  • ctest测试可以通过测试"菜单运行
  • 可以通过构建菜单运行安装目标 但是没有菜单选项可以使用cpack创建软件包.
  • cmake integration is very good
  • ctest tests can be run via the tests menu
  • the install target can be run via the build menu but there is no menu option to create packages with cpack.

请注意,我正在尝试创建ZIP或TGZ包,并且此时不需要NSIS的额外复杂性. 我正在使用VS2019

Note I am trying to create ZIP or TGZ package and don't need the extra complication of NSIS at this time. I am using VS2019

推荐答案

我想出的最好的解决方案是您不能-至少不能直接这样做.更开明的人可能知道得更多,因为这确实确实是一个奇怪的疏忽.

The best solution I've come up with is you can't - at least not directly. Someone more enlightened may know better because it does indeed seem a strange oversight.

如果从工具/开发人员命令提示符下打开命令提示符 您可以从那里手动运行cpack.

If you open a commmand prompt from tools/developer command prompt you can run cpack manually from there.

另一个重要的一点是,不应在Windows上设置CPACK_PACKAGING_INSTALL_PREFIX. 参见 https://gitlab.kitware.com/cmake/cmake/issues/17534

Another important point is that CPACK_PACKAGING_INSTALL_PREFIX should not be set on Windows. See https://gitlab.kitware.com/cmake/cmake/issues/17534

您可以通过将一个或多个自定义目标添加到您的 CMakeLists.txt 中来进行改进,该目标将显示在 https://cmake.org/pipermail/cmake/2017 -January/064830.html )添加:

You can improve on this by adding a custom target (or targets) to your CMakeLists.txt which will be visible in the targets view. For example (base on https://cmake.org/pipermail/cmake/2017-January/064830.html) add:

SET( CPACK_OUTPUT_CONFIG_FILE "${CMAKE_BINARY_DIR}/BundleConfig.cmake" )
ADD_CUSTOM_TARGET( bundle
         COMMAND "${CMAKE_CPACK_COMMAND}"
                 "-C" "$<CONFIGURATION>"
            "--config" "${CMAKE_BINARY_DIR}/BundleConfig.cmake"
            COMMENT "Running CPack. Please wait..."
            DEPENDS ${PROJECT_NAME} doxygen)

在我看来,安装包中包含的Doxygen文档是一个额外的依赖项.

Doxygen documentation to be included in the install package is an extra dependency in my case.

这篇关于您如何从Visual Studio中运行cpack?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆