Skip to content
This repository has been archived by the owner on Aug 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #59 from frederikvannoote/feature/addManifest
Browse files Browse the repository at this point in the history
Added manifest functionality.
  • Loading branch information
frederikvannoote authored Aug 17, 2018
2 parents 9ab8f76 + f5de07c commit 8e54cff
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions CommonConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,4 @@ include(Doxygen)
# Generate information (name, description, version, etc.) for applications and libraries
include(GetGitRevisionDescription)
include(AddResourceInfo)
include(manifest/AddManifest)
43 changes: 43 additions & 0 deletions manifest/AddManifest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Add manifest: executables may require administrative privileges.

macro(add_manifest PROJECT TYPE)
if(CMAKE_BUILD_TYPE MATCHES Release)
if(WIN32 AND NOT UNIX)
# Search for the mt binary
find_program(MT_TOOL NAMES mt PATHS "C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin/" "C:/Program Files (x86)/Windows Kits/8.1/bin/x86")
# Get the full output name for the target
set(OUTPUT_FILE_PATH $<TARGET_FILE:${PROJECT}>)

if(MT_TOOL)
# select type
if(${TYPE} STREQUAL "LIB" OR ${TYPE} STREQUAL "QMLLIB")
set(MANIFEST_FILE_IN ${CMAKE_CURRENT_LIST_DIR}/dll.manifest.in)
set(MANIFEST_FILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.dll.manifest)
elseif(${TYPE} STREQUAL "BIN")
set(MANIFEST_FILE_IN ${CMAKE_CURRENT_LIST_DIR}/exe.manifest.in)
set(MANIFEST_FILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.exe.manifest)
endif()

# fill in the appropriate information into dll.manifest
configure_file(${MANIFEST_FILE_IN} ${MANIFEST_FILE_OUT})

add_custom_command(
TARGET ${PROJECT}
POST_BUILD
COMMAND ${MT_TOOL} -manifest ${MANIFEST_FILE_OUT} -outputresource:${OUTPUT_FILE_PATH};#1
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIRs}
DEPENDS ${MANIFEST_FILE_OUT}
)

# return info
message(STATUS "Prepared embedded manifest for ${PROJECT_NAME} of type ${TYPE}")

else()
message(SEND_ERROR "Manifest creation of ${PROJECT} failed")
endif()
endif(WIN32 AND NOT UNIX)
endif(CMAKE_BUILD_TYPE MATCHES Release)
endmacro()

# More info:
# http://blogs.msdn.com/b/cheller/archive/2006/08/24/how-to-embed-a-manifest-in-an-assembly-let-me-count-the-ways.aspx
2 changes: 2 additions & 0 deletions manifest/dll.manifest.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
</assembly>
9 changes: 9 additions & 0 deletions manifest/exe.manifest.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

0 comments on commit 8e54cff

Please sign in to comment.