From 1f30275281d3e3d85fa9cc0686e80f3df12888f4 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 6 Sep 2017 13:17:57 +0200 Subject: [PATCH] Do not let dbus-update-activation-environment.exe be catched by UAC on Windows --- cmake/modules/Win32.Manifest.in | 10 ++++++++++ cmake/modules/Win32Macros.cmake | 26 +++++++++++++++++++++++++- cmake/tools/CMakeLists.txt | 3 +++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 cmake/modules/Win32.Manifest.in diff --git a/cmake/modules/Win32.Manifest.in b/cmake/modules/Win32.Manifest.in new file mode 100644 index 00000000..63dce3b5 --- /dev/null +++ b/cmake/modules/Win32.Manifest.in @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/cmake/modules/Win32Macros.cmake b/cmake/modules/Win32Macros.cmake index 4385cc97..0846c748 100644 --- a/cmake/modules/Win32Macros.cmake +++ b/cmake/modules/Win32Macros.cmake @@ -1,7 +1,7 @@ # # win32 macros # -# Copyright (c) 2006-2007, Ralf Habacker +# Copyright (c) 2006-2017, Ralf Habacker # # Redistribution and use is allowed according to the terms of the BSD license. # @@ -41,4 +41,28 @@ if (WIN32) endif (CMAKE_BUILD_TOOL STREQUAL "nmake") endif (MINGW) ENDMACRO (addExplorerWrapper) + + # + # Set execution level for a target to 'asInvoker' + # + # Syntax: + # set_execution_level_as_invoker(_source) + # + # @param _source name of source list for a given target + # + # Example: + # set (SOURCE test.c) + # set_execution_level_as_invoker(SOURCE) + # add_executable(atarget, ${SOURCE}) + # + MACRO (set_execution_level_as_invoker _source) + # create rc file + # 1 is the resource ID, ID_MANIFEST + # 24 is the resource type, RT_MANIFEST + # constants are used because of a bug in windres + # see https://stackoverflow.com/questions/33000158/embed-manifest-file-to-require-administrator-execution-level-with-mingw32 + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_source}.rc "1 24 \"${CMAKE_SOURCE_DIR}/modules/Win32.Manifest.in\"\n") + # add to source list + list(APPEND ${_source} ${CMAKE_CURRENT_BINARY_DIR}/${_source}.rc) + ENDMACRO (set_execution_level_as_invoker) endif(WIN32) diff --git a/cmake/tools/CMakeLists.txt b/cmake/tools/CMakeLists.txt index 8b3de0c9..6c721005 100644 --- a/cmake/tools/CMakeLists.txt +++ b/cmake/tools/CMakeLists.txt @@ -62,6 +62,9 @@ add_executable(dbus-test-tool ${dbus_test_tool_SOURCES}) target_link_libraries(dbus-test-tool ${DBUS_LIBRARIES}) install(TARGETS dbus-test-tool ${INSTALL_TARGETS_DEFAULT_ARGS}) +if(WIN32) + set_execution_level_as_invoker(dbus_update_activation_environment_SOURCES) +endif() add_executable(dbus-update-activation-environment ${dbus_update_activation_environment_SOURCES}) target_link_libraries(dbus-update-activation-environment ${DBUS_LIBRARIES}) install(TARGETS dbus-update-activation-environment ${INSTALL_TARGETS_DEFAULT_ARGS}) -- 2.12.3