Notes |
|
(0013076)
|
Bill Hoffman
|
2008-08-19 15:09
|
|
Committer: Bill Hoffman <bill.hoffman@kitware.com>
/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' |
|
|
(0014292)
|
Luke K
|
2008-12-04 18:32
|
|
This MSVC 7.1 issue is not entirely resolved. I am still seeing numerous warnings when dependent static libraries are built prior to linking the final executable:
[ 45%] Building CXX object
Util/CMakeFiles/Util-SL.dir/XMLUtil/XMLWriter.cpp.obj
XMLWriter.cpp
Linking CXX static library ..\build\MT-DLL\Util-SL.lib
XMLWriter.cpp.obj : warning LNK4218: non-native module found; restarting
link with /LTCG
[ 45%] Built target Util-SL
The /LTCG option is added to the executable linker line now (in the "AdditionalOptions" linker section), but I think that the above warning is caused by a missing WholeProgramOptimization="TRUE" element in the static library project files (in the Configuration tag).
I think the best way to resolve this issue is to detect the /GL compiler flag and insert the WholeProgramOptimization="TRUE" element into the Configuration tag. The compiler flag /GL and linker flag /LTCG are almost synonymous flags that mean "perform whole program optimization". This warning is a result of a discrepancy between the /GL flag and the WholeProgramOptimization element. If /GL is passed as a compiler arg, then it is necessarily true that WholeProgramOptimization element should = "TRUE" (otherwise = "FALSE" or omitted).
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 Kucalaba |
|
|
(0014294)
|
Luke K
|
2008-12-04 18:50
|
|
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">
Thanks again,
Luke |
|
|
(0014314)
|
Luke K
|
2008-12-09 14:44
|
|
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 |
|
|
(0024612)
|
David Cole
|
2011-01-12 06:40
|
|
Resolving issue that I accidentally stumbled across... and according to all the notes in the bug, it appears fixed.
Please re-open if there is still an issue here. |
|
|
(0026329)
|
David Cole
|
2011-05-02 14:45
|
|
Closing resolved issues that have not been updated in more than 3 months. |
|