cmGlobalVisualStudio10Generator.cxx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "windows.h" // this must be first to define GetCurrentDirectory
  14. #include "cmGlobalVisualStudio10Generator.h"
  15. #include "cmLocalVisualStudio10Generator.h"
  16. #include "cmMakefile.h"
  17. #include "cmake.h"
  18. cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator()
  19. {
  20. this->FindMakeProgramFile = "CMakeVS10FindMake.cmake";
  21. }
  22. //----------------------------------------------------------------------------
  23. void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf)
  24. {
  25. mf->AddDefinition("MSVC10", "1");
  26. }
  27. //----------------------------------------------------------------------------
  28. void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
  29. {
  30. fout << "Microsoft Visual Studio Solution File, Format Version 11.00\n";
  31. fout << "# Visual Studio 10\n";
  32. }
  33. ///! Create a local generator appropriate to this Global Generator
  34. cmLocalGenerator *cmGlobalVisualStudio10Generator::CreateLocalGenerator()
  35. {
  36. cmLocalGenerator*lg = new cmLocalVisualStudio10Generator;
  37. lg->SetGlobalGenerator(this);
  38. return lg;
  39. }
  40. //----------------------------------------------------------------------------
  41. void cmGlobalVisualStudio10Generator
  42. ::GetDocumentation(cmDocumentationEntry& entry) const
  43. {
  44. entry.Name = this->GetName();
  45. entry.Brief = "Generates Visual Studio 10 project files.";
  46. entry.Full = "";
  47. }
  48. //----------------------------------------------------------------------------
  49. void cmGlobalVisualStudio10Generator
  50. ::EnableLanguage(std::vector<std::string>const & lang,
  51. cmMakefile *mf, bool optional)
  52. {
  53. cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional);
  54. }
  55. //----------------------------------------------------------------------------
  56. std::string cmGlobalVisualStudio10Generator::GetUserMacrosDirectory()
  57. {
  58. std::string base;
  59. std::string path;
  60. // base begins with the VisualStudioProjectsLocation reg value...
  61. if (cmSystemTools::ReadRegistryValue(
  62. "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0;"
  63. "VisualStudioProjectsLocation",
  64. base))
  65. {
  66. cmSystemTools::ConvertToUnixSlashes(base);
  67. // 9.0 macros folder:
  68. path = base + "/VSMacros80";
  69. // *NOT* a typo; right now in Visual Studio 2008 beta the macros
  70. // folder is VSMacros80... They may change it to 90 before final
  71. // release of 2008 or they may not... we'll have to keep our eyes
  72. // on it
  73. }
  74. // path is (correctly) still empty if we did not read the base value from
  75. // the Registry value
  76. return path;
  77. }
  78. //----------------------------------------------------------------------------
  79. std::string cmGlobalVisualStudio10Generator::GetUserMacrosRegKeyBase()
  80. {
  81. return "Software\\Microsoft\\VisualStudio\\10.0\\vsmacros";
  82. }
  83. std::string cmGlobalVisualStudio10Generator
  84. ::GenerateBuildCommand(const char* makeProgram,
  85. const char *projectName,
  86. const char* additionalOptions, const char *targetName,
  87. const char* config, bool ignoreErrors, bool)
  88. {
  89. // Ingoring errors is not implemented in visual studio 6
  90. (void) ignoreErrors;
  91. // now build the test
  92. std::string makeCommand
  93. = cmSystemTools::ConvertToOutputPath(makeProgram);
  94. std::string lowerCaseCommand = makeCommand;
  95. cmSystemTools::LowerCase(lowerCaseCommand);
  96. // if there are spaces in the makeCommand, assume a full path
  97. // and convert it to a path with no spaces in it as the
  98. // RunSingleCommand does not like spaces
  99. if(makeCommand.find(' ') != std::string::npos)
  100. {
  101. cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand);
  102. }
  103. // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
  104. if(!targetName || strlen(targetName) == 0)
  105. {
  106. targetName = "ALL_BUILD";
  107. }
  108. bool clean = false;
  109. if ( targetName && strcmp(targetName, "clean") == 0 )
  110. {
  111. clean = true;
  112. makeCommand += " ";
  113. makeCommand += projectName;
  114. makeCommand += ".sln ";
  115. makeCommand += "/t:Clean ";
  116. }
  117. else
  118. {
  119. makeCommand += " ";
  120. makeCommand += targetName;
  121. makeCommand += ".vcxproj ";
  122. }
  123. makeCommand += "/p:Configuration=";
  124. if(config && strlen(config))
  125. {
  126. makeCommand += config;
  127. }
  128. else
  129. {
  130. makeCommand += "Debug";
  131. }
  132. if ( additionalOptions )
  133. {
  134. makeCommand += " ";
  135. makeCommand += additionalOptions;
  136. }
  137. return makeCommand;
  138. }