My findings, with visual studio 2008 express, are that you don't
really need to have WholeProgramOptimization=TRUE to fix this warning.
It suffices to add /LTCG to the link options of all executables and modules.

Unfortunately I'm not able to get cmake to add the /LTCG flag to the
module link flags.
See also here: http://www.cmake.org/pipermail/cmake/2008-October/024446.html

Also, it seems weird that this flag is reported not to work in VS8+,
as both VS8 Express, and VS9 Express show the whole program
optimization options in the IDE.

>From the error above "cl : Command line warning D9002 : ignoring
unknown option '/LTGC'" i could guess that the flags have slightly
changed:
It seems the compiler (cl.exe) now needs the /GL option to enable
whole program optimization,
and the linkers (lib.exe & link.exe) now need the /LTCG option to enable it.

On Fri, Oct 10, 2008 at 19:44, Luke Kucalaba <[EMAIL PROTECTED]> wrote:
> I posted an issue on the mantis bug tracker a while ago regarding supporting 
> the /LTCG option for the MSVC71 generator.  The issue history indicates this 
> problem is fixed, but with CMake 2.6.2 the correct flags are still not being 
> generated for the MSVC71 project files and nmake makefiles.  Fortunately, the 
> MSVC compiler/linker is smart enough to realize this and restarts the link 
> using /LTCG.  The only bad thing about this is it extends the time required 
> to link because it has to restart the link again.
>
> Some details are provided below.  Thanks in advance!
> Luke
>
> -----------------------
> NMake output:
> -----------------------
> Linking CXX static library ..\build\MT-DLL\Util-SL.lib
> XMLWriter.cpp.obj : warning LNK4218: non-native module found; restarting link 
> with /LTCG
>
> -----------------------
> MSVC71 output:
> -----------------------
> Timer.obj : warning LNK4218: non-native module found; restarting link with 
> /LTCG
>
> -----------------------------
> Here's the original issue:
> -----------------------------
>
> Summary 0006794: Visual Studio compiler 'WholeProgramOptimization' (/LTCG)
>
> Description
>
> Hi,
>
> The cl.exe compiler option /LTCG (i.e. "WholeProgramOptimization") does not 
> seem to be generated correctly into the Visual Studio project file. This 
> error occurs in Visual Studio .NET 2003 (v7.1), and probably occurs in later 
> versions as well.
>
> The /LTCG is a whole configuration setting, which should be added to the 
> "Configuration" xml tag in the vcproj file as in the following example:
>
>   <Configuration
>     Name="Release|Win32"
>     OutputDirectory="Release"
>     . . .
>     WholeProgramOptimization="TRUE">
>
> This should be an easy fix. Please feel free to contact me with any questions 
> you may have.
>
> Thanks!
> Luke
>
> (0013076)
> bill.hoffman (manager)
> 2008-08-19 15:09
> Committer: Bill Hoffman <[EMAIL PROTECTED]>
> /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio7Generator.cxx,v <-- 
> cmGlobalVisualStudio7Generator.cxx
> new revision: 1.101; previous revision: 1.100
>
> BTW, this flag is not supported in VS8 and greater:
> cl : Command line warning D9002 : ignoring unknown option '/LTGC'
>
> Issue History
> Date Modified Username Field Change
> 2008-04-11 15:49 lkucalaba New Issue
> 2008-08-19 15:09 bill.hoffman Status new => closed
> 2008-08-19 15:09 bill.hoffman Note Added: 0013076
> 2008-08-19 15:09 bill.hoffman Resolution open => fixed
>
> _______________________________________________
> CMake mailing list
> [email protected]
> http://www.cmake.org/mailman/listinfo/cmake
>
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to