如何在NSIS安装中设置图标(CMake)

时间:2015-02-27 15:20:23

标签: cmake nsis bmp cpack

CPACK_PACKAGE_ICON的文档在cmake wiki page上非常有限。

以下内容对我不起作用(如per):

set(CPACK_PACKAGE_ICON  "${CMAKE_CURRENT_SOURCE_DIR}/images/MyIcon.bmp")
include(CPack)

导致:

File: "C:/proj/my_library/images/MyIcon.bmp" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
   /oname=outfile one_file_only)
Error in macro MUI_HEADERIMAGE_INIT on macroline 24
Error in macro MUI_GUIINIT on macroline 3
Error in macro MUI_FUNCTION_GUIINIT on macroline 4
Error in macro MUI_INSERT on macroline 11
Error in macro MUI_LANGUAGE on macroline 7
Error in script "C:/proj/bin-win/_CPack_Packages/win32/NSIS/project.nsi" on line 574 -- aborting creation process

那么在NSIS安装程序的安装过程中如何实际设置工作图标?图标实际上还需要什么格式?

1 个答案:

答案 0 :(得分:5)

经过一番反复试验后,我终于找到了两个技巧:

语法实际上是:

set(CPACK_PACKAGE_ICON  "${CMAKE_CURRENT_SOURCE_DIR}/images\\\\MyIcon.bmp")

并且BMP文件仅限于旧格式,这不是imagemagick的默认格式。例如:

$ file MyIcon.bmp
MyIcon.bmp: PC bitmap, Windows 98/2000 and newer format, 128 x 128 x 24

需要的是:

$ convert MyIcon.bmp BMP3:MyIcon2.bmp
$ file MyIcon2.bmp
MyIcon2.bmp: PC bitmap, Windows 3.x format, 128 x 128 x 24

第一个表示(Windows 98/2000 and newer format)对我不起作用。