diff --git a/CommonConfig.cmake b/CommonConfig.cmake index 33982e2..deec0ba 100644 --- a/CommonConfig.cmake +++ b/CommonConfig.cmake @@ -125,3 +125,4 @@ include(Doxygen) # Generate information (name, description, version, etc.) for applications and libraries include(GetGitRevisionDescription) include(AddResourceInfo) +include(manifest/AddManifest) diff --git a/manifest/AddManifest.cmake b/manifest/AddManifest.cmake new file mode 100644 index 0000000..a1c22a8 --- /dev/null +++ b/manifest/AddManifest.cmake @@ -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 $) + + 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 diff --git a/manifest/dll.manifest.in b/manifest/dll.manifest.in new file mode 100644 index 0000000..9552504 --- /dev/null +++ b/manifest/dll.manifest.in @@ -0,0 +1,2 @@ + + diff --git a/manifest/exe.manifest.in b/manifest/exe.manifest.in new file mode 100644 index 0000000..6e15cd6 --- /dev/null +++ b/manifest/exe.manifest.in @@ -0,0 +1,9 @@ + + + + + + + + +