如何通过CMake/CPack在NSIS中设置向导图像?

发布于 2024-11-07 20:54:47 字数 427 浏览 3 评论 0原文

我发现 NSIS 中没有用于更改向导图像的 CPACK_xxx 变量(如 CPACK_PACKAGE_ICON)。 所以我复制了NSIS.template.in并修改了它。我可以这样做:

!define MUI_WELCOMEFINISHPAGE_BITMAP "C:\work\project\img\wizardInstall.bmp" !define MUI_UNWELCOMEFINISHPAGE_BITMAP "C:\work\project\img\wizardUninstall.bmp"

就可以了。然而,源代码位于许多开发人员协作的存储库中,在那里保留绝对路径并不是一个好主意。 我试图找到某种方法来获取我的源路径,并以某种方式从该路径创建图像路径,但无济于事。

因此,如果有人知道如何在 NSIS 中设置向导图像,或将源目录(并从中创建路径)传递到我的模板文件,请告诉我。

I see that there is no CPACK_xxx variable for changing the wizard image(s) in NSIS (like CPACK_PACKAGE_ICON).
So I copied the NSIS.template.in and modified it. I could do something like:

!define MUI_WELCOMEFINISHPAGE_BITMAP "C:\work\project\img\wizardInstall.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "C:\work\project\img\wizardUninstall.bmp"

and it will work. However, the source code goes in a repository where many developers colaborate, and it's not really good idea to keep absolute paths there.
I tried to find some way to get my source path, and somehow create the image path from that one, but to no avail.

So, if someone knows how can i set the wizard images in NSIS, or pass the source dir (and create the path from it) to my template file, please let me know.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一个人的旅程 2024-11-14 20:54:47

由于您已经自定义了 NSIS.template.in 文件,并且它是一个大概使用 CONFIGURE_FILE() 命令配置的模板,为什么不将以下内容放入您的 NSIS.template.in 中:

!define MUI_WELCOMEFINISHPAGE_BITMAP "@MY_CPACK_MUI_WELCOMEFINISHPAGE_BITMAP@"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "@MY_CPACK_MUI_UNWELCOMEFINISHPAGE_BITMAP@"

然后,在您的 CMakeLists.txt 文件中,其中设置其他 CPACK 变量,添加如下内容:

SET(MY_CPACK_MUI_WELCOMEFINISHPAGE_BITMAP
    "${CMAKE_SOURCE_DIR)/path/to/wizardInstall.bmp")
SET(MY_CPACK_MUI_UNWELCOMEFINISHPAGE_BITMAP
    "${CMAKE_SOURCE_DIR)/path/to/wizardUninstall.bmp")

Since you are already customizing the NSIS.template.in file, and it is a template presumably configured with the CONFIGURE_FILE() command, why not put the following in to your NSIS.template.in:

!define MUI_WELCOMEFINISHPAGE_BITMAP "@MY_CPACK_MUI_WELCOMEFINISHPAGE_BITMAP@"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "@MY_CPACK_MUI_UNWELCOMEFINISHPAGE_BITMAP@"

Then, in your CMakeLists.txt file where you set your other CPACK variables, add something like:

SET(MY_CPACK_MUI_WELCOMEFINISHPAGE_BITMAP
    "${CMAKE_SOURCE_DIR)/path/to/wizardInstall.bmp")
SET(MY_CPACK_MUI_UNWELCOMEFINISHPAGE_BITMAP
    "${CMAKE_SOURCE_DIR)/path/to/wizardUninstall.bmp")
感情洁癖 2024-11-14 20:54:47

您不需要编译整个 NSIS 来使用/更改这些图像。

它们存在于每台安装了 NSIS 的计算机上 ${NSISDIR}\Contrib\Graphics\Wizard\win.bmp

在 .nsi 脚本中使用 !define MUI_WELCOMEFINISHPAGE_BITMAP bmp_file改变他们。

You do not need to compile whole NSIS to use/change these images.

They are present on every machine which has NSIS installed in ${NSISDIR}\Contrib\Graphics\Wizard\win.bmp

Use !define MUI_WELCOMEFINISHPAGE_BITMAP bmp_file in your .nsi script to change them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文