MantisBT - CMake
View Issue Details
0011171CMakeCMakepublic2010-08-25 10:122016-06-10 14:31
Steven Taylor 
Bill Hoffman 
normalminoralways
closedmoved 
CMake-2-8 
 
0011171: Visual Studio 10 solution generation is incorrect
I am adding the following to my cmake files to update the manifest with the correct UAC requirements for my exe

SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS" )

But what I see in the generated solution files is
    <Link>
      <AdditionalOptions> /machine:X86 /debug %(AdditionalOptions)</AdditionalOptions>
      <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
      <EnableUAC>true</EnableUAC>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <ImportLibrary>C:/Development/cmake/test/vs/Debug/HelloWorld.lib</ImportLibrary>
      <ProgramDataBaseFileName>C:/Development/cmake/test/vs/Debug/HelloWorld.pdb</ProgramDataBaseFileName>
      <StackReserveSize>10000000</StackReserveSize>
      <SubSystem>Console</SubSystem>
      <UACUIAccess>level='requireAdministrator' uiAccess='false'</UACUIAccess>
      <Version>0.0</Version>
    </Link>

and DevStudio 10 complains about

<UACUIAccess>level='requireAdministrator' uiAccess='false'</UACUIAccess>

What I expected to see was

    <Link>
      <AdditionalOptions>
      </AdditionalOptions>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <EnableUAC>true</EnableUAC>
      <UACUIAccess>false</UACUIAccess>
      <UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
    </Link>

But cannot generate it.

This looks like a bug in the generation code and the only workaround I can see is comment out the MANIFESTUAC entries in the cmVS10LinkFlagTable.h file. Is this a bug or am I missing something?
No tags attached.
related to 0010704closed David Cole don't GenerateManifest flag (/Manifest:NO) doesn't work with VS 2010 
related to 0011216closed David Cole Link with /MANIFEST even /manifest:no was set 
related to 0012566closed Kitware Robot REGRESSION: CMake suppresses /SUBSYSTEM linker flag 
patch Bug-0011171-sub-topic-SUBSYSTEM-WINDOWS-linker-flag.patch (1,769) 2010-10-18 16:03
https://public.kitware.com/Bug/file/3459/Bug-0011171-sub-topic-SUBSYSTEM-WINDOWS-linker-flag.patch
Issue History
2010-08-25 10:12Steven TaylorNew Issue
2010-08-29 12:35Strahinja Markovic Note Added: 0022001
2010-08-29 12:37Strahinja Markovic Note Edited: 0022001
2010-10-05 23:47Denis RotnovNote Added: 0022413
2010-10-10 07:55McBenNote Added: 0022465
2010-10-10 08:09Strahinja Markovic Note Added: 0022466
2010-10-18 09:14abubadabuNote Added: 0022518
2010-10-18 16:03McBenNote Added: 0022527
2010-10-18 16:03McBenFile Added: Bug-0011171-sub-topic-SUBSYSTEM-WINDOWS-linker-flag.patch
2010-11-08 14:30goatboy160Note Added: 0023065
2010-12-15 11:49David ColeAssigned To => Bill Hoffman
2010-12-15 11:49David ColeStatusnew => assigned
2011-02-08 12:16David ColeRelationship addedrelated to 0010704
2011-02-08 12:16David ColeRelationship addedrelated to 0011216
2011-04-14 14:31David ColeTarget Version => CMake 2.8.5
2011-05-25 17:03David ColeNote Added: 0026596
2011-05-25 17:03David ColeTarget VersionCMake 2.8.5 =>
2011-07-20 15:11Timothy St. ClairNote Added: 0027057
2011-08-25 09:01aeNote Added: 0027271
2011-08-25 09:29Bill HoffmanNote Added: 0027272
2011-08-25 11:31David ColeNote Edited: 0027272bug_revision_view_page.php?bugnote_id=27272#r410
2011-11-09 19:42GiliNote Added: 0027740
2011-11-10 11:10David ColeRelationship addedrelated to 0012566
2012-01-30 15:34Fraser HutchisonNote Added: 0028426
2016-06-10 14:28Kitware RobotNote Added: 0041742
2016-06-10 14:28Kitware RobotStatusassigned => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0022001)
Strahinja Markovic    
2010-08-29 12:35   
(edited on: 2010-08-29 12:37)
I have the same issue. I'm trying to pass the "/SUBSYSTEM:WINDOWS" option to the linker using this:

set_target_properties( ${PROJECT_NAME} PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS" )

and it works for NMake makefiles and vs2008 project files, but not for the vs2010 project files. The subsystem stays CONSOLE.

(0022413)
Denis Rotnov   
2010-10-05 23:47   
I have excatly same issue like Steven Taylor.
CMake script

-------------------------------------------------------------------------------
AUX_SOURCE_DIRECTORY(src SRC)
INCLUDE_DIRECTORIES(include)

SET(SRC ${SRC} "res/web-loader.rc")

SET(TARGET_NAME "web-loader")

ADD_EXECUTABLE(${TARGET_NAME} WIN32 ${SRC})

TARGET_LINK_LIBRARIES("${TARGET_NAME}" wininet shlwapi Shell32 comctl32 strsafe)
SET_TARGET_PROPERTIES("${TARGET_NAME}" PROPERTIES LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='true'\"")

-------------------------------------------------------------------------------

As result VS 10 grenerates error
-------------------------------------------------------------------------------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(353,9): error MSB4030: "level='requireAdministrator' uiAccess='true'" is an invalid value for the "UACUIAccess" parameter of the "Link" task. The "UACUIAccess" parameter is of type "System.Boolean".
-------------------------------------------------------------------------------

Is any workaround to avoid this problem?

Thanks
(0022465)
McBen   
2010-10-10 07:55   
@Strahinja Markovic
subsystem is defined by the "WIN32_EXECUTABLE" property.
or quickly by the WIN32 in "ADD_EXECUTABLE(${TARGET_NAME} WIN32 ${SRC})"
(0022466)
Strahinja Markovic    
2010-10-10 08:09   
@McBen Thanks for that. I was told to do it like this a long time ago, and it worked for years. Good to know there's a better way to do it.
(0022518)
abubadabu   
2010-10-18 09:14   
@McBen But this kills the feature for us to do a console app for debug- and a windowed for release-build :(

Before (vs 2005/2008) you could overwrite the WIN32 flag from add_executable by setting the target_properties to subsystem:console.

There is no way to do both:
- ADD_EXECUTABLE_RELEASE(${TARGET_NAME} WIN32 ${SRC})
- ADD_EXECUTABLE_DEBUG(${TARGET_NAME} ${SRC})
(0022527)
McBen   
2010-10-18 16:03   
yes, that's true. But that wasn't requested above.
And I wouldn't do such thinks because I want the debug-version as near as possible to the release version...anyway..I bet you'll have a good reason to do so.

I added a patch for that
(it'll change the order how manual linker flags and WIN32_EXECUTABLE are processed)

BUT: this has nothing to do with the reported bug here !!
(0023065)
goatboy160   
2010-11-08 14:30   
For the execution level I added this to cmVS10LinkFlagTable.h. Not perfect but works.

{"UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
   cmVS7FlagTable::UserValueRequired},
+ {"UACExecutionLevel", "UACEXECUTIONLEVEL:", "Modify Execution Level",
+ "RequireAdministrator",
+ cmVS7FlagTable::UserValueRequired},
  {"GenerateMapFile", "MAP", "", "true",
   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
(0026596)
David Cole   
2011-05-25 17:03   
Not for 2.8.5 - postponing until a future release
(0027057)
Timothy St. Clair   
2011-07-20 15:11   
This is a pretty serious issue that appears to be lingering and I just hit. Request a bump in priority.
(0027271)
ae   
2011-08-25 09:01   
Could you at least provide a workaround until this gets usable with vs 2010?
(0027272)
Bill Hoffman   
2011-08-25 09:29   
(edited on: 2011-08-25 11:31)
If there was a workable patch we could get this into 2.8.6. Anyone have an idea? "For the execution level I added this to cmVS10LinkFlagTable.h. Not perfect but works." Does that patch work?

(0027740)
Gili   
2011-11-09 19:42   
I've filed a separate bug report for the /SUBSYSTEM bug at http://public.kitware.com/Bug/view.php?id=12566 [^]
(0028426)
Fraser Hutchison   
2012-01-30 15:34   
A workaround for just the UAC issue is to declare the link flags separately. I believe this only works for VS2010.

Replace:
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\"" )

with:
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /level='requireAdministrator' /uiAccess='false'" )
(0041742)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.