CMake RequireAdministrator
Asked Answered
T

5

7

I'm trying to set the RequireAdministrator manifest flag on an executable I'm building with CMake and Visual Studio.

Any ideas on how to direct CMake to set that option?

Thanks!

Billy3

Triune answered 31/10, 2009 at 17:53 Comment(0)
K
10

try this:

SET_TARGET_PROPERTIES(your_executable PROPERTIES LINK_FLAGS    "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS")
Kenneth answered 31/10, 2009 at 19:36 Comment(2)
Works so long as remove /SUBSYSTEM:Windows ... it's a console app :)Triune
Note that these manifest settings don't seem to show up in the project properties, but they do appear in the intermediate manifest. And they are recorded in the .vcproj file. (This is with VS2008).Brena
G
13

I appreciate that the question is tagged visual-studio-2008, but for VS2010 this produces the following error message:

error MSB4030: "level='requireAdministrator' uiAccess='false'" is an invalid value for the "UACUIAccess" parameter of the "Link" task. The "UACUIAccess" parameter is of type "System.Boolean".

An equivalent CMake command (disregarding the /SUBSYSTEM:WINDOWS portion) for VS2010 is

SET_TARGET_PROPERTIES(your_executable PROPERTIES LINK_FLAGS "/level='requireAdministrator' /uiAccess='false'")
Grit answered 30/1, 2012 at 20:25 Comment(0)
K
10

try this:

SET_TARGET_PROPERTIES(your_executable PROPERTIES LINK_FLAGS    "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS")
Kenneth answered 31/10, 2009 at 19:36 Comment(2)
Works so long as remove /SUBSYSTEM:Windows ... it's a console app :)Triune
Note that these manifest settings don't seem to show up in the project properties, but they do appear in the intermediate manifest. And they are recorded in the .vcproj file. (This is with VS2008).Brena
T
1

If it is a console app, you need to remove the "/SUBSYSTEM:WINDOWS".

try this:

set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS " /MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" ")
Thema answered 23/6, 2021 at 2:56 Comment(0)
B
0

With cmake 3.24.2 it works well with:

target_link_options(<target name> PRIVATE "/MANIFESTUAC:level='requireAdministrator'" PRIVATE "/MANIFESTUAC:uiAccess='false'")
Bureaucratic answered 6/12, 2022 at 23:24 Comment(0)
A
0

Building on what Fraser said, the command that worked for me in cmake 3.9.1 and Visual Studio 10 is:

SET_TARGET_PROPERTIES(your_executable PROPERTIES LINK_FLAGS "/MANIFESTUAC: /level='requireAdministrator' /uiAccess='false'")
Anfractuosity answered 10/10, 2023 at 21:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.