Created
November 23, 2019 19:55
-
-
Save Niakr1s/749a88643e154320768e5972c80347cb to your computer and use it in GitHub Desktop.
How to add icon to cmake app in windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Put app.ico in directory. | |
2. Create app.rc in same directory with one line: | |
IDI_ICON1 ICON DISCARDABLE "app.ico" | |
3. Run command (Warning: it's app.o, not app.res, how it is mentioned in other manuals!) | |
windres app.rc -o app.o | |
4. add_executable(app | |
... | |
app.o | |
) | |
5. Proofit! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This post is incorrect. The Doc identify option /fo resname for anyone using cmake here is a snippet that generates the .RES script form RC compilation. Also make sure the resource.h file include windows.h header file .
adds a custom build step to a file. Generates the resources
add_custom_command(
TARGET LibTransactX
PRE_BUILD
DEPENDS RC
COMMAND RC /v /r ${CMAKE_SOURCE_DIR}/res/app.rc
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/res"
COMMENT "Build step to produce the icon file"
)