| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 | 
							- /*=========================================================================
 
-   Program:   CMake - Cross-Platform Makefile Generator
 
-   Module:    $RCSfile$
 
-   Language:  C++
 
-   Date:      $Date$
 
-   Version:   $Revision$
 
-   Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
 
-   See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
 
-      This software is distributed WITHOUT ANY WARRANTY; without even 
 
-      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 
-      PURPOSE.  See the above copyright notices for more information.
 
- =========================================================================*/
 
- #include "windows.h" // this must be first to define GetCurrentDirectory
 
- #include "cmGlobalVisualStudio8Generator.h"
 
- #include "cmLocalVisualStudio7Generator.h"
 
- #include "cmMakefile.h"
 
- #include "cmake.h"
 
- cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator()
 
- {
 
-   this->FindMakeProgramFile = "CMakeVS8FindMake.cmake";
 
-   this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms";
 
-   this->PlatformName = "Win32";
 
- }
 
- ///! Create a local generator appropriate to this Global Generator
 
- cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator()
 
- {
 
-   cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator;
 
-   lg->SetVersion8();
 
-   lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
 
-   lg->SetGlobalGenerator(this);
 
-   return lg;
 
- }
 
-   
 
- // ouput standard header for dsw file
 
- void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout)
 
- {
 
-   fout << "Microsoft Visual Studio Solution File, Format Version 9.00\n";
 
-   fout << "# Visual Studio 2005\n";
 
- }
 
- //----------------------------------------------------------------------------
 
- void cmGlobalVisualStudio8Generator
 
- ::GetDocumentation(cmDocumentationEntry& entry) const
 
- {
 
-   entry.Name = this->GetName();
 
-   entry.Brief = "Generates Visual Studio .NET 2005 project files.";
 
-   entry.Full = "";
 
- }
 
- //----------------------------------------------------------------------------
 
- void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf)
 
- {
 
-   mf->AddDefinition("MSVC80", "1");
 
- }
 
- //----------------------------------------------------------------------------
 
- void cmGlobalVisualStudio8Generator::Configure()
 
- {
 
-   this->cmGlobalVisualStudio7Generator::Configure();
 
-   this->CreateGUID(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
 
- }
 
- //----------------------------------------------------------------------------
 
- std::string cmGlobalVisualStudio8Generator::GetUserMacrosDirectory()
 
- {
 
-   // Some VS8 sp0 versions cannot run macros.
 
-   // See http://support.microsoft.com/kb/928209
 
-   const char* vc8sp1Registry =
 
-     "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\"
 
-     "InstalledProducts\\KB926601;";
 
-   const char* vc8exSP1Registry =
 
-     "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\"
 
-     "InstalledProducts\\KB926748;";
 
-   std::string vc8sp1;
 
-   if (!cmSystemTools::ReadRegistryValue(vc8sp1Registry, vc8sp1) &&
 
-       !cmSystemTools::ReadRegistryValue(vc8exSP1Registry, vc8sp1))
 
-     {
 
-     return "";
 
-     }
 
-   std::string base;
 
-   std::string path;
 
-   // base begins with the VisualStudioProjectsLocation reg value...
 
-   if (cmSystemTools::ReadRegistryValue(
 
-     "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\8.0;"
 
-     "VisualStudioProjectsLocation",
 
-     base))
 
-     {
 
-     cmSystemTools::ConvertToUnixSlashes(base);
 
-     // 7.0 macros folder:
 
-     //path = base + "/VSMacros";
 
-     // 7.1 macros folder:
 
-     //path = base + "/VSMacros71";
 
-     // 8.0 macros folder:
 
-     path = base + "/VSMacros80";
 
-     }
 
-   // path is (correctly) still empty if we did not read the base value from
 
-   // the Registry value
 
-   return path;
 
- }
 
- //----------------------------------------------------------------------------
 
- void cmGlobalVisualStudio8Generator::Generate()
 
- {
 
-   // Add a special target on which all other targets depend that
 
-   // checks the build system and optionally re-runs CMake.
 
-   const char* no_working_directory = 0;
 
-   std::vector<std::string> no_depends;
 
-   std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
 
-   for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
 
-     {
 
-     std::vector<cmLocalGenerator*>& generators = it->second;
 
-     if(!generators.empty())
 
-       {
 
-       // Add the build-system check target to the first local
 
-       // generator of this project.
 
-       cmLocalVisualStudio7Generator* lg =
 
-         static_cast<cmLocalVisualStudio7Generator*>(generators[0]);
 
-       cmMakefile* mf = lg->GetMakefile();
 
-       std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND");
 
-       cmCustomCommandLines noCommandLines;
 
-       mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false,
 
-                             no_working_directory, no_depends,
 
-                             noCommandLines);
 
-       cmTarget* tgt = mf->FindTarget(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
 
-       if(!tgt)
 
-         {
 
-         cmSystemTools::Error("Error adding target " 
 
-                              CMAKE_CHECK_BUILD_SYSTEM_TARGET);
 
-         continue;
 
-         }
 
-       // Add a custom rule to re-run CMake if any input files changed.
 
-       const char* suppRegenRule =
 
-         mf->GetDefinition("CMAKE_SUPPRESS_REGENERATION");
 
-       if(!cmSystemTools::IsOn(suppRegenRule))
 
-         {
 
-         // Collect the input files used to generate all targets in this
 
-         // project.
 
-         std::vector<std::string> listFiles;
 
-         for(unsigned int j = 0; j < generators.size(); ++j)
 
-           {
 
-           cmMakefile* lmf = generators[j]->GetMakefile();
 
-           listFiles.insert(listFiles.end(), lmf->GetListFiles().begin(),
 
-                            lmf->GetListFiles().end());
 
-           }
 
-         // Sort the list of input files and remove duplicates.
 
-         std::sort(listFiles.begin(), listFiles.end(), 
 
-                   std::less<std::string>());
 
-         std::vector<std::string>::iterator new_end =
 
-           std::unique(listFiles.begin(), listFiles.end());
 
-         listFiles.erase(new_end, listFiles.end());
 
-         // Create a rule to re-run CMake.
 
-         std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash();
 
-         stampName += "generate.stamp";
 
-         const char* dsprule = mf->GetRequiredDefinition("CMAKE_COMMAND");
 
-         cmCustomCommandLine commandLine;
 
-         commandLine.push_back(dsprule);
 
-         std::string argH = "-H";
 
-         argH += lg->Convert(mf->GetHomeDirectory(),
 
-                             cmLocalGenerator::START_OUTPUT,
 
-                             cmLocalGenerator::UNCHANGED, true);
 
-         commandLine.push_back(argH);
 
-         std::string argB = "-B";
 
-         argB += lg->Convert(mf->GetHomeOutputDirectory(),
 
-                             cmLocalGenerator::START_OUTPUT,
 
-                             cmLocalGenerator::UNCHANGED, true);
 
-         commandLine.push_back(argB);
 
-         commandLine.push_back("--check-stamp-file");
 
-         commandLine.push_back(stampName.c_str());
 
-         commandLine.push_back("--vs-solution-file");
 
-         commandLine.push_back("\"$(SolutionPath)\"");
 
-         cmCustomCommandLines commandLines;
 
-         commandLines.push_back(commandLine);
 
-         // Add the rule.  Note that we cannot use the CMakeLists.txt
 
-         // file as the main dependency because it would get
 
-         // overwritten by the CreateVCProjBuildRule.
 
-         // (this could be avoided with per-target source files)
 
-         const char* no_main_dependency = 0;
 
-         const char* no_working_directory = 0;
 
-         mf->AddCustomCommandToOutput(
 
-           stampName.c_str(), listFiles,
 
-           no_main_dependency, commandLines, "Checking Build System",
 
-           no_working_directory, true);
 
-         std::string ruleName = stampName;
 
-         ruleName += ".rule";
 
-         if(cmSourceFile* file = mf->GetSource(ruleName.c_str()))
 
-           {
 
-           tgt->AddSourceFile(file);
 
-           }
 
-         else
 
-           {
 
-           cmSystemTools::Error("Error adding rule for ", stampName.c_str());
 
-           }
 
-         }
 
-       }
 
-     }
 
-   // Now perform the main generation.
 
-   this->cmGlobalVisualStudio7Generator::Generate();
 
- }
 
- //----------------------------------------------------------------------------
 
- void cmGlobalVisualStudio8Generator::WriteSLNFile(
 
-   std::ostream& fout, cmLocalGenerator* root,
 
-   std::vector<cmLocalGenerator*>& generators)
 
- {
 
-   // Make all targets depend on their respective project's build
 
-   // system check target.
 
-   unsigned int i;
 
-   for(i = 0; i < generators.size(); ++i)
 
-     {
 
-     if(this->IsExcluded(root, generators[i]))
 
-       {
 
-       continue;
 
-       }
 
-     cmMakefile* mf = generators[i]->GetMakefile();
 
-     cmTargets& tgts = mf->GetTargets();
 
-     for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l)
 
-       {
 
-       if(l->first == CMAKE_CHECK_BUILD_SYSTEM_TARGET)
 
-         {
 
-         for(unsigned int j = 0; j < generators.size(); ++j)
 
-           {
 
-           // Every target in all generators should depend on this target.
 
-           cmMakefile* lmf = generators[j]->GetMakefile();
 
-           cmTargets &atgts = lmf->GetTargets();
 
-           for(cmTargets::iterator al = atgts.begin(); al != atgts.end(); ++al)
 
-             {
 
-             al->second.AddUtility(l->first.c_str());
 
-             }
 
-           }
 
-         }
 
-       }
 
-     }
 
-   // Now write the solution file.
 
-   this->cmGlobalVisualStudio71Generator::WriteSLNFile(fout, root, generators);
 
- }
 
- //----------------------------------------------------------------------------
 
- void
 
- cmGlobalVisualStudio8Generator
 
- ::WriteSolutionConfigurations(std::ostream& fout)
 
- {
 
-   fout << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n";
 
-   for(std::vector<std::string>::iterator i = this->Configurations.begin();
 
-       i != this->Configurations.end(); ++i)
 
-     {
 
-     fout << "\t\t" << *i << "|" << this->PlatformName << " = " << *i << "|"
 
-          << this->PlatformName << "\n";
 
-     }
 
-   fout << "\tEndGlobalSection\n";
 
- }
 
- //----------------------------------------------------------------------------
 
- void
 
- cmGlobalVisualStudio8Generator
 
- ::WriteProjectConfigurations(std::ostream& fout, const char* name,
 
-                              bool partOfDefaultBuild)
 
- {
 
-   std::string guid = this->GetGUID(name);
 
-   for(std::vector<std::string>::iterator i = this->Configurations.begin();
 
-       i != this->Configurations.end(); ++i)
 
-     {
 
-     fout << "\t\t{" << guid << "}." << *i
 
-          << "|" << this->PlatformName << ".ActiveCfg = "
 
-          << *i << "|" << this->PlatformName << "\n";
 
-     if(partOfDefaultBuild)
 
-       {
 
-       fout << "\t\t{" << guid << "}." << *i
 
-            << "|" << this->PlatformName << ".Build.0 = "
 
-            << *i << "|" << this->PlatformName << "\n";
 
-       }
 
-     }
 
- }
 
- //----------------------------------------------------------------------------
 
- static cmVS7FlagTable cmVS8ExtraFlagTable[] =
 
- { 
 
-   {"CallingConvention", "Gd", "cdecl", "0", 0 },
 
-   {"CallingConvention", "Gr", "fastcall", "1", 0 },
 
-   {"CallingConvention", "Gz", "stdcall", "2", 0 },
 
-   {"Detect64BitPortabilityProblems", "Wp64",
 
-    "Detect 64Bit Portability Problems", "true", 0 },
 
-   {"ErrorReporting", "errorReport:prompt", "Report immediately", "1", 0 },
 
-   {"ErrorReporting", "errorReport:queue", "Queue for next login", "2", 0 },
 
-   // Precompiled header and related options.  Note that the
 
-   // UsePrecompiledHeader entries are marked as "Continue" so that the
 
-   // corresponding PrecompiledHeaderThrough entry can be found.
 
-   {"UsePrecompiledHeader", "Yu", "Use Precompiled Header", "2",
 
-    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
 
-   {"PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "",
 
-    cmVS7FlagTable::UserValueRequired},
 
-   // There is no YX option in the VS8 IDE.
 
-   // Exception handling mode.  If no entries match, it will be FALSE.
 
-   {"ExceptionHandling", "GX", "enable c++ exceptions", "1", 0},
 
-   {"ExceptionHandling", "EHsc", "enable c++ exceptions", "1", 0},
 
-   {"ExceptionHandling", "EHa", "enable SEH exceptions", "2", 0},
 
-   {0,0,0,0,0}
 
- };
 
- cmVS7FlagTable const* cmGlobalVisualStudio8Generator::GetExtraFlagTableVS8()
 
- {
 
-   return cmVS8ExtraFlagTable;
 
- }
 
 
  |