MantisBT - CMake
View Issue Details
0013601CMakeCMakepublic2012-10-23 18:192013-03-04 08:38
dmytro_ovdiienko 
Brad King 
normalblockalways
closedfixed 
x32Windows7
CMake 2.8.9 
CMake 2.8.11 
0013601: LinkDelaySign /KEYFILE and /DELAYSIGN parameters do not work
CMake generates incorrect keys for /KEYFILE and /DELAYSIGN parameters for VS2010
0. Create dummy C++ project

Add following statement to teh project file

ADD_DEFINITIONS ("/clr /FUSystem.dll /FUSystem.Core.dll")

set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYSIGN /KEYFILE:\"path-to-key-file.snk\"")

Expected:
  LinkDelaySign and LinkKeyFile parameters are generated.

In fact:
  DelaySign and KeyFile are generated.
No tags attached.
zip b2b_V12_net.vcxproj.zip (4,602) 2012-10-25 06:14
https://public.kitware.com/Bug/file/4534/b2b_V12_net.vcxproj.zip
png Linker_Advanced.png (26,869) 2012-10-25 06:25
https://public.kitware.com/Bug/file/4535/Linker_Advanced.png
png

zip test_sign.vcxproj.zip (4,940) 2012-10-25 10:26
https://public.kitware.com/Bug/file/4539/test_sign.vcxproj.zip
? patch (1,260) 2012-10-25 16:38
https://public.kitware.com/Bug/file/4540/patch
Issue History
2012-10-23 18:19dmytro_ovdiienkoNew Issue
2012-10-23 18:20dmytro_ovdiienkoNote Added: 0031299
2012-10-24 13:44Brad KingNote Added: 0031304
2012-10-24 13:44Brad KingAssigned To => Brad King
2012-10-24 13:44Brad KingStatusnew => assigned
2012-10-24 13:44Brad KingResolutionopen => fixed
2012-10-24 13:44Brad KingFixed in Version => CMake 2.8.10
2012-10-24 13:44Brad KingTarget Version => CMake 2.8.10
2012-10-24 13:44Brad KingStatusassigned => resolved
2012-10-25 06:14dmytro_ovdiienkoNote Added: 0031311
2012-10-25 06:14dmytro_ovdiienkoStatusresolved => feedback
2012-10-25 06:14dmytro_ovdiienkoResolutionfixed => reopened
2012-10-25 06:14dmytro_ovdiienkoFile Added: b2b_V12_net.vcxproj.zip
2012-10-25 06:25dmytro_ovdiienkoNote Edited: 0031311bug_revision_view_page.php?bugnote_id=31311#r867
2012-10-25 06:25dmytro_ovdiienkoFile Added: Linker_Advanced.png
2012-10-25 07:48Brad KingNote Added: 0031312
2012-10-25 07:48Brad KingStatusfeedback => assigned
2012-10-25 07:48Brad KingResolutionreopened => open
2012-10-25 07:48Brad KingFixed in VersionCMake 2.8.10 =>
2012-10-25 07:48Brad KingTarget VersionCMake 2.8.10 => CMake 2.8.11
2012-10-25 08:47dmytro_ovdiienkoNote Added: 0031314
2012-10-25 08:52dmytro_ovdiienkoNote Added: 0031316
2012-10-25 08:56Brad KingNote Added: 0031318
2012-10-25 08:56Brad KingNote Edited: 0031318bug_revision_view_page.php?bugnote_id=31318#r871
2012-10-25 10:26dmytro_ovdiienkoFile Added: test_sign.vcxproj.zip
2012-10-25 10:27dmytro_ovdiienkoNote Added: 0031319
2012-10-25 10:45Brad KingNote Added: 0031320
2012-10-25 10:45Brad KingAssigned ToBrad King =>
2012-10-25 10:45Brad KingStatusassigned => backlog
2012-10-25 10:45Brad KingTarget VersionCMake 2.8.11 =>
2012-10-25 10:52dmytro_ovdiienkoNote Added: 0031321
2012-10-25 10:53dmytro_ovdiienkoNote Added: 0031322
2012-10-25 11:50Brad KingNote Added: 0031323
2012-10-25 16:38dmytro_ovdiienkoFile Added: patch
2012-10-25 16:38dmytro_ovdiienkoNote Added: 0031333
2012-10-25 16:41Brad KingNote Added: 0031334
2012-10-25 17:11dmytro_ovdiienkoNote Added: 0031336
2012-10-26 12:51Brad KingNote Added: 0031342
2012-10-26 12:51Brad KingAssigned To => Brad King
2012-10-26 12:51Brad KingStatusbacklog => resolved
2012-10-26 12:51Brad KingResolutionopen => fixed
2012-10-26 12:51Brad KingTarget Version => CMake 2.8.11
2013-03-04 08:38Robert MaynardNote Added: 0032492
2013-03-04 08:38Robert MaynardStatusresolved => closed

Notes
(0031299)
dmytro_ovdiienko   
2012-10-23 18:20   
I see bugfix in the following commit:
http://public.kitware.com/pipermail/cmake-commits/2012-August/013276.html [^]
(0031304)
Brad King   
2012-10-24 13:44   
This commit:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9b2dda5d [^]

is in 2.8.10 and adds the mapping for VS 11 features. The /DELAYSIGN flag was called just DelaySign in VS 10:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmVS10LinkFlagTable.h;hb=v2.8.9#l185 [^]
(0031311)
dmytro_ovdiienko   
2012-10-25 06:14   
(edited on: 2012-10-25 06:25)
I've checked latest build on VS 2010:
http://www.cmake.org/files/dev/cmake-2.8.9.20121024-gd3328-win32-x86.zip [^]

It still generates DelaySign and KeyFile tags. VS 2010 does not support them. I'm attaching project file. Please try to open it and check Linker->Advanced settings. KeyFile and Delay Sign fields should be set.

(0031312)
Brad King   
2012-10-25 07:48   
Try changing the relevant entries in "Source/cmVS10LinkFlagTable.h" and report back with the correct lines for that. Use the VS 11 table from 2.8.10 as a reference.

The existing VS 10 table entries were computed automatically from parsing MSBuild rule files. I wonder if VS 10 sp1 changed these names.
(0031314)
dmytro_ovdiienko   
2012-10-25 08:47   
I will try.

BTW, VS2010SP1 duplicates parameters.

1. It stores these parameters to the following structure:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> [^]

...

<PropertyGroup>
...
    <LinkKeyFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\key\FIXAntenna.Net.snk</LinkKeyFile>
    <LinkDelaySign Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkDelaySign>

2. Additionally it stores values to:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> [^]
...
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
...
    <Link>
...
      <KeyFile>..\key\FIXAntenna.Net.snk</KeyFile>
      <DelaySign>true</DelaySign>


o_O
(0031316)
dmytro_ovdiienko   
2012-10-25 08:52   
Looks like second option is not used by MSBuild. And it was obtained after migration from VS2008 to VS2010.

3rd option:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> [^]

..
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <LinkIncremental>true</LinkIncremental>
    <LinkKeyFile>D:\src\epm-bfix\fix_trunk\dot_net\key\FIXAntenna.Net.snk </LinkKeyFile>
    <LinkDelaySign>true</LinkDelaySign>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <LinkIncremental>false</LinkIncremental>
    <LinkKeyFile>D:\src\epm-bfix\fix_trunk\dot_net\key\FIXAntenna.Net.snk </LinkKeyFile>
    <LinkDelaySign>true</LinkDelaySign>
  </PropertyGroup>
(0031318)
Brad King   
2012-10-25 08:56   
Please try this patch (untested):

diff --git a/Source/cmVS10LinkFlagTable.h b/Source/cmVS10LinkFlagTable.h
index c60e8eb..64febbb 100644
--- a/Source/cmVS10LinkFlagTable.h
+++ b/Source/cmVS10LinkFlagTable.h
@@ -182,8 +182,8 @@ static cmVS7FlagTable cmVS10LinkFlagTable[] =
   {"SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 
0},
   {"SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 
0},
   {"Profile", "PROFILE", "", "true", 0},
-  {"DelaySign", "DELAYSIGN:NO", "", "false", 0},
-  {"DelaySign", "DELAYSIGN", "", "true", 0},
+  {"LinkDelaySign", "DELAYSIGN:NO", "", "false", 0},
+  {"LinkDelaySign", "DELAYSIGN", "", "true", 0},
   {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 
0},
   {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 
0},
   {"ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 
0},
@@ -294,7 +294,7 @@ static cmVS7FlagTable cmVS10LinkFlagTable[] =
   {"MergeSections", "MERGE:",
    "Merge Sections",
    "", cmVS7FlagTable::UserValue},
-  {"KeyFile", "KEYFILE:",
+  {"LinkKeyFile", "KEYFILE:",
    "Key File",
    "", cmVS7FlagTable::UserValue},
   {"KeyContainer", "KEYCONTAINER:",


(0031319)
dmytro_ovdiienko   
2012-10-25 10:27   
Does not work. You should put these tags to the PropertyGroup tag. Please find correct project attached.
(0031320)
Brad King   
2012-10-25 10:45   
In that case this will need special handling in the C++ code which I don't have time to do. Look at

 cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions

for generation of PropertyGroup elements.
(0031321)
dmytro_ovdiienko   
2012-10-25 10:52   
OK. Thanks.
Is there workaround?
(0031322)
dmytro_ovdiienko   
2012-10-25 10:53   
Could you please remove support of the keyfile and delaysign so it will be inserted as is?
(0031323)
Brad King   
2012-10-25 11:50   
Re 0013601:0031322: If you can construct a patch that does the minimum for what you need then post it here.
(0031333)
dmytro_ovdiienko   
2012-10-25 16:38   
Please find attached.
(0031334)
Brad King   
2012-10-25 16:41   
Thanks. Will a similar change be needed to "Source/cmVS11LinkFlagTable.h" to handle this for VS 11?
(0031336)
dmytro_ovdiienko   
2012-10-25 17:11   
dunno
(0031342)
Brad King   
2012-10-26 12:51   
It looks like the LinkIncremental and GenerateManifest options also need to be in the PropertyGroup instead of Link, and there was already hackish code to implement that. I've refactored it to avoid duplicate code:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c65a2ea6 [^]

The result allows this issue to be addressed easily in the same way:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=035e7bd0 [^]
(0032492)
Robert Maynard   
2013-03-04 08:38   
Closing resolved issues that have not been updated in more than 4 months.