cmGlobalVisualStudio10Generator.cxx 19 KB

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