cmGlobalVisualStudio10Generator.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmGlobalVisualStudio10Generator.h"
  4. #include "cmAlgorithms.h"
  5. #include "cmDocumentationEntry.h"
  6. #include "cmGeneratorTarget.h"
  7. #include "cmLocalVisualStudio10Generator.h"
  8. #include "cmMakefile.h"
  9. #include "cmSourceFile.h"
  10. #include "cmVS10CLFlagTable.h"
  11. #include "cmVS10CSharpFlagTable.h"
  12. #include "cmVS10LibFlagTable.h"
  13. #include "cmVS10LinkFlagTable.h"
  14. #include "cmVS10MASMFlagTable.h"
  15. #include "cmVS10RCFlagTable.h"
  16. #include "cmVisualStudioSlnData.h"
  17. #include "cmVisualStudioSlnParser.h"
  18. #include "cmake.h"
  19. static const char vs10generatorName[] = "Visual Studio 10 2010";
  20. // Map generator name without year to name with year.
  21. static const char* cmVS10GenName(const std::string& name, std::string& genName)
  22. {
  23. if (strncmp(name.c_str(), vs10generatorName,
  24. sizeof(vs10generatorName) - 6) != 0) {
  25. return 0;
  26. }
  27. const char* p = name.c_str() + sizeof(vs10generatorName) - 6;
  28. if (cmHasLiteralPrefix(p, " 2010")) {
  29. p += 5;
  30. }
  31. genName = std::string(vs10generatorName) + p;
  32. return p;
  33. }
  34. class cmGlobalVisualStudio10Generator::Factory
  35. : public cmGlobalGeneratorFactory
  36. {
  37. public:
  38. cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
  39. cmake* cm) const CM_OVERRIDE
  40. {
  41. std::string genName;
  42. const char* p = cmVS10GenName(name, genName);
  43. if (!p) {
  44. return 0;
  45. }
  46. if (!*p) {
  47. return new cmGlobalVisualStudio10Generator(cm, genName, "");
  48. }
  49. if (*p++ != ' ') {
  50. return 0;
  51. }
  52. if (strcmp(p, "Win64") == 0) {
  53. return new cmGlobalVisualStudio10Generator(cm, genName, "x64");
  54. }
  55. if (strcmp(p, "IA64") == 0) {
  56. return new cmGlobalVisualStudio10Generator(cm, genName, "Itanium");
  57. }
  58. return 0;
  59. }
  60. void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
  61. {
  62. entry.Name = std::string(vs10generatorName) + " [arch]";
  63. entry.Brief = "Generates Visual Studio 2010 project files. "
  64. "Optional [arch] can be \"Win64\" or \"IA64\".";
  65. }
  66. void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
  67. {
  68. names.push_back(vs10generatorName);
  69. names.push_back(vs10generatorName + std::string(" IA64"));
  70. names.push_back(vs10generatorName + std::string(" Win64"));
  71. }
  72. bool SupportsToolset() const CM_OVERRIDE { return true; }
  73. bool SupportsPlatform() const CM_OVERRIDE { return true; }
  74. };
  75. cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory()
  76. {
  77. return new Factory;
  78. }
  79. cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
  80. cmake* cm, const std::string& name, const std::string& platformName)
  81. : cmGlobalVisualStudio8Generator(cm, name, platformName)
  82. {
  83. std::string vc10Express;
  84. this->ExpressEdition = cmSystemTools::ReadRegistryValue(
  85. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0\\Setup\\VC;"
  86. "ProductDir",
  87. vc10Express, cmSystemTools::KeyWOW64_32);
  88. this->SystemIsWindowsCE = false;
  89. this->SystemIsWindowsPhone = false;
  90. this->SystemIsWindowsStore = false;
  91. this->MSBuildCommandInitialized = false;
  92. {
  93. std::string envPlatformToolset;
  94. if (cmSystemTools::GetEnv("PlatformToolset", envPlatformToolset) &&
  95. envPlatformToolset == "Windows7.1SDK") {
  96. // We are running from a Windows7.1SDK command prompt.
  97. this->DefaultPlatformToolset = "Windows7.1SDK";
  98. } else {
  99. this->DefaultPlatformToolset = "v100";
  100. }
  101. }
  102. this->DefaultClFlagTable = cmVS10CLFlagTable;
  103. this->DefaultCSharpFlagTable = cmVS10CSharpFlagTable;
  104. this->DefaultLibFlagTable = cmVS10LibFlagTable;
  105. this->DefaultLinkFlagTable = cmVS10LinkFlagTable;
  106. this->DefaultMasmFlagTable = cmVS10MASMFlagTable;
  107. this->DefaultRcFlagTable = cmVS10RCFlagTable;
  108. this->Version = VS10;
  109. }
  110. bool cmGlobalVisualStudio10Generator::MatchesGeneratorName(
  111. const std::string& name) const
  112. {
  113. std::string genName;
  114. if (cmVS10GenName(name, genName)) {
  115. return genName == this->GetName();
  116. }
  117. return false;
  118. }
  119. bool cmGlobalVisualStudio10Generator::SetSystemName(std::string const& s,
  120. cmMakefile* mf)
  121. {
  122. this->SystemName = s;
  123. this->SystemVersion = mf->GetSafeDefinition("CMAKE_SYSTEM_VERSION");
  124. if (!this->InitializeSystem(mf)) {
  125. return false;
  126. }
  127. return this->cmGlobalVisualStudio8Generator::SetSystemName(s, mf);
  128. }
  129. bool cmGlobalVisualStudio10Generator::SetGeneratorPlatform(
  130. std::string const& p, cmMakefile* mf)
  131. {
  132. if (!this->cmGlobalVisualStudio8Generator::SetGeneratorPlatform(p, mf)) {
  133. return false;
  134. }
  135. if (this->GetPlatformName() == "Itanium" ||
  136. this->GetPlatformName() == "x64") {
  137. if (this->IsExpressEdition() && !this->Find64BitTools(mf)) {
  138. return false;
  139. }
  140. }
  141. return true;
  142. }
  143. bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
  144. std::string const& ts, cmMakefile* mf)
  145. {
  146. if (this->SystemIsWindowsCE && ts.empty() &&
  147. this->DefaultPlatformToolset.empty()) {
  148. std::ostringstream e;
  149. e << this->GetName() << " Windows CE version '" << this->SystemVersion
  150. << "' requires CMAKE_GENERATOR_TOOLSET to be set.";
  151. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  152. return false;
  153. }
  154. if (!this->ParseGeneratorToolset(ts, mf)) {
  155. return false;
  156. }
  157. if (const char* toolset = this->GetPlatformToolset()) {
  158. mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", toolset);
  159. }
  160. if (const char* hostArch = this->GetPlatformToolsetHostArchitecture()) {
  161. mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE", hostArch);
  162. }
  163. return true;
  164. }
  165. bool cmGlobalVisualStudio10Generator::ParseGeneratorToolset(
  166. std::string const& ts, cmMakefile* mf)
  167. {
  168. if (ts.find_first_of(",=") != ts.npos) {
  169. std::ostringstream e;
  170. /* clang-format off */
  171. e <<
  172. "Generator\n"
  173. " " << this->GetName() << "\n"
  174. "does not recognize the toolset\n"
  175. " " << ts << "\n"
  176. "that was specified.";
  177. /* clang-format on */
  178. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  179. return false;
  180. }
  181. this->GeneratorToolset = ts;
  182. return true;
  183. }
  184. bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
  185. {
  186. if (this->SystemName == "Windows") {
  187. if (!this->InitializeWindows(mf)) {
  188. return false;
  189. }
  190. } else if (this->SystemName == "WindowsCE") {
  191. this->SystemIsWindowsCE = true;
  192. if (!this->InitializeWindowsCE(mf)) {
  193. return false;
  194. }
  195. } else if (this->SystemName == "WindowsPhone") {
  196. this->SystemIsWindowsPhone = true;
  197. if (!this->InitializeWindowsPhone(mf)) {
  198. return false;
  199. }
  200. } else if (this->SystemName == "WindowsStore") {
  201. this->SystemIsWindowsStore = true;
  202. if (!this->InitializeWindowsStore(mf)) {
  203. return false;
  204. }
  205. } else if (this->SystemName == "Android") {
  206. if (this->DefaultPlatformName != "Win32") {
  207. std::ostringstream e;
  208. e << "CMAKE_SYSTEM_NAME is 'Android' but CMAKE_GENERATOR "
  209. << "specifies a platform too: '" << this->GetName() << "'";
  210. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  211. return false;
  212. }
  213. std::string v = this->GetInstalledNsightTegraVersion();
  214. if (v.empty()) {
  215. mf->IssueMessage(cmake::FATAL_ERROR,
  216. "CMAKE_SYSTEM_NAME is 'Android' but "
  217. "'NVIDIA Nsight Tegra Visual Studio Edition' "
  218. "is not installed.");
  219. return false;
  220. }
  221. this->DefaultPlatformName = "Tegra-Android";
  222. this->DefaultPlatformToolset = "Default";
  223. this->NsightTegraVersion = v;
  224. mf->AddDefinition("CMAKE_VS_NsightTegra_VERSION", v.c_str());
  225. }
  226. return true;
  227. }
  228. bool cmGlobalVisualStudio10Generator::InitializeWindows(cmMakefile*)
  229. {
  230. return true;
  231. }
  232. bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf)
  233. {
  234. if (this->DefaultPlatformName != "Win32") {
  235. std::ostringstream e;
  236. e << "CMAKE_SYSTEM_NAME is 'WindowsCE' but CMAKE_GENERATOR "
  237. << "specifies a platform too: '" << this->GetName() << "'";
  238. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  239. return false;
  240. }
  241. this->DefaultPlatformToolset = this->SelectWindowsCEToolset();
  242. return true;
  243. }
  244. bool cmGlobalVisualStudio10Generator::InitializeWindowsPhone(cmMakefile* mf)
  245. {
  246. std::ostringstream e;
  247. e << this->GetName() << " does not support Windows Phone.";
  248. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  249. return false;
  250. }
  251. bool cmGlobalVisualStudio10Generator::InitializeWindowsStore(cmMakefile* mf)
  252. {
  253. std::ostringstream e;
  254. e << this->GetName() << " does not support Windows Store.";
  255. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  256. return false;
  257. }
  258. bool cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset(
  259. std::string& toolset) const
  260. {
  261. toolset = "";
  262. return false;
  263. }
  264. bool cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset(
  265. std::string& toolset) const
  266. {
  267. toolset = "";
  268. return false;
  269. }
  270. std::string cmGlobalVisualStudio10Generator::SelectWindowsCEToolset() const
  271. {
  272. if (this->SystemVersion == "8.0") {
  273. return "CE800";
  274. }
  275. return "";
  276. }
  277. void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
  278. {
  279. fout << "Microsoft Visual Studio Solution File, Format Version 11.00\n";
  280. if (this->ExpressEdition) {
  281. fout << "# Visual C++ Express 2010\n";
  282. } else {
  283. fout << "# Visual Studio 2010\n";
  284. }
  285. }
  286. ///! Create a local generator appropriate to this Global Generator
  287. cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator(
  288. cmMakefile* mf)
  289. {
  290. return new cmLocalVisualStudio10Generator(this, mf);
  291. }
  292. void cmGlobalVisualStudio10Generator::Generate()
  293. {
  294. this->LongestSource = LongestSourcePath();
  295. this->cmGlobalVisualStudio8Generator::Generate();
  296. if (this->LongestSource.Length > 0) {
  297. cmLocalGenerator* lg = this->LongestSource.Target->GetLocalGenerator();
  298. std::ostringstream e;
  299. /* clang-format off */
  300. e <<
  301. "The binary and/or source directory paths may be too long to generate "
  302. "Visual Studio 10 files for this project. "
  303. "Consider choosing shorter directory names to build this project with "
  304. "Visual Studio 10. "
  305. "A more detailed explanation follows."
  306. "\n"
  307. "There is a bug in the VS 10 IDE that renders property dialog fields "
  308. "blank for files referenced by full path in the project file. "
  309. "However, CMake must reference at least one file by full path:\n"
  310. " " << this->LongestSource.SourceFile->GetFullPath() << "\n"
  311. "This is because some Visual Studio tools would append the relative "
  312. "path to the end of the referencing directory path, as in:\n"
  313. " " << lg->GetCurrentBinaryDirectory() << "/"
  314. << this->LongestSource.SourceRel << "\n"
  315. "and then incorrectly complain that the file does not exist because "
  316. "the path length is too long for some internal buffer or API. "
  317. "To avoid this problem CMake must use a full path for this file "
  318. "which then triggers the VS 10 property dialog bug.";
  319. /* clang-format on */
  320. lg->IssueMessage(cmake::WARNING, e.str().c_str());
  321. }
  322. }
  323. void cmGlobalVisualStudio10Generator::EnableLanguage(
  324. std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
  325. {
  326. cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional);
  327. }
  328. const char* cmGlobalVisualStudio10Generator::GetPlatformToolset() const
  329. {
  330. std::string const& toolset = this->GetPlatformToolsetString();
  331. if (toolset.empty()) {
  332. return CM_NULLPTR;
  333. }
  334. return toolset.c_str();
  335. }
  336. std::string const& cmGlobalVisualStudio10Generator::GetPlatformToolsetString()
  337. const
  338. {
  339. if (!this->GeneratorToolset.empty()) {
  340. return this->GeneratorToolset;
  341. }
  342. if (!this->DefaultPlatformToolset.empty()) {
  343. return this->DefaultPlatformToolset;
  344. }
  345. static std::string const empty;
  346. return empty;
  347. }
  348. const char*
  349. cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitecture() const
  350. {
  351. if (!this->GeneratorToolsetHostArchitecture.empty()) {
  352. return this->GeneratorToolsetHostArchitecture.c_str();
  353. }
  354. return CM_NULLPTR;
  355. }
  356. bool cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf)
  357. {
  358. if (!this->cmGlobalVisualStudio8Generator::FindMakeProgram(mf)) {
  359. return false;
  360. }
  361. mf->AddDefinition("CMAKE_VS_MSBUILD_COMMAND",
  362. this->GetMSBuildCommand().c_str());
  363. return true;
  364. }
  365. std::string const& cmGlobalVisualStudio10Generator::GetMSBuildCommand()
  366. {
  367. if (!this->MSBuildCommandInitialized) {
  368. this->MSBuildCommandInitialized = true;
  369. this->MSBuildCommand = this->FindMSBuildCommand();
  370. }
  371. return this->MSBuildCommand;
  372. }
  373. std::string cmGlobalVisualStudio10Generator::FindMSBuildCommand()
  374. {
  375. std::string msbuild;
  376. std::string mskey;
  377. // Search in standard location.
  378. mskey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\";
  379. mskey += this->GetToolsVersion();
  380. mskey += ";MSBuildToolsPath";
  381. if (cmSystemTools::ReadRegistryValue(mskey.c_str(), msbuild,
  382. cmSystemTools::KeyWOW64_32)) {
  383. cmSystemTools::ConvertToUnixSlashes(msbuild);
  384. msbuild += "/MSBuild.exe";
  385. if (cmSystemTools::FileExists(msbuild, true)) {
  386. return msbuild;
  387. }
  388. }
  389. msbuild = "MSBuild.exe";
  390. return msbuild;
  391. }
  392. std::string cmGlobalVisualStudio10Generator::FindDevEnvCommand()
  393. {
  394. if (this->ExpressEdition) {
  395. // Visual Studio Express >= 10 do not have "devenv.com" or
  396. // "VCExpress.exe" that we can use to build reliably.
  397. // Tell the caller it needs to use MSBuild instead.
  398. return "";
  399. }
  400. // Skip over the cmGlobalVisualStudio8Generator implementation because
  401. // we expect a real devenv and do not want to look for VCExpress.
  402. return this->cmGlobalVisualStudio71Generator::FindDevEnvCommand();
  403. }
  404. void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
  405. std::vector<std::string>& makeCommand, const std::string& makeProgram,
  406. const std::string& projectName, const std::string& projectDir,
  407. const std::string& targetName, const std::string& config, bool fast,
  408. bool verbose, std::vector<std::string> const& makeOptions)
  409. {
  410. // Select the caller- or user-preferred make program, else MSBuild.
  411. std::string makeProgramSelected =
  412. this->SelectMakeProgram(makeProgram, this->GetMSBuildCommand());
  413. // Check if the caller explicitly requested a devenv tool.
  414. std::string makeProgramLower = makeProgramSelected;
  415. cmSystemTools::LowerCase(makeProgramLower);
  416. bool useDevEnv = (makeProgramLower.find("devenv") != std::string::npos ||
  417. makeProgramLower.find("vcexpress") != std::string::npos);
  418. // MSBuild is preferred (and required for VS Express), but if the .sln has
  419. // an Intel Fortran .vfproj then we have to use devenv. Parse it to find out.
  420. cmSlnData slnData;
  421. {
  422. std::string slnFile;
  423. if (!projectDir.empty()) {
  424. slnFile = projectDir;
  425. slnFile += "/";
  426. }
  427. slnFile += projectName;
  428. slnFile += ".sln";
  429. cmVisualStudioSlnParser parser;
  430. if (parser.ParseFile(slnFile, slnData,
  431. cmVisualStudioSlnParser::DataGroupProjects)) {
  432. std::vector<cmSlnProjectEntry> slnProjects = slnData.GetProjects();
  433. for (std::vector<cmSlnProjectEntry>::iterator i = slnProjects.begin();
  434. !useDevEnv && i != slnProjects.end(); ++i) {
  435. std::string proj = i->GetRelativePath();
  436. if (proj.size() > 7 && proj.substr(proj.size() - 7) == ".vfproj") {
  437. useDevEnv = true;
  438. }
  439. }
  440. }
  441. }
  442. if (useDevEnv) {
  443. // Use devenv to build solutions containing Intel Fortran projects.
  444. cmGlobalVisualStudio7Generator::GenerateBuildCommand(
  445. makeCommand, makeProgram, projectName, projectDir, targetName, config,
  446. fast, verbose, makeOptions);
  447. return;
  448. }
  449. makeCommand.push_back(makeProgramSelected);
  450. std::string realTarget = targetName;
  451. // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
  452. if (realTarget.empty()) {
  453. realTarget = "ALL_BUILD";
  454. }
  455. if (realTarget == "clean") {
  456. makeCommand.push_back(std::string(projectName) + ".sln");
  457. makeCommand.push_back("/t:Clean");
  458. } else {
  459. std::string targetProject(realTarget);
  460. targetProject += ".vcxproj";
  461. if (targetProject.find('/') == std::string::npos) {
  462. // it might be in a subdir
  463. if (cmSlnProjectEntry const* proj =
  464. slnData.GetProjectByName(realTarget)) {
  465. targetProject = proj->GetRelativePath();
  466. cmSystemTools::ConvertToUnixSlashes(targetProject);
  467. }
  468. }
  469. makeCommand.push_back(targetProject);
  470. }
  471. std::string configArg = "/p:Configuration=";
  472. if (!config.empty()) {
  473. configArg += config;
  474. } else {
  475. configArg += "Debug";
  476. }
  477. makeCommand.push_back(configArg);
  478. makeCommand.push_back(std::string("/p:VisualStudioVersion=") +
  479. this->GetIDEVersion());
  480. makeCommand.insert(makeCommand.end(), makeOptions.begin(),
  481. makeOptions.end());
  482. }
  483. bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf)
  484. {
  485. if (this->DefaultPlatformToolset == "v100") {
  486. // The v100 64-bit toolset does not exist in the express edition.
  487. this->DefaultPlatformToolset.clear();
  488. }
  489. if (this->GetPlatformToolset()) {
  490. return true;
  491. }
  492. // This edition does not come with 64-bit tools. Look for them.
  493. //
  494. // TODO: Detect available tools? x64\v100 exists but does not work?
  495. // HKLM\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\4.0;VCTargetsPath
  496. // c:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/Platforms/
  497. // {Itanium,Win32,x64}/PlatformToolsets/{v100,v90,Windows7.1SDK}
  498. std::string winSDK_7_1;
  499. if (cmSystemTools::ReadRegistryValue(
  500. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\"
  501. "Windows\\v7.1;InstallationFolder",
  502. winSDK_7_1)) {
  503. std::ostringstream m;
  504. m << "Found Windows SDK v7.1: " << winSDK_7_1;
  505. mf->DisplayStatus(m.str().c_str(), -1);
  506. this->DefaultPlatformToolset = "Windows7.1SDK";
  507. return true;
  508. } else {
  509. std::ostringstream e;
  510. /* clang-format off */
  511. e << "Cannot enable 64-bit tools with Visual Studio 2010 Express.\n"
  512. << "Install the Microsoft Windows SDK v7.1 to get 64-bit tools:\n"
  513. << " http://msdn.microsoft.com/en-us/windows/bb980924.aspx";
  514. /* clang-format on */
  515. mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
  516. cmSystemTools::SetFatalErrorOccured();
  517. return false;
  518. }
  519. }
  520. std::string cmGlobalVisualStudio10Generator::GenerateRuleFile(
  521. std::string const& output) const
  522. {
  523. // The VS 10 generator needs to create the .rule files on disk.
  524. // Hide them away under the CMakeFiles directory.
  525. std::string ruleDir = this->GetCMakeInstance()->GetHomeOutputDirectory();
  526. ruleDir += cmake::GetCMakeFilesDirectory();
  527. ruleDir += "/";
  528. ruleDir += cmSystemTools::ComputeStringMD5(
  529. cmSystemTools::GetFilenamePath(output).c_str());
  530. std::string ruleFile = ruleDir + "/";
  531. ruleFile += cmSystemTools::GetFilenameName(output);
  532. ruleFile += ".rule";
  533. return ruleFile;
  534. }
  535. void cmGlobalVisualStudio10Generator::PathTooLong(cmGeneratorTarget* target,
  536. cmSourceFile const* sf,
  537. std::string const& sfRel)
  538. {
  539. size_t len =
  540. (strlen(target->GetLocalGenerator()->GetCurrentBinaryDirectory()) + 1 +
  541. sfRel.length());
  542. if (len > this->LongestSource.Length) {
  543. this->LongestSource.Length = len;
  544. this->LongestSource.Target = target;
  545. this->LongestSource.SourceFile = sf;
  546. this->LongestSource.SourceRel = sfRel;
  547. }
  548. }
  549. bool cmGlobalVisualStudio10Generator::IsNsightTegra() const
  550. {
  551. return !this->NsightTegraVersion.empty();
  552. }
  553. std::string cmGlobalVisualStudio10Generator::GetNsightTegraVersion() const
  554. {
  555. return this->NsightTegraVersion;
  556. }
  557. std::string cmGlobalVisualStudio10Generator::GetInstalledNsightTegraVersion()
  558. {
  559. std::string version;
  560. cmSystemTools::ReadRegistryValue(
  561. "HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;"
  562. "Version",
  563. version, cmSystemTools::KeyWOW64_32);
  564. return version;
  565. }
  566. cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const
  567. {
  568. cmIDEFlagTable const* table = this->ToolsetOptions.GetClFlagTable(
  569. this->GetPlatformName(), this->GetPlatformToolsetString());
  570. return (table != CM_NULLPTR) ? table : this->DefaultClFlagTable;
  571. }
  572. cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable()
  573. const
  574. {
  575. cmIDEFlagTable const* table = this->ToolsetOptions.GetCSharpFlagTable(
  576. this->GetPlatformName(), this->GetPlatformToolsetString());
  577. return (table != CM_NULLPTR) ? table : this->DefaultCSharpFlagTable;
  578. }
  579. cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const
  580. {
  581. cmIDEFlagTable const* table = this->ToolsetOptions.GetRcFlagTable(
  582. this->GetPlatformName(), this->GetPlatformToolsetString());
  583. return (table != CM_NULLPTR) ? table : this->DefaultRcFlagTable;
  584. }
  585. cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const
  586. {
  587. cmIDEFlagTable const* table = this->ToolsetOptions.GetLibFlagTable(
  588. this->GetPlatformName(), this->GetPlatformToolsetString());
  589. return (table != CM_NULLPTR) ? table : this->DefaultLibFlagTable;
  590. }
  591. cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const
  592. {
  593. cmIDEFlagTable const* table = this->ToolsetOptions.GetLinkFlagTable(
  594. this->GetPlatformName(), this->GetPlatformToolsetString());
  595. return (table != CM_NULLPTR) ? table : this->DefaultLinkFlagTable;
  596. }
  597. cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const
  598. {
  599. cmIDEFlagTable const* table = this->ToolsetOptions.GetMasmFlagTable(
  600. this->GetPlatformName(), this->GetPlatformToolsetString());
  601. return (table != CM_NULLPTR) ? table : this->DefaultMasmFlagTable;
  602. }