[CMake] MSVC71 WholeProgramOptimization flags (/LTCG and /GL)
Luke Kucalaba
lkucalaba at dsci.com
Tue Dec 9 14:39:09 EST 2008
Problem solved! I finally found some time today to checkout the CMake
source code and get setup for development. I started the build and found
the answer I was looking for in
cmLocalVisualStudio7Generator::OutputBuildTool() :
const char* tool = "VCLibrarianTool";
fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"" << tool << "\"\n";
if(const char* libflags =
target.GetProperty("STATIC_LIBRARY_FLAGS"))
{
fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
}
Here is the solution that worked for me... if you have a similar problem
you can use the same concept for your situation:
If(WIN32 AND MSVC71)
String(REGEX MATCH "/GL" matchResult
"${compilerFlagsDebug}")
If(matchResult)
Set_Target_Properties("${targetFilenameDebug}"
PROPERTIES
STATIC_LIBRARY_FLAGS "/LTCG"
)
EndIf()
String(REGEX MATCH "/GL" matchResult
"${compilerFlagsRelease}")
If(matchResult)
Set_Target_Properties("${targetFilenameRelease}"
PROPERTIES
STATIC_LIBRARY_FLAGS "/LTCG"
)
EndIf()
EndIf()
Thanks again for everything. Our build system is now completely free of
errors and warnings!
Luke
________________________________
From: Luke Kucalaba
Sent: Thursday, December 04, 2008 6:57 PM
To: cmake at cmake.org
Subject: MSVC71 WholeProgramOptimization flags (/LTCG and /GL)
Hi,
I would like to reopen issue #0006794 dealing with this linker warning
that is still present for MSVC 7.1 static library builds:
Linking CXX static library ..\build\MT-DLL\Util-SL.lib
XMLWriter.cpp.obj : warning LNK4218: non-native module found; restarting
I did some more investigation of this problem, and I think I've nailed
it down now. I thought it was the missing WholeProgramOptimization
element that was causing the warning, when in fact it is the missing
"/LTCG" flag that should be in the Librarian additional command-line
options. I realize that for a static library project the linker flags
are not included in the generated project file, but this should be an
exception case to that rule. As a general rule of thumb, if the /GL
compiler flag is passed to a static library project, then the /LTCG flag
should be passed to the Librarian AdditionalOptions line.
<Tool
Name="VCLibrarianTool"
AdditionalOptions="/LTCG">
Thank you for your time and effort. I appreciate the hard work that you
have all done to make and keep CMake a high-quality software product.
Sincerely,
Luke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081209/987003e3/attachment.htm>
More information about the CMake
mailing list