• <tfoot id='Bwz6R'></tfoot>

    <small id='Bwz6R'></small><noframes id='Bwz6R'>

    • <bdo id='Bwz6R'></bdo><ul id='Bwz6R'></ul>
  • <legend id='Bwz6R'><style id='Bwz6R'><dir id='Bwz6R'><q id='Bwz6R'></q></dir></style></legend>

    1. <i id='Bwz6R'><tr id='Bwz6R'><dt id='Bwz6R'><q id='Bwz6R'><span id='Bwz6R'><b id='Bwz6R'><form id='Bwz6R'><ins id='Bwz6R'></ins><ul id='Bwz6R'></ul><sub id='Bwz6R'></sub></form><legend id='Bwz6R'></legend><bdo id='Bwz6R'><pre id='Bwz6R'><center id='Bwz6R'></center></pre></bdo></b><th id='Bwz6R'></th></span></q></dt></tr></i><div id='Bwz6R'><tfoot id='Bwz6R'></tfoot><dl id='Bwz6R'><fieldset id='Bwz6R'></fieldset></dl></div>
      1. 如何在 Windows 上使用 CMake + CPack + NSIS 创建安装程序?

        时间:2023-06-30
      2. <tfoot id='DmDf9'></tfoot>

          <small id='DmDf9'></small><noframes id='DmDf9'>

          <legend id='DmDf9'><style id='DmDf9'><dir id='DmDf9'><q id='DmDf9'></q></dir></style></legend>
                <bdo id='DmDf9'></bdo><ul id='DmDf9'></ul>

                1. <i id='DmDf9'><tr id='DmDf9'><dt id='DmDf9'><q id='DmDf9'><span id='DmDf9'><b id='DmDf9'><form id='DmDf9'><ins id='DmDf9'></ins><ul id='DmDf9'></ul><sub id='DmDf9'></sub></form><legend id='DmDf9'></legend><bdo id='DmDf9'><pre id='DmDf9'><center id='DmDf9'></center></pre></bdo></b><th id='DmDf9'></th></span></q></dt></tr></i><div id='DmDf9'><tfoot id='DmDf9'></tfoot><dl id='DmDf9'><fieldset id='DmDf9'></fieldset></dl></div>
                    <tbody id='DmDf9'></tbody>

                2. 本文介绍了如何在 Windows 上使用 CMake + CPack + NSIS 创建安装程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想为我正在构建的基于 C++ 的系统创建一个跨平台安装程序.

                  I'd like to create a cross-platform installer for a C++ based system I am building.

                  我使用 CMake 来构建所有东西,如果我可以使用 CPack 来制作安装程序就太好了.我已经在 OSX 上使用了 CPack,但我无法让它在 Windows 上工作.为了让事情更容易,我尝试在 http://www.cmake.org/Wiki 上获取示例/CMake:Packaging_With_CPack 使用 NSIS 安装程序软件.配置后我在任何地方都找不到 NSIS 安装程序(使用 VS 2010 Win64 生成器).

                  I use CMake to build everything, and it would be great if I could use CPack to make the installer. I already have CPack working on OSX, but I cannot get it to work on Windows. To make things easier, I tried to get the example at http://www.cmake.org/Wiki/CMake:Packaging_With_CPack to work with the NSIS installer software. I cannot find the NSIS installer anywhere after configuring (with VS 2010 Win64 generator).

                  也许我很困惑,但我认为可以创建仅包含源代码、CMake、CPack 和 NSIS 的安装包,而无需任何 Visual Studio.这可能吗?

                  Maybe I am confused, but I thought it would be possible to create the installation package with only the source, CMake, CPack, and NSIS without any need for Visual Studio. Is this possible?

                  完整教程的链接(http://www.cmake.org/Wiki/CMake:Component_Install_With_CPack 跳过了相关信息以使 NSIS 工作并且没有提到生成器或编译器)将非常有帮助,或者对我如何获得这个神话般的生成 NSIS 安装程序的基本解释会很棒.

                  A link to a full tutorial (the one at http://www.cmake.org/Wiki/CMake:Component_Install_With_CPack skips over the relevant information to get NSIS working and doesn't mention generators or compilers) would be very helpful, or a basic explanation of how I can get to this mythical generated NSIS installer would be great.

                  这里是上面例子的 CMakeLists.txt:

                  Here is CMakeLists.txt for the example above:

                  cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
                  project(StPMS)
                  
                  add_library(mylib mylib.cpp)
                  
                  add_executable(mylibapp mylibapp.cpp)
                  target_link_libraries(mylibapp mylib)
                  
                   install(TARGETS mylib 
                     ARCHIVE
                     DESTINATION lib
                     COMPONENT libraries)
                   install(TARGETS mylibapp
                     RUNTIME
                     DESTINATION bin
                     COMPONENT applications)
                   install(FILES mylib.h
                     DESTINATION include
                     COMPONENT headers)
                  
                  set(CPACK_GENERATOR NSIS)
                  set(CPACK_PACKAGE_NAME "MyLib")
                  set(CPACK_PACKAGE_VENDOR "CMake.org")
                  set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyLib - CPack Component Installation Example")
                  set(CPACK_PACKAGE_VERSION "1.0.0")
                  set(CPACK_PACKAGE_VERSION_MAJOR "1")
                  set(CPACK_PACKAGE_VERSION_MINOR "0")
                  set(CPACK_PACKAGE_VERSION_PATCH "0")
                  set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example")
                  SET(CPACK_NSIS_MODIFY_PATH ON)
                  
                  INCLUDE(CPack)
                  

                  推荐答案

                  ... 我认为可以只使用源代码、CMake、CPack 和 NSIS 来创建安装包,而无需任何 Visual Studio.这可能吗?

                  ... I thought it would be possible to create the installation package with only the source, CMake, CPack, and NSIS without any need for Visual Studio. Is this possible?

                  有点.这取决于您所说的不需要 Visual Studio"是什么意思.您需要一个构建工具来实际创建 lib 和 exe.在 Windows 上,您需要类似 Visual Studio 的 msbuild,尤其是当您指定 "Visual Studio 10 Win64" 作为生成器时.

                  Kind of. It depends on what you mean by "without any need for Visual Studio". You need a build tool to actually create the lib and exe. On Windows, you need something like Visual Studio's msbuild, especially if you specified "Visual Studio 10 Win64" as the generator.

                  如果您的意思是不运行 Visual Studio",那么答案是肯定的.您可以使用 让 CMake 执行您选择的构建工具--build 参数.

                  If you mean "without running Visual Studio", then the answer is yes. You can have CMake execute your chosen build tool using the --build argument.

                  运行 CMake 后,您最终会在构建目录中得到一个文件 PACKAGE.vcxproj.它正在构建这将创建安装程序.您可以从 Visual Studio 内部构建 PACKAGE 项目,也可以通过执行以下操作直接调用 msbuild:

                  After running CMake, you end up with a file PACKAGE.vcxproj in your build directory. It is building this which will create the installer. You can either build the PACKAGE project from inside Visual Studio, or you can invoke msbuild directly by doing:

                  msbuild /P:Configuration=Release PACKAGE.vcxproj
                  

                  从 VS 命令提示符中的构建目录.

                  from your build directory in a VS command prompt.

                  这应该会生成名为 MyLib-1.0.0-win64.exe 的安装程序,也在您的构建目录中.

                  This should yield your installer named MyLib-1.0.0-win64.exe, also in your build directory.


                  如果您只想使用 CMake,那么调用 msbuild 的替代方法是:


                  If you want to just use CMake, then an alternative to invoking msbuild is:

                  cmake --build . --target PACKAGE.vcxproj --config Release
                  


                  或者您可以先构建解决方案,然后调用 CPack 来创建安装程序:


                  Or you can build the solution first, then invoke CPack to create the installer:

                  cmake --build . --config Release
                  cpack -C Release
                  

                  这篇关于如何在 Windows 上使用 CMake + CPack + NSIS 创建安装程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Windows 10 上安装 C++ tesseract 下一篇:如何将包含时间的字符串变量转换为 C++ 中的 time_t 类型?

                  相关文章

                    <bdo id='RSHsA'></bdo><ul id='RSHsA'></ul>

                  <small id='RSHsA'></small><noframes id='RSHsA'>

                  <i id='RSHsA'><tr id='RSHsA'><dt id='RSHsA'><q id='RSHsA'><span id='RSHsA'><b id='RSHsA'><form id='RSHsA'><ins id='RSHsA'></ins><ul id='RSHsA'></ul><sub id='RSHsA'></sub></form><legend id='RSHsA'></legend><bdo id='RSHsA'><pre id='RSHsA'><center id='RSHsA'></center></pre></bdo></b><th id='RSHsA'></th></span></q></dt></tr></i><div id='RSHsA'><tfoot id='RSHsA'></tfoot><dl id='RSHsA'><fieldset id='RSHsA'></fieldset></dl></div>

                3. <tfoot id='RSHsA'></tfoot>

                4. <legend id='RSHsA'><style id='RSHsA'><dir id='RSHsA'><q id='RSHsA'></q></dir></style></legend>