1
0

cmGlobalVisualStudio7Generator.cxx 22 KB

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