CMake 设置 Application Icon
Posted theArcticOcean
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CMake 设置 Application Icon相关的知识,希望对你有一定的参考价值。
For Windows
增添rc文件到工程中。
add file:
Source/myapp.rc
包含内容:
IDI_ICON1 ICON DISCARDABLE "Images/logo.ico"
他指明了图标文件的路径。
然后将这份rc文件添加到CMakeLists.txt中:
file( GLOB SourceFiles Source/*.cpp Source/myapp.rc )
add_executable(
$PROJECT_NAME
MACOSX_BUNDLE
$SourceFiles
$HeaderFiles
$ResourceFiles
$UISrcs
)
For Mac OS X
在CMakeLists.txt中指明图标文件的路径,然后添加到executable 的依赖文件列表中
# CMAKE_AUTOMOC in ON so the MOC headers will be automatically wrapped.
set( CMAKE_AUTOMOC ON )
# NOTE: Don't include the path in MACOSX_BUNDLE_ICON_FILE -- this is
# the property added to Info.plist
# <key>CFBundleIconFile</key>
# <string>logo</string>
set(MACOSX_BUNDLE_ICON_FILE logo)
# And this part tells CMake where to find and install the file itself
set(myApp_ICON $CMAKE_CURRENT_SOURCE_DIR/Images/logo.icns)
# set_source_files_properties would create Resources folder to store icns
# The folder is at same path where Info.plist located
set_source_files_properties($myApp_ICON PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
add_executable(
$PROJECT_NAME
MACOSX_BUNDLE
$SourceFiles
$HeaderFiles
$ResourceFiles
$UISrcs
$myApp_ICON # Add icon file to see in IDE.
)
以上是关于CMake 设置 Application Icon的主要内容,如果未能解决你的问题,请参考以下文章
怎样实现android Application的icon图标动态变化?