cmGlobalVisualStudio10Generator.cxx 21 KB

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