cmGlobalVisualStudio7Generator.cxx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  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 "cmGlobalVisualStudio7Generator.h"
  12. #include "cmGeneratedFileStream.h"
  13. #include "cmLocalVisualStudio7Generator.h"
  14. #include "cmMakefile.h"
  15. #include "cmake.h"
  16. cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator()
  17. {
  18. this->FindMakeProgramFile = "CMakeVS7FindMake.cmake";
  19. }
  20. void cmGlobalVisualStudio7Generator
  21. ::EnableLanguage(std::vector<std::string>const & lang,
  22. cmMakefile *mf, bool optional)
  23. {
  24. mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
  25. mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl");
  26. mf->AddDefinition("CMAKE_GENERATOR_RC", "rc");
  27. mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
  28. mf->AddDefinition("CMAKE_GENERATOR_FC", "ifort");
  29. this->AddPlatformDefinitions(mf);
  30. // Create list of configurations requested by user's cache, if any.
  31. this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
  32. this->GenerateConfigurations(mf);
  33. // if this environment variable is set, then copy it to
  34. // a static cache entry. It will be used by
  35. // cmLocalGenerator::ConstructScript, to add an extra PATH
  36. // to all custom commands. This is because the VS IDE
  37. // does not use the environment it is run in, and this allows
  38. // for running commands and using dll's that the IDE environment
  39. // does not know about.
  40. const char* extraPath = cmSystemTools::GetEnv("CMAKE_MSVCIDE_RUN_PATH");
  41. if(extraPath)
  42. {
  43. mf->AddCacheDefinition
  44. ("CMAKE_MSVCIDE_RUN_PATH", extraPath,
  45. "Saved environment variable CMAKE_MSVCIDE_RUN_PATH",
  46. cmCacheManager::STATIC);
  47. }
  48. }
  49. void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf)
  50. {
  51. mf->AddDefinition("MSVC70", "1");
  52. }
  53. std::string cmGlobalVisualStudio7Generator
  54. ::GenerateBuildCommand(const char* makeProgram,
  55. const char *projectName,
  56. const char* additionalOptions, const char *targetName,
  57. const char* config, bool ignoreErrors, bool)
  58. {
  59. // Ingoring errors is not implemented in visual studio 6
  60. (void) ignoreErrors;
  61. // now build the test
  62. std::string makeCommand =
  63. cmSystemTools::ConvertToOutputPath(makeProgram);
  64. std::string lowerCaseCommand = makeCommand;
  65. cmSystemTools::LowerCase(lowerCaseCommand);
  66. // if there are spaces in the makeCommand, assume a full path
  67. // and convert it to a path with no spaces in it as the
  68. // RunSingleCommand does not like spaces
  69. #if defined(_WIN32) && !defined(__CYGWIN__)
  70. if(makeCommand.find(' ') != std::string::npos)
  71. {
  72. cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand);
  73. }
  74. #endif
  75. makeCommand += " ";
  76. makeCommand += projectName;
  77. makeCommand += ".sln ";
  78. bool clean = false;
  79. if ( targetName && strcmp(targetName, "clean") == 0 )
  80. {
  81. clean = true;
  82. targetName = "ALL_BUILD";
  83. }
  84. if(clean)
  85. {
  86. makeCommand += "/clean ";
  87. }
  88. else
  89. {
  90. makeCommand += "/build ";
  91. }
  92. if(config && strlen(config))
  93. {
  94. makeCommand += config;
  95. }
  96. else
  97. {
  98. makeCommand += "Debug";
  99. }
  100. makeCommand += " /project ";
  101. if (targetName && strlen(targetName))
  102. {
  103. makeCommand += targetName;
  104. }
  105. else
  106. {
  107. makeCommand += "ALL_BUILD";
  108. }
  109. if ( additionalOptions )
  110. {
  111. makeCommand += " ";
  112. makeCommand += additionalOptions;
  113. }
  114. return makeCommand;
  115. }
  116. ///! Create a local generator appropriate to this Global Generator
  117. cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator()
  118. {
  119. cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator;
  120. lg->SetExtraFlagTable(this->GetExtraFlagTableVS7());
  121. lg->SetGlobalGenerator(this);
  122. return lg;
  123. }
  124. void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf)
  125. {
  126. // process the configurations
  127. const char* ct
  128. = this->CMakeInstance->GetCacheDefinition("CMAKE_CONFIGURATION_TYPES");
  129. if ( ct )
  130. {
  131. std::vector<std::string> argsOut;
  132. cmSystemTools::ExpandListArgument(ct, argsOut);
  133. for(std::vector<std::string>::iterator i = argsOut.begin();
  134. i != argsOut.end(); ++i)
  135. {
  136. if(std::find(this->Configurations.begin(),
  137. this->Configurations.end(),
  138. *i) == this->Configurations.end())
  139. {
  140. this->Configurations.push_back(*i);
  141. }
  142. }
  143. }
  144. // default to at least Debug and Release
  145. if(this->Configurations.size() == 0)
  146. {
  147. this->Configurations.push_back("Debug");
  148. this->Configurations.push_back("Release");
  149. }
  150. // Reset the entry to have a semi-colon separated list.
  151. std::string configs = this->Configurations[0];
  152. for(unsigned int i=1; i < this->Configurations.size(); ++i)
  153. {
  154. configs += ";";
  155. configs += this->Configurations[i];
  156. }
  157. mf->AddCacheDefinition(
  158. "CMAKE_CONFIGURATION_TYPES",
  159. configs.c_str(),
  160. "Semicolon separated list of supported configuration types, "
  161. "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, "
  162. "anything else will be ignored.",
  163. cmCacheManager::STRING);
  164. }
  165. void cmGlobalVisualStudio7Generator::Generate()
  166. {
  167. // first do the superclass method
  168. this->cmGlobalVisualStudioGenerator::Generate();
  169. // Now write out the DSW
  170. this->OutputSLNFile();
  171. // If any solution or project files changed during the generation,
  172. // tell Visual Studio to reload them...
  173. if(!cmSystemTools::GetErrorOccuredFlag())
  174. {
  175. this->CallVisualStudioMacro(MacroReload);
  176. }
  177. }
  178. void cmGlobalVisualStudio7Generator
  179. ::OutputSLNFile(cmLocalGenerator* root,
  180. std::vector<cmLocalGenerator*>& generators)
  181. {
  182. if(generators.size() == 0)
  183. {
  184. return;
  185. }
  186. this->CurrentProject = root->GetMakefile()->GetProjectName();
  187. std::string fname = root->GetMakefile()->GetStartOutputDirectory();
  188. fname += "/";
  189. fname += root->GetMakefile()->GetProjectName();
  190. fname += ".sln";
  191. cmGeneratedFileStream fout(fname.c_str());
  192. fout.SetCopyIfDifferent(true);
  193. if(!fout)
  194. {
  195. return;
  196. }
  197. this->WriteSLNFile(fout, root, generators);
  198. if (fout.Close())
  199. {
  200. this->FileReplacedDuringGenerate(fname);
  201. }
  202. }
  203. // output the SLN file
  204. void cmGlobalVisualStudio7Generator::OutputSLNFile()
  205. {
  206. std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
  207. for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
  208. {
  209. this->OutputSLNFile(it->second[0], it->second);
  210. }
  211. }
  212. void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
  213. std::ostream& fout,
  214. cmLocalGenerator* root,
  215. OrderedTargetDependSet const& projectTargets)
  216. {
  217. // loop over again and write out configurations for each target
  218. // in the solution
  219. for(OrderedTargetDependSet::const_iterator tt =
  220. projectTargets.begin(); tt != projectTargets.end(); ++tt)
  221. {
  222. cmTarget* target = *tt;
  223. const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
  224. if(expath)
  225. {
  226. this->WriteProjectConfigurations(fout, target->GetName(),
  227. true);
  228. }
  229. else
  230. {
  231. bool partOfDefaultBuild = this->IsPartOfDefaultBuild(
  232. root->GetMakefile()->GetProjectName(), target);
  233. const char *vcprojName =
  234. target->GetProperty("GENERATOR_FILE_NAME");
  235. if (vcprojName)
  236. {
  237. this->WriteProjectConfigurations(fout, vcprojName,
  238. partOfDefaultBuild);
  239. }
  240. }
  241. }
  242. }
  243. void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
  244. std::ostream& fout,
  245. cmLocalGenerator* root,
  246. OrderedTargetDependSet const& projectTargets)
  247. {
  248. std::string rootdir = root->GetMakefile()->GetStartOutputDirectory();
  249. rootdir += "/";
  250. for(OrderedTargetDependSet::const_iterator tt =
  251. projectTargets.begin(); tt != projectTargets.end(); ++tt)
  252. {
  253. cmTarget* target = *tt;
  254. // handle external vc project files
  255. const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
  256. if(expath)
  257. {
  258. std::string project = target->GetName();
  259. std::string location = expath;
  260. this->WriteExternalProject(fout, project.c_str(),
  261. location.c_str(), target->GetUtilities());
  262. }
  263. else
  264. {
  265. bool skip = false;
  266. // if it is a global target or the check build system target
  267. // or the all_build target
  268. // then only use the one that is for the root
  269. if(target->GetType() == cmTarget::GLOBAL_TARGET
  270. || !strcmp(target->GetName(), CMAKE_CHECK_BUILD_SYSTEM_TARGET)
  271. || !strcmp(target->GetName(), this->GetAllTargetName()))
  272. {
  273. if(target->GetMakefile() != root->GetMakefile())
  274. {
  275. skip = true;
  276. }
  277. }
  278. // if not skipping the project then write it into the
  279. // solution
  280. if(!skip)
  281. {
  282. const char *vcprojName =
  283. target->GetProperty("GENERATOR_FILE_NAME");
  284. if(vcprojName)
  285. {
  286. cmMakefile* tmf = target->GetMakefile();
  287. std::string dir = tmf->GetStartOutputDirectory();
  288. dir = root->Convert(dir.c_str(),
  289. cmLocalGenerator::START_OUTPUT);
  290. this->WriteProject(fout, vcprojName, dir.c_str(),
  291. *target);
  292. }
  293. }
  294. }
  295. }
  296. }
  297. void cmGlobalVisualStudio7Generator::WriteTargetDepends(
  298. std::ostream& fout,
  299. OrderedTargetDependSet const& projectTargets
  300. )
  301. {
  302. for(OrderedTargetDependSet::const_iterator tt =
  303. projectTargets.begin(); tt != projectTargets.end(); ++tt)
  304. {
  305. cmTarget* target = *tt;
  306. cmMakefile* mf = target->GetMakefile();
  307. const char *vcprojName =
  308. target->GetProperty("GENERATOR_FILE_NAME");
  309. if (vcprojName)
  310. {
  311. std::string dir = mf->GetStartDirectory();
  312. this->WriteProjectDepends(fout, vcprojName,
  313. dir.c_str(), *target);
  314. }
  315. }
  316. }
  317. // Write a SLN file to the stream
  318. void cmGlobalVisualStudio7Generator
  319. ::WriteSLNFile(std::ostream& fout,
  320. cmLocalGenerator* root,
  321. std::vector<cmLocalGenerator*>& generators)
  322. {
  323. // Write out the header for a SLN file
  324. this->WriteSLNHeader(fout);
  325. // collect the set of targets for this project by
  326. // tracing depends of all targets.
  327. // also collect the set of targets that are explicitly
  328. // in this project.
  329. cmGlobalGenerator::TargetDependSet projectTargets;
  330. cmGlobalGenerator::TargetDependSet originalTargets;
  331. this->GetTargetSets(projectTargets,
  332. originalTargets,
  333. root, generators);
  334. OrderedTargetDependSet orderedProjectTargets(projectTargets);
  335. this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
  336. // Write out the configurations information for the solution
  337. fout << "Global\n"
  338. << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
  339. int c = 0;
  340. for(std::vector<std::string>::iterator i = this->Configurations.begin();
  341. i != this->Configurations.end(); ++i)
  342. {
  343. fout << "\t\tConfigName." << c << " = " << *i << "\n";
  344. c++;
  345. }
  346. fout << "\tEndGlobalSection\n";
  347. // Write out project(target) depends
  348. fout << "\tGlobalSection(ProjectDependencies) = postSolution\n";
  349. this->WriteTargetDepends(fout, orderedProjectTargets);
  350. fout << "\tEndGlobalSection\n";
  351. // Write out the configurations for all the targets in the project
  352. fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n";
  353. this->WriteTargetConfigurations(fout, root, orderedProjectTargets);
  354. fout << "\tEndGlobalSection\n";
  355. // Write the footer for the SLN file
  356. this->WriteSLNFooter(fout);
  357. }
  358. //----------------------------------------------------------------------------
  359. std::string
  360. cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path)
  361. {
  362. // Convert to backslashes. Do not use ConvertToOutputPath because
  363. // we will add quoting ourselves, and we know these projects always
  364. // use windows slashes.
  365. std::string d = path;
  366. std::string::size_type pos = 0;
  367. while((pos = d.find('/', pos)) != d.npos)
  368. {
  369. d[pos++] = '\\';
  370. }
  371. return d;
  372. }
  373. // Write a dsp file into the SLN file,
  374. // Note, that dependencies from executables to
  375. // the libraries it uses are also done here
  376. void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout,
  377. const char* dspname,
  378. const char* dir, cmTarget& target)
  379. {
  380. // check to see if this is a fortran build
  381. const char* ext = ".vcproj";
  382. const char* project =
  383. "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"";
  384. if(this->TargetIsFortranOnly(target))
  385. {
  386. ext = ".vfproj";
  387. project = "Project(\"{6989167D-11E4-40FE-8C1A-2192A86A7E90}\") = \"";
  388. }
  389. fout << project
  390. << dspname << "\", \""
  391. << this->ConvertToSolutionPath(dir)
  392. << "\\" << dspname << ext << "\", \"{"
  393. << this->GetGUID(dspname) << "}\"\nEndProject\n";
  394. }
  395. // Write a dsp file into the SLN file,
  396. // Note, that dependencies from executables to
  397. // the libraries it uses are also done here
  398. void
  399. cmGlobalVisualStudio7Generator
  400. ::WriteProjectDepends(std::ostream& fout,
  401. const char* dspname,
  402. const char*, cmTarget& target)
  403. {
  404. int depcount = 0;
  405. // insert Begin Project Dependency Project_Dep_Name project stuff here
  406. if (target.GetType() != cmTarget::STATIC_LIBRARY)
  407. {
  408. cmTarget::LinkLibraryVectorType::const_iterator j, jend;
  409. j = target.GetLinkLibraries().begin();
  410. jend = target.GetLinkLibraries().end();
  411. for(;j!= jend; ++j)
  412. {
  413. if(j->first != dspname)
  414. {
  415. // is the library part of this SLN ? If so add dependency
  416. if(this->FindTarget(0, j->first.c_str()))
  417. {
  418. std::string guid = this->GetGUID(j->first.c_str());
  419. if(guid.size() == 0)
  420. {
  421. std::string m = "Target: ";
  422. m += dspname;
  423. m += " depends on unknown target: ";
  424. m += j->first.c_str();
  425. cmSystemTools::Error(m.c_str());
  426. }
  427. fout << "\t\t{" << this->GetGUID(dspname) << "}."
  428. << depcount << " = {" << guid << "}\n";
  429. depcount++;
  430. }
  431. }
  432. }
  433. }
  434. std::set<cmStdString>::const_iterator i, end;
  435. // write utility dependencies.
  436. i = target.GetUtilities().begin();
  437. end = target.GetUtilities().end();
  438. for(;i!= end; ++i)
  439. {
  440. if(*i != dspname)
  441. {
  442. std::string name = this->GetUtilityForTarget(target, i->c_str());
  443. std::string guid = this->GetGUID(name.c_str());
  444. if(guid.size() == 0)
  445. {
  446. std::string m = "Target: ";
  447. m += dspname;
  448. m += " depends on unknown target: ";
  449. m += name.c_str();
  450. cmSystemTools::Error(m.c_str());
  451. }
  452. fout << "\t\t{" << this->GetGUID(dspname) << "}." << depcount << " = {"
  453. << guid << "}\n";
  454. depcount++;
  455. }
  456. }
  457. }
  458. // Write a dsp file into the SLN file, Note, that dependencies from
  459. // executables to the libraries it uses are also done here
  460. void cmGlobalVisualStudio7Generator
  461. ::WriteProjectConfigurations(std::ostream& fout, const char* name,
  462. bool partOfDefaultBuild)
  463. {
  464. std::string guid = this->GetGUID(name);
  465. for(std::vector<std::string>::iterator i = this->Configurations.begin();
  466. i != this->Configurations.end(); ++i)
  467. {
  468. fout << "\t\t{" << guid << "}." << *i
  469. << ".ActiveCfg = " << *i << "|Win32\n";
  470. if(partOfDefaultBuild)
  471. {
  472. fout << "\t\t{" << guid << "}." << *i
  473. << ".Build.0 = " << *i << "|Win32\n";
  474. }
  475. }
  476. }
  477. // Write a dsp file into the SLN file,
  478. // Note, that dependencies from executables to
  479. // the libraries it uses are also done here
  480. void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout,
  481. const char* name,
  482. const char* location,
  483. const std::set<cmStdString>&)
  484. {
  485. std::string d = cmSystemTools::ConvertToOutputPath(location);
  486. fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
  487. << name << "\", \""
  488. << this->ConvertToSolutionPath(location) << "\", \"{"
  489. << this->GetGUID(name)
  490. << "}\"\n";
  491. fout << "EndProject\n";
  492. }
  493. // Standard end of dsw file
  494. void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout)
  495. {
  496. fout << "\tGlobalSection(ExtensibilityGlobals) = postSolution\n"
  497. << "\tEndGlobalSection\n"
  498. << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n"
  499. << "\tEndGlobalSection\n"
  500. << "EndGlobal\n";
  501. }
  502. // ouput standard header for dsw file
  503. void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout)
  504. {
  505. fout << "Microsoft Visual Studio Solution File, Format Version 7.00\n";
  506. }
  507. std::string cmGlobalVisualStudio7Generator::GetGUID(const char* name)
  508. {
  509. std::string guidStoreName = name;
  510. guidStoreName += "_GUID_CMAKE";
  511. const char* storedGUID =
  512. this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str());
  513. if(storedGUID)
  514. {
  515. return std::string(storedGUID);
  516. }
  517. cmSystemTools::Error("Unknown Target referenced : ",
  518. name);
  519. return "";
  520. }
  521. void cmGlobalVisualStudio7Generator::CreateGUID(const char* name)
  522. {
  523. std::string guidStoreName = name;
  524. guidStoreName += "_GUID_CMAKE";
  525. if(this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str()))
  526. {
  527. return;
  528. }
  529. std::string ret;
  530. UUID uid;
  531. unsigned char *uidstr;
  532. UuidCreate(&uid);
  533. UuidToString(&uid,&uidstr);
  534. ret = reinterpret_cast<char*>(uidstr);
  535. RpcStringFree(&uidstr);
  536. ret = cmSystemTools::UpperCase(ret);
  537. this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(),
  538. ret.c_str(), "Stored GUID",
  539. cmCacheManager::INTERNAL);
  540. }
  541. std::vector<std::string> *cmGlobalVisualStudio7Generator::GetConfigurations()
  542. {
  543. return &this->Configurations;
  544. };
  545. //----------------------------------------------------------------------------
  546. void cmGlobalVisualStudio7Generator
  547. ::GetDocumentation(cmDocumentationEntry& entry) const
  548. {
  549. entry.Name = this->GetName();
  550. entry.Brief = "Generates Visual Studio .NET 2002 project files.";
  551. entry.Full = "";
  552. }
  553. // make sure "special" targets have GUID's
  554. void cmGlobalVisualStudio7Generator::Configure()
  555. {
  556. cmGlobalGenerator::Configure();
  557. this->CreateGUID("ALL_BUILD");
  558. this->CreateGUID("INSTALL");
  559. this->CreateGUID("RUN_TESTS");
  560. this->CreateGUID("EDIT_CACHE");
  561. this->CreateGUID("REBUILD_CACHE");
  562. this->CreateGUID("PACKAGE");
  563. }
  564. //----------------------------------------------------------------------------
  565. void
  566. cmGlobalVisualStudio7Generator
  567. ::AppendDirectoryForConfig(const char* prefix,
  568. const char* config,
  569. const char* suffix,
  570. std::string& dir)
  571. {
  572. if(config)
  573. {
  574. dir += prefix;
  575. dir += config;
  576. dir += suffix;
  577. }
  578. }
  579. bool cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project,
  580. cmTarget* target)
  581. {
  582. if(target->GetPropertyAsBool("EXCLUDE_FROM_DEFAULT_BUILD"))
  583. {
  584. return false;
  585. }
  586. // if it is a utilitiy target then only make it part of the
  587. // default build if another target depends on it
  588. int type = target->GetType();
  589. if (type == cmTarget::GLOBAL_TARGET)
  590. {
  591. return false;
  592. }
  593. if(type == cmTarget::UTILITY)
  594. {
  595. return this->IsDependedOn(project, target);
  596. }
  597. // default is to be part of the build
  598. return true;
  599. }
  600. //----------------------------------------------------------------------------
  601. bool
  602. cmGlobalVisualStudio7Generator::TargetCompare
  603. ::operator()(cmTarget const* l, cmTarget const* r)
  604. {
  605. // Make sure ALL_BUILD is first so it is the default active project.
  606. if(strcmp(r->GetName(), "ALL_BUILD") == 0)
  607. {
  608. return false;
  609. }
  610. if(strcmp(l->GetName(), "ALL_BUILD") == 0)
  611. {
  612. return true;
  613. }
  614. return strcmp(l->GetName(), r->GetName()) < 0;
  615. }
  616. //----------------------------------------------------------------------------
  617. cmGlobalVisualStudio7Generator::OrderedTargetDependSet
  618. ::OrderedTargetDependSet(cmGlobalGenerator::TargetDependSet const& targets)
  619. {
  620. for(cmGlobalGenerator::TargetDependSet::const_iterator ti =
  621. targets.begin(); ti != targets.end(); ++ti)
  622. {
  623. this->insert(*ti);
  624. }
  625. }
  626. //----------------------------------------------------------------------------
  627. static cmVS7FlagTable cmVS7ExtraFlagTable[] =
  628. {
  629. // Precompiled header and related options. Note that the
  630. // UsePrecompiledHeader entries are marked as "Continue" so that the
  631. // corresponding PrecompiledHeaderThrough entry can be found.
  632. {"UsePrecompiledHeader", "YX", "Automatically Generate", "2",
  633. cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
  634. {"PrecompiledHeaderThrough", "YX", "Precompiled Header Name", "",
  635. cmVS7FlagTable::UserValueRequired},
  636. {"UsePrecompiledHeader", "Yu", "Use Precompiled Header", "3",
  637. cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
  638. {"PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "",
  639. cmVS7FlagTable::UserValueRequired},
  640. {"WholeProgramOptimization", "LTCG", "WholeProgramOptimization", "TRUE", 0},
  641. // Exception handling mode. If no entries match, it will be FALSE.
  642. {"ExceptionHandling", "GX", "enable c++ exceptions", "TRUE", 0},
  643. {"ExceptionHandling", "EHsc", "enable c++ exceptions", "TRUE", 0},
  644. // The EHa option does not have an IDE setting. Let it go to false,
  645. // and have EHa passed on the command line by leaving out the table
  646. // entry.
  647. {0,0,0,0,0}
  648. };
  649. cmIDEFlagTable const* cmGlobalVisualStudio7Generator::GetExtraFlagTableVS7()
  650. {
  651. return cmVS7ExtraFlagTable;
  652. }