MantisBT - CMake
View Issue Details
0014009CMakeCMakepublic2013-03-13 11:252016-06-10 14:31
Braden McDaniel 
Kitware Robot 
normalminoralways
closedmoved 
x86WindowsXP
CMake 2.8.10.2 
 
0014009: /LTCG option does not cause LinkTimeCodeGeneration to be set in project file
Adding the /LTCG linker option to LINK_FLAGS or STATIC_LIBRARY_FLAGS should cause LinkTimeCodeGeneration to be set in the project file. For instance:

  <Tool Name="VCLinkerTool" ... LinkTimeCodeGeneration="1" />

This flag has the following forms that correspond to values 1-4 for the LinkTimeCodeGeneration attribute:

  Option XML Attribute Value
  ---------------------------------------
  /LTCG 1
  /LTCG:PGINSTRUMENT 2
  /LTCG:PGOPTIMIZE 3
  /LTCG:PGUPDATE 4


See: http://msdn.microsoft.com/en-us/library/xbf3tbeh.aspx [^]
Add /LTCG to the linker (or librarian) using:

  foreach(CONFIG _RELEASE _MINSIZEREL _RELWITHDEBINFO)
    set_property(TARGET foo APPEND PROPERTY LINK_FLAGS${CONFIG} "/LTCG")
  endforeach()


  foreach(CONFIG _RELEASE _MINSIZEREL _RELWITHDEBINFO)
    set_property(TARGET bar APPEND PROPERTY STATIC_LIBRARY_FLAGS${CONFIG} "/LTCG")
  endforeach()

Generate a Visual Studio project file.
I'm observing this on Visual Studio 2008. This bug is similar to bug 0010263; though that bug dealt with the compiler option and this one is about the related linker option.
No tags attached.
related to 0010263closed David Cole /GL flag for Visual Studio 7 does not cause "WholeProgramOptimization" to be set in project file (i.e. GUI) 
Issue History
2013-03-13 11:25Braden McDanielNew Issue
2013-03-13 11:35Brad KingRelationship addedrelated to 0010263
2013-03-13 11:39Brad KingNote Added: 0032601
2016-06-10 14:28Kitware RobotNote Added: 0042247
2016-06-10 14:28Kitware RobotStatusnew => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0032601)
Brad King   
2013-03-13 11:39   
For VS >= 10 we generate the flag mappings from MSBuild rule files, but for VS <= 9 we have to hand-code the table. Try this patch which backports the VS 10 table entries (untested):

diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index dfe8280..1872d60 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -548,6 +548,16 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] =
    "Image may be rebased at load-time", "2", 0},
   {"SetChecksum", "RELEASE", "Enable setting checksum in header", "true", 
0},
   {"SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 
0},
+  {"LinkTimeCodeGeneration", "",
+   "Default", "Default", 0},
+  {"LinkTimeCodeGeneration", "LTCG",
+   "Use Link Time Code Generation", "UseLinkTimeCodeGeneration", 0},
+  {"LinkTimeCodeGeneration", "LTCG:PGInstrument",
+   "Profile Guided Optimization - Instrument", "PGInstrument", 0},
+  {"LinkTimeCodeGeneration", "LTCG:PGOptimize",
+   "Profile Guided Optimization - Optimization", "PGOptimization", 0},
+  {"LinkTimeCodeGeneration", "LTCG:PGUpdate",
+   "Profile Guided Optimization - Update", "PGUpdate", 0},
   {"TargetMachine", "MACHINE:I386", "Machine x86", "1", 0},                    
   
{"TargetMachine", "MACHINE:X86", "Machine x86", "1", 0},                     
   
{"TargetMachine", "MACHINE:AM33", "Machine AM33", "2", 0},                   

(0042247)
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.