cmLocalVisualStudio6Generator.cxx 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  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 "cmGlobalGenerator.h"
  14. #include "cmLocalVisualStudio6Generator.h"
  15. #include "cmMakefile.h"
  16. #include "cmSystemTools.h"
  17. #include "cmSourceFile.h"
  18. #include "cmCacheManager.h"
  19. #include "cmake.h"
  20. #include <cmsys/RegularExpression.hxx>
  21. cmLocalVisualStudio6Generator::cmLocalVisualStudio6Generator()
  22. {
  23. }
  24. cmLocalVisualStudio6Generator::~cmLocalVisualStudio6Generator()
  25. {
  26. }
  27. void cmLocalVisualStudio6Generator::Generate()
  28. {
  29. std::set<cmStdString> lang;
  30. lang.insert("C");
  31. lang.insert("CXX");
  32. this->CreateCustomTargetsAndCommands(lang);
  33. this->OutputDSPFile();
  34. }
  35. void cmLocalVisualStudio6Generator::OutputDSPFile()
  36. {
  37. // If not an in source build, then create the output directory
  38. if(strcmp(m_Makefile->GetStartOutputDirectory(),
  39. m_Makefile->GetHomeDirectory()) != 0)
  40. {
  41. if(!cmSystemTools::MakeDirectory(m_Makefile->GetStartOutputDirectory()))
  42. {
  43. cmSystemTools::Error("Error creating directory ",
  44. m_Makefile->GetStartOutputDirectory());
  45. }
  46. }
  47. // Setup /I and /LIBPATH options for the resulting DSP file
  48. std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
  49. std::vector<std::string>::iterator i;
  50. for(i = includes.begin(); i != includes.end(); ++i)
  51. {
  52. m_IncludeOptions += " /I ";
  53. std::string tmp = this->ConvertToOptionallyRelativeOutputPath(i->c_str());
  54. // quote if not already quoted
  55. if (tmp[0] != '"')
  56. {
  57. m_IncludeOptions += "\"";
  58. m_IncludeOptions += tmp;
  59. m_IncludeOptions += "\"";
  60. }
  61. else
  62. {
  63. m_IncludeOptions += tmp;
  64. }
  65. }
  66. // Create the DSP or set of DSP's for libraries and executables
  67. // clear project names
  68. m_CreatedProjectNames.clear();
  69. // build any targets
  70. cmTargets &tgts = m_Makefile->GetTargets();
  71. for(cmTargets::iterator l = tgts.begin();
  72. l != tgts.end(); l++)
  73. {
  74. switch(l->second.GetType())
  75. {
  76. case cmTarget::STATIC_LIBRARY:
  77. this->SetBuildType(STATIC_LIBRARY, l->first.c_str(), l->second);
  78. break;
  79. case cmTarget::SHARED_LIBRARY:
  80. case cmTarget::MODULE_LIBRARY:
  81. this->SetBuildType(DLL, l->first.c_str(), l->second);
  82. break;
  83. case cmTarget::EXECUTABLE:
  84. this->SetBuildType(EXECUTABLE,l->first.c_str(), l->second);
  85. break;
  86. case cmTarget::UTILITY:
  87. this->SetBuildType(UTILITY, l->first.c_str(), l->second);
  88. break;
  89. case cmTarget::INSTALL_FILES:
  90. break;
  91. case cmTarget::INSTALL_PROGRAMS:
  92. break;
  93. default:
  94. cmSystemTools::Error("Bad target type", l->first.c_str());
  95. break;
  96. }
  97. // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
  98. // so don't build a projectfile for it
  99. if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  100. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)
  101. && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0))
  102. {
  103. // check to see if the dsp is going into a sub-directory
  104. std::string::size_type pos = l->first.rfind('/');
  105. if(pos != std::string::npos)
  106. {
  107. std::string dir = m_Makefile->GetStartOutputDirectory();
  108. dir += "/";
  109. dir += l->first.substr(0, pos);
  110. if(!cmSystemTools::MakeDirectory(dir.c_str()))
  111. {
  112. cmSystemTools::Error("Error creating directory ", dir.c_str());
  113. }
  114. }
  115. this->CreateSingleDSP(l->first.c_str(),l->second);
  116. }
  117. }
  118. }
  119. void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname, cmTarget &target)
  120. {
  121. // add to the list of projects
  122. std::string pname = lname;
  123. m_CreatedProjectNames.push_back(pname);
  124. // create the dsp.cmake file
  125. std::string fname;
  126. fname = m_Makefile->GetStartOutputDirectory();
  127. fname += "/";
  128. fname += lname;
  129. fname += ".dsp";
  130. // save the name of the real dsp file
  131. std::string realDSP = fname;
  132. fname += ".cmake";
  133. std::ofstream fout(fname.c_str());
  134. if(!fout)
  135. {
  136. cmSystemTools::Error("Error Writing ", fname.c_str());
  137. cmSystemTools::ReportLastSystemError("");
  138. }
  139. this->WriteDSPFile(fout,lname,target);
  140. fout.close();
  141. // if the dsp file has changed, then write it.
  142. cmSystemTools::CopyFileIfDifferent(fname.c_str(), realDSP.c_str());
  143. }
  144. void cmLocalVisualStudio6Generator::AddDSPBuildRule()
  145. {
  146. std::string dspname = *(m_CreatedProjectNames.end()-1);
  147. dspname += ".dsp.cmake";
  148. const char* dsprule = m_Makefile->GetRequiredDefinition("CMAKE_COMMAND");
  149. cmCustomCommandLine commandLine;
  150. commandLine.push_back(dsprule);
  151. std::string makefileIn = m_Makefile->GetStartDirectory();
  152. makefileIn += "/";
  153. makefileIn += "CMakeLists.txt";
  154. std::string args;
  155. args = "-H";
  156. args +=
  157. this->Convert(m_Makefile->GetHomeDirectory(),START_OUTPUT, SHELL, true);
  158. commandLine.push_back(args);
  159. args = "-B";
  160. args +=
  161. this->Convert(m_Makefile->GetHomeOutputDirectory(),
  162. START_OUTPUT, SHELL, true);
  163. commandLine.push_back(args);
  164. std::string configFile =
  165. m_Makefile->GetRequiredDefinition("CMAKE_ROOT");
  166. configFile += "/Templates/CMakeWindowsSystemConfig.cmake";
  167. std::vector<std::string> listFiles = m_Makefile->GetListFiles();
  168. bool found = false;
  169. for(std::vector<std::string>::iterator i = listFiles.begin();
  170. i != listFiles.end(); ++i)
  171. {
  172. if(*i == configFile)
  173. {
  174. found = true;
  175. }
  176. }
  177. if(!found)
  178. {
  179. listFiles.push_back(configFile);
  180. }
  181. cmCustomCommandLines commandLines;
  182. commandLines.push_back(commandLine);
  183. const char* no_comment = 0;
  184. m_Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles, makefileIn.c_str(),
  185. commandLines, no_comment, true);
  186. }
  187. void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
  188. const char *libName,
  189. cmTarget &target)
  190. {
  191. // if we should add regen rule then...
  192. const char *suppRegenRule =
  193. m_Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION");
  194. if (!cmSystemTools::IsOn(suppRegenRule))
  195. {
  196. this->AddDSPBuildRule();
  197. }
  198. // For utility targets need custom command since pre- and post-
  199. // build does not do anything in Visual Studio 6. In order for the
  200. // rules to run in the correct order as custom commands, we need
  201. // special care for dependencies. The first rule must depend on all
  202. // the dependencies of all the rules. The later rules must each
  203. // depend only on the previous rule.
  204. if (target.GetType() == cmTarget::UTILITY &&
  205. (!target.GetPreBuildCommands().empty() ||
  206. !target.GetPostBuildCommands().empty()))
  207. {
  208. // Accumulate the dependencies of all the commands.
  209. std::vector<std::string> depends;
  210. for (std::vector<cmCustomCommand>::const_iterator cr =
  211. target.GetPreBuildCommands().begin();
  212. cr != target.GetPreBuildCommands().end(); ++cr)
  213. {
  214. depends.insert(depends.end(),
  215. cr->GetDepends().begin(), cr->GetDepends().end());
  216. }
  217. for (std::vector<cmCustomCommand>::const_iterator cr =
  218. target.GetPostBuildCommands().begin();
  219. cr != target.GetPostBuildCommands().end(); ++cr)
  220. {
  221. depends.insert(depends.end(),
  222. cr->GetDepends().begin(), cr->GetDepends().end());
  223. }
  224. // Add the pre- and post-build commands in order.
  225. int count = 1;
  226. for (std::vector<cmCustomCommand>::const_iterator cr =
  227. target.GetPreBuildCommands().begin();
  228. cr != target.GetPreBuildCommands().end(); ++cr)
  229. {
  230. this->AddUtilityCommandHack(target, count++, depends,
  231. cr->GetCommandLines());
  232. }
  233. for (std::vector<cmCustomCommand>::const_iterator cr =
  234. target.GetPostBuildCommands().begin();
  235. cr != target.GetPostBuildCommands().end(); ++cr)
  236. {
  237. this->AddUtilityCommandHack(target, count++, depends,
  238. cr->GetCommandLines());
  239. }
  240. }
  241. // trace the visual studio dependencies
  242. std::string name = libName;
  243. name += ".dsp.cmake";
  244. target.TraceVSDependencies(name, m_Makefile);
  245. // We may be modifying the source groups temporarily, so make a copy.
  246. std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups();
  247. // get the classes from the source lists then add them to the groups
  248. std::vector<cmSourceFile*> & classes = target.GetSourceFiles();
  249. // now all of the source files have been properly assigned to the target
  250. // now stick them into source groups using the reg expressions
  251. for(std::vector<cmSourceFile*>::iterator i = classes.begin();
  252. i != classes.end(); i++)
  253. {
  254. // Add the file to the list of sources.
  255. std::string source = (*i)->GetFullPath();
  256. cmSourceGroup& sourceGroup = m_Makefile->FindSourceGroup(source.c_str(),
  257. sourceGroups);
  258. sourceGroup.AssignSource(*i);
  259. // while we are at it, if it is a .rule file then for visual studio 6 we
  260. // must generate it
  261. if ((*i)->GetSourceExtension() == "rule")
  262. {
  263. if(!cmSystemTools::FileExists(source.c_str()))
  264. {
  265. cmSystemTools::ReplaceString(source, "$(IntDir)/", "");
  266. #if defined(_WIN32) || defined(__CYGWIN__)
  267. std::ofstream fout(source.c_str(),
  268. std::ios::binary | std::ios::out | std::ios::trunc);
  269. #else
  270. std::ofstream fout(source.c_str(),
  271. std::ios::out | std::ios::trunc);
  272. #endif
  273. if(fout)
  274. {
  275. fout.write("# generated from CMake",22);
  276. fout.flush();
  277. fout.close();
  278. }
  279. }
  280. }
  281. }
  282. // Write the DSP file's header.
  283. this->WriteDSPHeader(fout, libName, target, sourceGroups);
  284. // Loop through every source group.
  285. for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin();
  286. sg != sourceGroups.end(); ++sg)
  287. {
  288. const std::vector<const cmSourceFile *> &sourceFiles =
  289. sg->GetSourceFiles();
  290. // If the group is empty, don't write it at all.
  291. if(sourceFiles.empty())
  292. {
  293. continue;
  294. }
  295. // If the group has a name, write the header.
  296. std::string name = sg->GetName();
  297. if(name != "")
  298. {
  299. this->WriteDSPBeginGroup(fout, name.c_str(), "");
  300. }
  301. // Loop through each source in the source group.
  302. for(std::vector<const cmSourceFile *>::const_iterator sf =
  303. sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
  304. {
  305. std::string source = (*sf)->GetFullPath();
  306. const cmCustomCommand *command =
  307. (*sf)->GetCustomCommand();
  308. std::string compileFlags;
  309. std::vector<std::string> depends;
  310. const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS");
  311. if(cflags)
  312. {
  313. compileFlags = cflags;
  314. }
  315. const char* lang =
  316. m_GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str());
  317. if(lang && strcmp(lang, "CXX") == 0)
  318. {
  319. // force a C++ file type
  320. compileFlags += " /TP ";
  321. }
  322. // Check for extra object-file dependencies.
  323. const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS");
  324. if(dependsValue)
  325. {
  326. cmSystemTools::ExpandListArgument(dependsValue, depends);
  327. }
  328. if (source != libName || target.GetType() == cmTarget::UTILITY)
  329. {
  330. fout << "# Begin Source File\n\n";
  331. // Tell MS-Dev what the source is. If the compiler knows how to
  332. // build it, then it will.
  333. fout << "SOURCE=" <<
  334. this->ConvertToOptionallyRelativeOutputPath(source.c_str()) << "\n\n";
  335. if(!depends.empty())
  336. {
  337. // Write out the dependencies for the rule.
  338. fout << "USERDEP__HACK=";
  339. for(std::vector<std::string>::const_iterator d = depends.begin();
  340. d != depends.end(); ++d)
  341. {
  342. fout << "\\\n\t" <<
  343. this->ConvertToOptionallyRelativeOutputPath(d->c_str());
  344. }
  345. fout << "\n";
  346. }
  347. if (command)
  348. {
  349. std::string script =
  350. this->ConstructScript(command->GetCommandLines(), "\\\n\t");
  351. const char* comment = command->GetComment();
  352. const char* flags = compileFlags.size() ? compileFlags.c_str(): 0;
  353. this->WriteCustomRule(fout, source.c_str(), script.c_str(),
  354. (*comment?comment:"Custom Rule"),
  355. command->GetDepends(),
  356. command->GetOutput(), flags);
  357. }
  358. else if(compileFlags.size())
  359. {
  360. for(std::vector<std::string>::iterator i
  361. = m_Configurations.begin(); i != m_Configurations.end(); ++i)
  362. {
  363. if (i == m_Configurations.begin())
  364. {
  365. fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl;
  366. }
  367. else
  368. {
  369. fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl;
  370. }
  371. fout << "\n# ADD CPP " << compileFlags << "\n\n";
  372. }
  373. fout << "!ENDIF\n\n";
  374. }
  375. fout << "# End Source File\n";
  376. }
  377. }
  378. // If the group has a name, write the footer.
  379. if(name != "")
  380. {
  381. this->WriteDSPEndGroup(fout);
  382. }
  383. }
  384. // Write the DSP file's footer.
  385. this->WriteDSPFooter(fout);
  386. }
  387. void
  388. cmLocalVisualStudio6Generator
  389. ::AddUtilityCommandHack(cmTarget& target, int count,
  390. std::vector<std::string>& depends,
  391. const cmCustomCommandLines& commandLines)
  392. {
  393. // Create a fake output that forces the rule to run.
  394. char* output = new char[(strlen(m_Makefile->GetStartOutputDirectory()) +
  395. strlen(target.GetName()) + 30)];
  396. sprintf(output,"%s/%s_force_%i", m_Makefile->GetStartOutputDirectory(),
  397. target.GetName(), count);
  398. // Add the rule with the given dependencies and commands.
  399. const char* no_main_dependency = 0;
  400. const char* no_comment = 0;
  401. m_Makefile->AddCustomCommandToOutput(output,
  402. depends,
  403. no_main_dependency,
  404. commandLines,
  405. no_comment);
  406. // Replace the dependencies with the output of this rule so that the
  407. // next rule added will run after this one.
  408. depends.clear();
  409. depends.push_back(output);
  410. // Add a source file representing this output to the project.
  411. cmSourceFile* outsf = m_Makefile->GetSourceFileWithOutput(output);
  412. target.GetSourceFiles().push_back(outsf);
  413. // Free the fake output name.
  414. delete [] output;
  415. }
  416. void cmLocalVisualStudio6Generator::WriteCustomRule(std::ostream& fout,
  417. const char* source,
  418. const char* command,
  419. const char* comment,
  420. const std::vector<std::string>& depends,
  421. const char *output,
  422. const char* flags
  423. )
  424. {
  425. std::vector<std::string>::iterator i;
  426. for(i = m_Configurations.begin(); i != m_Configurations.end(); ++i)
  427. {
  428. if (i == m_Configurations.begin())
  429. {
  430. fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl;
  431. }
  432. else
  433. {
  434. fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl;
  435. }
  436. if(flags)
  437. {
  438. fout << "\n# ADD CPP " << flags << "\n\n";
  439. }
  440. // Write out the dependencies for the rule.
  441. fout << "USERDEP__HACK=";
  442. for(std::vector<std::string>::const_iterator d = depends.begin();
  443. d != depends.end(); ++d)
  444. {
  445. std::string dep = cmSystemTools::GetFilenameName(*d);
  446. if (cmSystemTools::GetFilenameLastExtension(dep) == ".exe")
  447. {
  448. dep = cmSystemTools::GetFilenameWithoutLastExtension(dep);
  449. }
  450. std::string libPath = dep + "_CMAKE_PATH";
  451. const char* cacheValue = m_Makefile->GetDefinition(libPath.c_str());
  452. if (cacheValue && *cacheValue)
  453. {
  454. std::string exePath = "";
  455. if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
  456. {
  457. exePath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
  458. }
  459. if(exePath.size())
  460. {
  461. libPath = exePath;
  462. }
  463. else
  464. {
  465. libPath = cacheValue;
  466. }
  467. libPath += "/";
  468. libPath += "$(INTDIR)/";
  469. libPath += dep;
  470. libPath += ".exe";
  471. fout << "\\\n\t" <<
  472. this->ConvertToOptionallyRelativeOutputPath(libPath.c_str());
  473. }
  474. else
  475. {
  476. fout << "\\\n\t" <<
  477. this->ConvertToOptionallyRelativeOutputPath(d->c_str());
  478. }
  479. }
  480. fout << "\n";
  481. fout << "# PROP Ignore_Default_Tool 1\n";
  482. fout << "# Begin Custom Build - Building " << comment
  483. << " $(InputPath)\n\n";
  484. if(output == 0)
  485. {
  486. fout << source << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t";
  487. fout << command << "\n\n";
  488. }
  489. // Write a rule for every output generated by this command.
  490. fout << this->ConvertToOptionallyRelativeOutputPath(output)
  491. << " : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t";
  492. fout << command << "\n\n";
  493. fout << "# End Custom Build\n\n";
  494. }
  495. fout << "!ENDIF\n\n";
  496. }
  497. void cmLocalVisualStudio6Generator::WriteDSPBeginGroup(std::ostream& fout,
  498. const char* group,
  499. const char* filter)
  500. {
  501. fout << "# Begin Group \"" << group << "\"\n"
  502. "# PROP Default_Filter \"" << filter << "\"\n";
  503. }
  504. void cmLocalVisualStudio6Generator::WriteDSPEndGroup(std::ostream& fout)
  505. {
  506. fout << "# End Group\n";
  507. }
  508. void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
  509. const char* libName,
  510. cmTarget& target)
  511. {
  512. std::string root= m_Makefile->GetRequiredDefinition("CMAKE_ROOT");
  513. const char *def= m_Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY");
  514. if( def)
  515. {
  516. root = def;
  517. }
  518. else
  519. {
  520. root += "/Templates";
  521. }
  522. switch(b)
  523. {
  524. case STATIC_LIBRARY:
  525. m_DSPHeaderTemplate = root;
  526. m_DSPHeaderTemplate += "/staticLibHeader.dsptemplate";
  527. m_DSPFooterTemplate = root;
  528. m_DSPFooterTemplate += "/staticLibFooter.dsptemplate";
  529. break;
  530. case DLL:
  531. m_DSPHeaderTemplate = root;
  532. m_DSPHeaderTemplate += "/DLLHeader.dsptemplate";
  533. m_DSPFooterTemplate = root;
  534. m_DSPFooterTemplate += "/DLLFooter.dsptemplate";
  535. break;
  536. case EXECUTABLE:
  537. if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") )
  538. {
  539. m_DSPHeaderTemplate = root;
  540. m_DSPHeaderTemplate += "/EXEWinHeader.dsptemplate";
  541. m_DSPFooterTemplate = root;
  542. m_DSPFooterTemplate += "/EXEFooter.dsptemplate";
  543. }
  544. else
  545. {
  546. m_DSPHeaderTemplate = root;
  547. m_DSPHeaderTemplate += "/EXEHeader.dsptemplate";
  548. m_DSPFooterTemplate = root;
  549. m_DSPFooterTemplate += "/EXEFooter.dsptemplate";
  550. }
  551. break;
  552. case UTILITY:
  553. m_DSPHeaderTemplate = root;
  554. m_DSPHeaderTemplate += "/UtilityHeader.dsptemplate";
  555. m_DSPFooterTemplate = root;
  556. m_DSPFooterTemplate += "/UtilityFooter.dsptemplate";
  557. break;
  558. }
  559. // once the build type is set, determine what configurations are
  560. // possible
  561. std::ifstream fin(m_DSPHeaderTemplate.c_str());
  562. cmsys::RegularExpression reg("# Name ");
  563. if(!fin)
  564. {
  565. cmSystemTools::Error("Error Reading ", m_DSPHeaderTemplate.c_str());
  566. }
  567. // reset m_Configurations
  568. m_Configurations.erase(m_Configurations.begin(), m_Configurations.end());
  569. // now add all the configurations possible
  570. std::string line;
  571. while(cmSystemTools::GetLineFromStream(fin, line))
  572. {
  573. cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName);
  574. if (reg.find(line))
  575. {
  576. m_Configurations.push_back(line.substr(reg.end()));
  577. }
  578. }
  579. }
  580. // look for custom rules on a target and collect them together
  581. std::string
  582. cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target,
  583. const char * /* libName */)
  584. {
  585. std::string customRuleCode = "";
  586. if (target.GetType() >= cmTarget::UTILITY)
  587. {
  588. return customRuleCode;
  589. }
  590. // are there any rules?
  591. if (target.GetPreBuildCommands().size() +
  592. target.GetPreLinkCommands().size() +
  593. target.GetPostBuildCommands().size() == 0)
  594. {
  595. return customRuleCode;
  596. }
  597. customRuleCode = "# Begin Special Build Tool\n";
  598. // Write the pre-build and pre-link together (VS6 does not support
  599. // both). Make sure no continuation character is put on the last
  600. // line.
  601. int prelink_total = (static_cast<int>(target.GetPreBuildCommands().size())+
  602. static_cast<int>(target.GetPreLinkCommands().size()));
  603. int prelink_count = 0;
  604. if(prelink_total > 0)
  605. {
  606. // header stuff
  607. customRuleCode += "PreLink_Cmds=";
  608. }
  609. const char* prelink_newline = "\\\n\t";
  610. for (std::vector<cmCustomCommand>::const_iterator cr =
  611. target.GetPreBuildCommands().begin();
  612. cr != target.GetPreBuildCommands().end(); ++cr)
  613. {
  614. if(++prelink_count == prelink_total)
  615. {
  616. prelink_newline = "";
  617. }
  618. customRuleCode += this->ConstructScript(cr->GetCommandLines(),
  619. prelink_newline);
  620. }
  621. for (std::vector<cmCustomCommand>::const_iterator cr =
  622. target.GetPreLinkCommands().begin();
  623. cr != target.GetPreLinkCommands().end(); ++cr)
  624. {
  625. if(++prelink_count == prelink_total)
  626. {
  627. prelink_newline = "";
  628. }
  629. customRuleCode += this->ConstructScript(cr->GetCommandLines(),
  630. prelink_newline);
  631. }
  632. if(prelink_total > 0)
  633. {
  634. customRuleCode += "\n";
  635. }
  636. // Write the post-build rules. Make sure no continuation character
  637. // is put on the last line.
  638. int postbuild_total = static_cast<int>(target.GetPostBuildCommands().size());
  639. int postbuild_count = 0;
  640. const char* postbuild_newline = "\\\n\t";
  641. if(postbuild_total > 0)
  642. {
  643. customRuleCode += "PostBuild_Cmds=";
  644. }
  645. for (std::vector<cmCustomCommand>::const_iterator cr =
  646. target.GetPostBuildCommands().begin();
  647. cr != target.GetPostBuildCommands().end(); ++cr)
  648. {
  649. if(++postbuild_count == postbuild_total)
  650. {
  651. postbuild_newline = "";
  652. }
  653. customRuleCode += this->ConstructScript(cr->GetCommandLines(),
  654. postbuild_newline);
  655. }
  656. if(postbuild_total > 0)
  657. {
  658. customRuleCode += "\n";
  659. }
  660. customRuleCode += "# End Special Build Tool\n";
  661. return customRuleCode;
  662. }
  663. inline std::string removeQuotes(const std::string& s)
  664. {
  665. if(s[0] == '\"' && s[s.size()-1] == '\"')
  666. {
  667. return s.substr(1, s.size()-2);
  668. }
  669. return s;
  670. }
  671. void cmLocalVisualStudio6Generator
  672. ::WriteDSPHeader(std::ostream& fout,
  673. const char *libName, cmTarget &target,
  674. std::vector<cmSourceGroup> &)
  675. {
  676. std::set<std::string> pathEmitted;
  677. // determine the link directories
  678. std::string libOptions;
  679. std::string libDebugOptions;
  680. std::string libOptimizedOptions;
  681. std::string libMultiLineOptions;
  682. std::string libMultiLineOptionsForDebug;
  683. std::string libMultiLineDebugOptions;
  684. std::string libMultiLineOptimizedOptions;
  685. // suppoirt override in output directory
  686. std::string libPath = "";
  687. if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
  688. {
  689. libPath = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
  690. }
  691. std::string exePath = "";
  692. if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
  693. {
  694. exePath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
  695. }
  696. if(libPath.size())
  697. {
  698. // make sure there is a trailing slash
  699. if(libPath[libPath.size()-1] != '/')
  700. {
  701. libPath += "/";
  702. }
  703. std::string lpath =
  704. this->ConvertToOptionallyRelativeOutputPath(libPath.c_str());
  705. if(lpath.size() == 0)
  706. {
  707. lpath = ".";
  708. }
  709. std::string lpathIntDir = libPath + "$(INTDIR)";
  710. lpathIntDir = this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str());
  711. if(pathEmitted.insert(lpath).second)
  712. {
  713. libOptions += " /LIBPATH:";
  714. libOptions += lpathIntDir;
  715. libOptions += " ";
  716. libOptions += " /LIBPATH:";
  717. libOptions += lpath;
  718. libOptions += " ";
  719. libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
  720. libMultiLineOptions += lpathIntDir;
  721. libMultiLineOptions += " ";
  722. libMultiLineOptions += " /LIBPATH:";
  723. libMultiLineOptions += lpath;
  724. libMultiLineOptions += " \n";
  725. libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
  726. libMultiLineOptionsForDebug += lpathIntDir;
  727. libMultiLineOptionsForDebug += " ";
  728. libMultiLineOptionsForDebug += " /LIBPATH:";
  729. libMultiLineOptionsForDebug += lpath;
  730. libMultiLineOptionsForDebug += " \n";
  731. }
  732. }
  733. if(exePath.size())
  734. {
  735. // make sure there is a trailing slash
  736. if(exePath[exePath.size()-1] != '/')
  737. {
  738. exePath += "/";
  739. }
  740. std::string lpath =
  741. this->ConvertToOptionallyRelativeOutputPath(exePath.c_str());
  742. if(lpath.size() == 0)
  743. {
  744. lpath = ".";
  745. }
  746. std::string lpathIntDir = exePath + "$(INTDIR)";
  747. lpathIntDir = this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str());
  748. if(pathEmitted.insert(lpath).second)
  749. {
  750. libOptions += " /LIBPATH:";
  751. libOptions += lpathIntDir;
  752. libOptions += " ";
  753. libOptions += " /LIBPATH:";
  754. libOptions += lpath;
  755. libOptions += " ";
  756. libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
  757. libMultiLineOptions += lpathIntDir;
  758. libMultiLineOptions += " ";
  759. libMultiLineOptions += " /LIBPATH:";
  760. libMultiLineOptions += lpath;
  761. libMultiLineOptions += " \n";
  762. libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
  763. libMultiLineOptionsForDebug += lpathIntDir;
  764. libMultiLineOptionsForDebug += " ";
  765. libMultiLineOptionsForDebug += " /LIBPATH:";
  766. libMultiLineOptionsForDebug += lpath;
  767. libMultiLineOptionsForDebug += " \n";
  768. }
  769. }
  770. std::vector<std::string>::const_iterator i;
  771. const std::vector<std::string>& libdirs = target.GetLinkDirectories();
  772. for(i = libdirs.begin(); i != libdirs.end(); ++i)
  773. {
  774. std::string path = *i;
  775. if(path[path.size()-1] != '/')
  776. {
  777. path += "/";
  778. }
  779. std::string lpath =
  780. this->ConvertToOptionallyRelativeOutputPath(path.c_str());
  781. if(lpath.size() == 0)
  782. {
  783. lpath = ".";
  784. }
  785. std::string lpathIntDir = path + "$(INTDIR)";
  786. lpathIntDir = this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str());
  787. if(pathEmitted.insert(lpath).second)
  788. {
  789. libOptions += " /LIBPATH:";
  790. libOptions += lpathIntDir;
  791. libOptions += " ";
  792. libOptions += " /LIBPATH:";
  793. libOptions += lpath;
  794. libOptions += " ";
  795. libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
  796. libMultiLineOptions += lpathIntDir;
  797. libMultiLineOptions += " ";
  798. libMultiLineOptions += " /LIBPATH:";
  799. libMultiLineOptions += lpath;
  800. libMultiLineOptions += " \n";
  801. libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
  802. libMultiLineOptionsForDebug += lpathIntDir;
  803. libMultiLineOptionsForDebug += " ";
  804. libMultiLineOptionsForDebug += " /LIBPATH:";
  805. libMultiLineOptionsForDebug += lpath;
  806. libMultiLineOptionsForDebug += " \n";
  807. }
  808. }
  809. // find link libraries
  810. const cmTarget::LinkLibraries& libs = target.GetLinkLibraries();
  811. cmTarget::LinkLibraries::const_iterator j;
  812. for(j = libs.begin(); j != libs.end(); ++j)
  813. {
  814. // add libraries to executables and dlls (but never include
  815. // a library in a library, bad recursion)
  816. if ((target.GetType() != cmTarget::SHARED_LIBRARY
  817. && target.GetType() != cmTarget::STATIC_LIBRARY
  818. && target.GetType() != cmTarget::MODULE_LIBRARY) ||
  819. (target.GetType()==cmTarget::SHARED_LIBRARY && libName != j->first) ||
  820. (target.GetType()==cmTarget::MODULE_LIBRARY && libName != j->first))
  821. {
  822. std::string lib = j->first;
  823. std::string libDebug = j->first;
  824. std::string libPath = j->first + "_CMAKE_PATH";
  825. const char* cacheValue
  826. = m_GlobalGenerator->GetCMakeInstance()->GetCacheDefinition(
  827. libPath.c_str());
  828. if ( cacheValue && *cacheValue && m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX") )
  829. {
  830. libDebug += m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
  831. }
  832. if(j->first.find(".lib") == std::string::npos)
  833. {
  834. lib += ".lib";
  835. libDebug += ".lib";
  836. }
  837. lib = this->ConvertToOptionallyRelativeOutputPath(lib.c_str());
  838. libDebug = this->ConvertToOptionallyRelativeOutputPath(libDebug.c_str());
  839. if (j->second == cmTarget::GENERAL)
  840. {
  841. libOptions += " ";
  842. libOptions += lib;
  843. libMultiLineOptions += "# ADD LINK32 ";
  844. libMultiLineOptions += lib;
  845. libMultiLineOptions += "\n";
  846. libMultiLineOptionsForDebug += "# ADD LINK32 ";
  847. libMultiLineOptionsForDebug += libDebug;
  848. libMultiLineOptionsForDebug += "\n";
  849. }
  850. if (j->second == cmTarget::DEBUG)
  851. {
  852. libDebugOptions += " ";
  853. libDebugOptions += lib;
  854. libMultiLineDebugOptions += "# ADD LINK32 ";
  855. libMultiLineDebugOptions += libDebug;
  856. libMultiLineDebugOptions += "\n";
  857. }
  858. if (j->second == cmTarget::OPTIMIZED)
  859. {
  860. libOptimizedOptions += " ";
  861. libOptimizedOptions += lib;
  862. libMultiLineOptimizedOptions += "# ADD LINK32 ";
  863. libMultiLineOptimizedOptions += lib;
  864. libMultiLineOptimizedOptions += "\n";
  865. }
  866. }
  867. }
  868. std::string extraLinkOptions;
  869. if(target.GetType() == cmTarget::EXECUTABLE)
  870. {
  871. extraLinkOptions =
  872. m_Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS");
  873. // if the executable has an output name then add the appropriate flag
  874. if (target.GetProperty("OUTPUT_NAME"))
  875. {
  876. libMultiLineOptions += "# ADD LINK32 /out:";
  877. libMultiLineOptions += target.GetProperty("OUTPUT_NAME");
  878. libMultiLineOptions += " \n";
  879. }
  880. }
  881. if(target.GetType() == cmTarget::SHARED_LIBRARY)
  882. {
  883. extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS");
  884. }
  885. if(target.GetType() == cmTarget::MODULE_LIBRARY)
  886. {
  887. extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS");
  888. }
  889. if(extraLinkOptions.size())
  890. {
  891. libOptions += " ";
  892. libOptions += extraLinkOptions;
  893. libOptions += " ";
  894. libMultiLineOptions += "# ADD LINK32 ";
  895. libMultiLineOptions += extraLinkOptions;
  896. libMultiLineOptions += " \n";
  897. libMultiLineOptionsForDebug += "# ADD LINK32 ";
  898. libMultiLineOptionsForDebug += extraLinkOptions;
  899. libMultiLineOptionsForDebug += " \n";
  900. }
  901. if(const char* stdLibs = m_Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES"))
  902. {
  903. libOptions += " ";
  904. libOptions += stdLibs;
  905. libOptions += " ";
  906. libMultiLineOptions += "# ADD LINK32 ";
  907. libMultiLineOptions += stdLibs;
  908. libMultiLineOptions += " \n";
  909. libMultiLineOptionsForDebug += "# ADD LINK32 ";
  910. libMultiLineOptionsForDebug += stdLibs;
  911. libMultiLineOptionsForDebug += " \n";
  912. }
  913. if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"))
  914. {
  915. libOptions += " ";
  916. libOptions += targetLinkFlags;
  917. libOptions += " ";
  918. libMultiLineOptions += "# ADD LINK32 ";
  919. libMultiLineOptions += targetLinkFlags;
  920. libMultiLineOptions += " \n";
  921. libMultiLineOptionsForDebug += "# ADD LINK32 ";
  922. libMultiLineOptionsForDebug += targetLinkFlags;
  923. libMultiLineOptionsForDebug += " \n";
  924. }
  925. // are there any custom rules on the target itself
  926. // only if the target is a lib or exe
  927. std::string customRuleCode = this->CreateTargetRules(target, libName);
  928. std::ifstream fin(m_DSPHeaderTemplate.c_str());
  929. if(!fin)
  930. {
  931. cmSystemTools::Error("Error Reading ", m_DSPHeaderTemplate.c_str());
  932. }
  933. std::string staticLibOptions;
  934. if(target.GetType() == cmTarget::STATIC_LIBRARY )
  935. {
  936. if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
  937. {
  938. staticLibOptions = libflags;
  939. }
  940. }
  941. std::string exportSymbol;
  942. if (const char* custom_export_name = target.GetProperty("DEFINE_SYMBOL"))
  943. {
  944. exportSymbol = custom_export_name;
  945. }
  946. else
  947. {
  948. std::string in = libName;
  949. in += "_EXPORTS";
  950. exportSymbol = cmSystemTools::MakeCindentifier(in.c_str());
  951. }
  952. std::string line;
  953. while(cmSystemTools::GetLineFromStream(fin, line))
  954. {
  955. const char* mfcFlag = m_Makefile->GetDefinition("CMAKE_MFC_FLAG");
  956. if(!mfcFlag)
  957. {
  958. mfcFlag = "0";
  959. }
  960. cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME_EXPORTS",
  961. exportSymbol.c_str());
  962. cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE",
  963. customRuleCode.c_str());
  964. cmSystemTools::ReplaceString(line, "CMAKE_MFC_FLAG",
  965. mfcFlag);
  966. if(target.GetType() == cmTarget::STATIC_LIBRARY )
  967. {
  968. cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS",
  969. staticLibOptions.c_str());
  970. }
  971. if(m_Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"))
  972. {
  973. cmSystemTools::ReplaceString(line, "/nologo", "");
  974. }
  975. cmSystemTools::ReplaceString(line, "CM_LIBRARIES",
  976. libOptions.c_str());
  977. cmSystemTools::ReplaceString(line, "CM_DEBUG_LIBRARIES",
  978. libDebugOptions.c_str());
  979. cmSystemTools::ReplaceString(line, "CM_OPTIMIZED_LIBRARIES",
  980. libOptimizedOptions.c_str());
  981. cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES_FOR_DEBUG",
  982. libMultiLineOptionsForDebug.c_str());
  983. cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES",
  984. libMultiLineOptions.c_str());
  985. cmSystemTools::ReplaceString(line, "CM_MULTILINE_DEBUG_LIBRARIES",
  986. libMultiLineDebugOptions.c_str());
  987. cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIMIZED_LIBRARIES",
  988. libMultiLineOptimizedOptions.c_str());
  989. cmSystemTools::ReplaceString(line, "BUILD_INCLUDES",
  990. m_IncludeOptions.c_str());
  991. cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName);
  992. // because LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH
  993. // are already quoted in the template file,
  994. // we need to remove the quotes here, we still need
  995. // to convert to output path for unix to win32 conversion
  996. cmSystemTools::ReplaceString(line, "LIBRARY_OUTPUT_PATH",
  997. removeQuotes(
  998. this->ConvertToOptionallyRelativeOutputPath(libPath.c_str())).c_str());
  999. cmSystemTools::ReplaceString(line, "EXECUTABLE_OUTPUT_PATH",
  1000. removeQuotes(
  1001. this->ConvertToOptionallyRelativeOutputPath(exePath.c_str())).c_str());
  1002. cmSystemTools::ReplaceString(line,
  1003. "EXTRA_DEFINES",
  1004. m_Makefile->GetDefineFlags());
  1005. const char* debugPostfix
  1006. = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
  1007. cmSystemTools::ReplaceString(line, "DEBUG_POSTFIX",
  1008. debugPostfix?debugPostfix:"");
  1009. // store flags for each configuration
  1010. std::string flags = " ";
  1011. std::string flagsRelease = " ";
  1012. std::string flagsMinSize = " ";
  1013. std::string flagsDebug = " ";
  1014. std::string flagsDebugRel = " ";
  1015. if(target.GetType() >= cmTarget::EXECUTABLE &&
  1016. target.GetType() <= cmTarget::MODULE_LIBRARY)
  1017. {
  1018. const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
  1019. if(!linkLanguage)
  1020. {
  1021. cmSystemTools::Error("CMake can not determine linker language for target:",
  1022. target.GetName());
  1023. return;
  1024. }
  1025. // if CXX is on and the target contains cxx code then add the cxx flags
  1026. std::string baseFlagVar = "CMAKE_";
  1027. baseFlagVar += linkLanguage;
  1028. baseFlagVar += "_FLAGS";
  1029. flags = m_Makefile->GetRequiredDefinition(baseFlagVar.c_str());
  1030. std::string flagVar = baseFlagVar + "_RELEASE";
  1031. flagsRelease = m_Makefile->GetRequiredDefinition(flagVar.c_str());
  1032. flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
  1033. flagVar = baseFlagVar + "_MINSIZEREL";
  1034. flagsMinSize = m_Makefile->GetRequiredDefinition(flagVar.c_str());
  1035. flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
  1036. flagVar = baseFlagVar + "_DEBUG";
  1037. flagsDebug = m_Makefile->GetRequiredDefinition(flagVar.c_str());
  1038. flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
  1039. flagVar = baseFlagVar + "_RELWITHDEBINFO";
  1040. flagsDebugRel = m_Makefile->GetRequiredDefinition(flagVar.c_str());
  1041. flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
  1042. }
  1043. // if unicode is not found, then add -D_MBCS
  1044. std::string defs = m_Makefile->GetDefineFlags();
  1045. if(flags.find("D_UNICODE") == flags.npos &&
  1046. defs.find("D_UNICODE") == flags.npos)
  1047. {
  1048. flags += " /D \"_MBCS\"";
  1049. }
  1050. // The template files have CXX FLAGS in them, that need to be replaced.
  1051. // There are not separate CXX and C template files, so we use the same
  1052. // variable names. The previous code sets up flags* variables to contain
  1053. // the correct C or CXX flags
  1054. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL", flagsMinSize.c_str());
  1055. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG", flagsDebug.c_str());
  1056. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELWITHDEBINFO", flagsDebugRel.c_str());
  1057. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE", flagsRelease.c_str());
  1058. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS", flags.c_str());
  1059. fout << line.c_str() << std::endl;
  1060. }
  1061. }
  1062. void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout)
  1063. {
  1064. std::ifstream fin(m_DSPFooterTemplate.c_str());
  1065. if(!fin)
  1066. {
  1067. cmSystemTools::Error("Error Reading ",
  1068. m_DSPFooterTemplate.c_str());
  1069. }
  1070. std::string line;
  1071. while(cmSystemTools::GetLineFromStream(fin, line))
  1072. {
  1073. fout << line << std::endl;
  1074. }
  1075. }