[Cmake] Handling precompiled headers compiler flag for VC7

Robert Mathews rmathews at envoyww.com
Thu May 1 17:04:54 EDT 2003


I guess every "/Foo" compiler flag for VC7 has to be handled differently
..... ugly.

Here's the diff for handling one of the precompiled header flags && allowing
control of "Detect64BitPortabilityProblems".

Hope that's useful.

Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.18
diff -r1.18 cmLocalVisualStudio7Generator.cxx
341a342,362
>
>   // Handle the precompiled header flag specially, since VC .NET needs
that.
>   std::string aCompilerFlags = m_Makefile->GetDefineFlags();
>   std::string::size_type aPrecompiledOptionIndex =
aCompilerFlags.find("/YX");
>   if(aPrecompiledOptionIndex != std::string::npos)
>   {
>    fout << "\t\t\t\tUsePrecompiledHeader=\"2\"\n";
>    std::string aHeaderName;
>    std::string::size_type aNextIndex = aCompilerFlags.find(" ",
aPrecompiledOptionIndex);
>    if(aNextIndex > aPrecompiledOptionIndex+3)
>    {
>     std::string::size_type aLength = (aNextIndex == std::string::npos) ?
std::string::npos :
>              aNextIndex - (aPrecompiledOptionIndex+3);
>     aHeaderName =
aCompilerFlags.substr(aPrecompiledOptionIndex+3,aLength);
>     if(*aHeaderName.begin()== '"')
>      aHeaderName.erase(aHeaderName.begin());
>     if(*aHeaderName.rbegin() == '"')
>      aHeaderName.erase(aHeaderName.size()-1);
>     fout << "\t\t\t\tPrecompileHeaderThrough=\"" << aHeaderName << "\"\n";
>    }
>   }
348,349c369,375
<   fout << "\t\t\t\tDetect64BitPortabilityProblems=\"TRUE\"\n"
<        << "\t\t\t\tDebugInformationFormat=\"3\"";
---
>   if(m_Makefile->GetDefinition("DETECT64BITPORTABILITYPROBLEMS"))
>    fout << "\t\t\t\tDetect64BitPortabilityProblems=\"" <<
>      m_Makefile->GetDefinition("DETECT64BITPORTABILITYPROBLEMS") <<
"\"\n";
>   else
>    fout << "\t\t\t\tDetect64BitPortabilityProblems=\"TRUE\"\n";
>
>   fout << "\t\t\t\tDebugInformationFormat=\"3\"";




More information about the CMake mailing list