使用cmake环境安装Mac OS X应用程序,我想在安装过程中设置并安装图标.
因此,我尝试设置
set( MACOSX_BUNDLE_ICON_FILE ${CMAKE_CURRENT_SOURCE_DIR}/images/myAopImage.icns )
ADD_EXECUTABLE(MYAPP MACOSX_BUNDLE ${MACOSX_BUNDLE_ICON_FILE} ${allSources})
#(I could set it in the source directory to any other path)
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用,它将完整路径写入Info.plist,并且不在Resources目录中安装任何内容(资源目录甚至不会在安装的app文件夹中创建)
无论如何,即使我手工将信息放入Info.plist中
<key>CFBundleIconFile</key>
<string>myAppImage.icns</string>
Run Code Online (Sandbox Code Playgroud)
手动创建Resources目录,放入icns文件,
该图标无论如何都会出现在应用中.
我该如何解决这个问题?起初可能是手工完成,但也在cmake上下文中?
Zra*_*rax 11
从CMake中捆绑.icns文件有两个部分:添加源文件本身,并在.plist中配置它.如果要指定.icns文件的路径(例如,因为它位于子目录中),那么这两个属性将稍微不同地引用.icns文件:
# NOTE: Don't include the path in MACOSX_BUNDLE_ICON_FILE -- this is
# the property added to Info.plist
set(MACOSX_BUNDLE_ICON_FILE myAppImage.icns)
# And this part tells CMake where to find and install the file itself
set(myApp_ICON ${CMAKE_CURRENT_SOURCE_DIR}/images/myAppImage.icns)
set_source_files_properties(${myApp_ICON} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
add_executable(myApp MACOSX_BUNDLE ${myApp_ICON} ${allSources})
Run Code Online (Sandbox Code Playgroud)
要将icns文件复制到Resources文件夹,需要在其上设置source属性.
set_source_files_properties(myAppImage.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
Run Code Online (Sandbox Code Playgroud)
另外,我读到某个地方,plist中的字符串不需要.icns,所以
<string>myAppImage</string>
Run Code Online (Sandbox Code Playgroud)
应该没事.
| 归档时间: |
|
| 查看次数: |
4776 次 |
| 最近记录: |