cmGlobalVisualStudio10Generator.cxx 21 KB

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