From a5f4b5fce9a3af90e3c1fad02e4e4fa20f8ca1c4 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 | 13 ++++++++++++- cmake/tools/CMakeLists.txt | 3 +++ 3 files changed, 25 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..f8d7ba4f --- /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..c1d6018d 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,15 @@ if (WIN32) endif (CMAKE_BUILD_TOOL STREQUAL "nmake") endif (MINGW) ENDMACRO (addExplorerWrapper) + + MACRO (add_win32_manifest _source) + # set uiaccess to false in manifest + file(READ ${CMAKE_SOURCE_DIR}/modules/Win32.Manifest.in _tmp) + string(REPLACE "true" "false" _out ${_tmp}) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_source}.manifest ${_out}) + # create rc file + # 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_CURRENT_BINARY_DIR}/${_source}.manifest\"\n") + list(APPEND ${_source} ${CMAKE_CURRENT_BINARY_DIR}/${_source}.rc) + ENDMACRO (add_win32_manifest) endif(WIN32) diff --git a/cmake/tools/CMakeLists.txt b/cmake/tools/CMakeLists.txt index 8b3de0c9..31ec8917 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) + add_win32_manifest(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