Skip to content

Instantly share code, notes, and snippets.

@bjornblissing
Last active July 30, 2024 22:12
Show Gist options
  • Save bjornblissing/6fc452fe7ec1fdfe3419 to your computer and use it in GitHub Desktop.
Save bjornblissing/6fc452fe7ec1fdfe3419 to your computer and use it in GitHub Desktop.
CMake script to add manifest to exe-file
# Amend manifest to tell Windows that the application is DPI aware (needed for Windows 8.1 and up)
IF (MSVC)
IF (CMAKE_MAJOR_VERSION LESS 3)
MESSAGE(WARNING "CMake version 3.0 or newer is required use build variable TARGET_FILE")
ELSE()
ADD_CUSTOM_COMMAND(
TARGET ${TARGET_TARGETNAME}
POST_BUILD
COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\dpiawarescaleing.manifest\" -inputresource:\"$<TARGET_FILE:${TARGET_TARGETNAME}>\"\;\#1 -outputresource:\"$<TARGET_FILE:${TARGET_TARGETNAME}>\"\;\#1
COMMENT "Adding display aware manifest..."
)
ENDIF()
ENDIF(MSVC)
@bjornblissing
Copy link
Author

bjornblissing commented Oct 13, 2014

If you are amending manifests to DLL-files you will need to change the #1 to #2 in on the following line:
http://gist.github.com/bjornblissing/6fc452fe7ec1fdfe3419#file-cmakemanifest-txt-L9

So the new line would be:
COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\dpiawarescaleing.manifest\" -inputresource:\"$<TARGET_FILE:${TARGET_TARGETNAME}>\"\;\#2 -outputresource:\"$<TARGET_FILE:${TARGET_TARGETNAME}>\"\;\#2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment