cmLocalVisualStudio6Generator.cxx 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  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. const 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(const 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,
  674. const cmTarget &target,
  675. std::vector<cmSourceGroup> &)
  676. {
  677. std::set<std::string> pathEmitted;
  678. // determine the link directories
  679. std::string libOptions;
  680. std::string libDebugOptions;
  681. std::string libOptimizedOptions;
  682. std::string libMultiLineOptions;
  683. std::string libMultiLineOptionsForDebug;
  684. std::string libMultiLineDebugOptions;
  685. std::string libMultiLineOptimizedOptions;
  686. // suppoirt override in output directory
  687. std::string libPath = "";
  688. if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
  689. {
  690. libPath = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
  691. }
  692. std::string exePath = "";
  693. if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
  694. {
  695. exePath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
  696. }
  697. if(libPath.size())
  698. {
  699. // make sure there is a trailing slash
  700. if(libPath[libPath.size()-1] != '/')
  701. {
  702. libPath += "/";
  703. }
  704. std::string lpath =
  705. this->ConvertToOptionallyRelativeOutputPath(libPath.c_str());
  706. if(lpath.size() == 0)
  707. {
  708. lpath = ".";
  709. }
  710. std::string lpathIntDir = libPath + "$(INTDIR)";
  711. lpathIntDir = this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str());
  712. if(pathEmitted.insert(lpath).second)
  713. {
  714. libOptions += " /LIBPATH:";
  715. libOptions += lpathIntDir;
  716. libOptions += " ";
  717. libOptions += " /LIBPATH:";
  718. libOptions += lpath;
  719. libOptions += " ";
  720. libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
  721. libMultiLineOptions += lpathIntDir;
  722. libMultiLineOptions += " ";
  723. libMultiLineOptions += " /LIBPATH:";
  724. libMultiLineOptions += lpath;
  725. libMultiLineOptions += " \n";
  726. libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
  727. libMultiLineOptionsForDebug += lpathIntDir;
  728. libMultiLineOptionsForDebug += " ";
  729. libMultiLineOptionsForDebug += " /LIBPATH:";
  730. libMultiLineOptionsForDebug += lpath;
  731. libMultiLineOptionsForDebug += " \n";
  732. }
  733. }
  734. if(exePath.size())
  735. {
  736. // make sure there is a trailing slash
  737. if(exePath[exePath.size()-1] != '/')
  738. {
  739. exePath += "/";
  740. }
  741. std::string lpath =
  742. this->ConvertToOptionallyRelativeOutputPath(exePath.c_str());
  743. if(lpath.size() == 0)
  744. {
  745. lpath = ".";
  746. }
  747. std::string lpathIntDir = exePath + "$(INTDIR)";
  748. lpathIntDir = this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str());
  749. if(pathEmitted.insert(lpath).second)
  750. {
  751. libOptions += " /LIBPATH:";
  752. libOptions += lpathIntDir;
  753. libOptions += " ";
  754. libOptions += " /LIBPATH:";
  755. libOptions += lpath;
  756. libOptions += " ";
  757. libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
  758. libMultiLineOptions += lpathIntDir;
  759. libMultiLineOptions += " ";
  760. libMultiLineOptions += " /LIBPATH:";
  761. libMultiLineOptions += lpath;
  762. libMultiLineOptions += " \n";
  763. libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
  764. libMultiLineOptionsForDebug += lpathIntDir;
  765. libMultiLineOptionsForDebug += " ";
  766. libMultiLineOptionsForDebug += " /LIBPATH:";
  767. libMultiLineOptionsForDebug += lpath;
  768. libMultiLineOptionsForDebug += " \n";
  769. }
  770. }
  771. std::vector<std::string>::const_iterator i;
  772. const std::vector<std::string>& libdirs = target.GetLinkDirectories();
  773. for(i = libdirs.begin(); i != libdirs.end(); ++i)
  774. {
  775. std::string path = *i;
  776. if(path[path.size()-1] != '/')
  777. {
  778. path += "/";
  779. }
  780. std::string lpath =
  781. this->ConvertToOptionallyRelativeOutputPath(path.c_str());
  782. if(lpath.size() == 0)
  783. {
  784. lpath = ".";
  785. }
  786. std::string lpathIntDir = path + "$(INTDIR)";
  787. lpathIntDir = this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str());
  788. if(pathEmitted.insert(lpath).second)
  789. {
  790. libOptions += " /LIBPATH:";
  791. libOptions += lpathIntDir;
  792. libOptions += " ";
  793. libOptions += " /LIBPATH:";
  794. libOptions += lpath;
  795. libOptions += " ";
  796. libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
  797. libMultiLineOptions += lpathIntDir;
  798. libMultiLineOptions += " ";
  799. libMultiLineOptions += " /LIBPATH:";
  800. libMultiLineOptions += lpath;
  801. libMultiLineOptions += " \n";
  802. libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
  803. libMultiLineOptionsForDebug += lpathIntDir;
  804. libMultiLineOptionsForDebug += " ";
  805. libMultiLineOptionsForDebug += " /LIBPATH:";
  806. libMultiLineOptionsForDebug += lpath;
  807. libMultiLineOptionsForDebug += " \n";
  808. }
  809. }
  810. // find link libraries
  811. const cmTarget::LinkLibraries& libs = target.GetLinkLibraries();
  812. cmTarget::LinkLibraries::const_iterator j;
  813. for(j = libs.begin(); j != libs.end(); ++j)
  814. {
  815. // add libraries to executables and dlls (but never include
  816. // a library in a library, bad recursion)
  817. if ((target.GetType() != cmTarget::SHARED_LIBRARY
  818. && target.GetType() != cmTarget::STATIC_LIBRARY
  819. && target.GetType() != cmTarget::MODULE_LIBRARY) ||
  820. (target.GetType()==cmTarget::SHARED_LIBRARY && libName != j->first) ||
  821. (target.GetType()==cmTarget::MODULE_LIBRARY && libName != j->first))
  822. {
  823. std::string lib = j->first;
  824. std::string libDebug = j->first;
  825. std::string libPath = j->first + "_CMAKE_PATH";
  826. const char* cacheValue
  827. = m_GlobalGenerator->GetCMakeInstance()->GetCacheDefinition(
  828. libPath.c_str());
  829. if ( cacheValue && *cacheValue && m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX") )
  830. {
  831. libDebug += m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
  832. }
  833. if(j->first.find(".lib") == std::string::npos)
  834. {
  835. lib += ".lib";
  836. libDebug += ".lib";
  837. }
  838. lib = this->ConvertToOptionallyRelativeOutputPath(lib.c_str());
  839. libDebug = this->ConvertToOptionallyRelativeOutputPath(libDebug.c_str());
  840. if (j->second == cmTarget::GENERAL)
  841. {
  842. libOptions += " ";
  843. libOptions += lib;
  844. libMultiLineOptions += "# ADD LINK32 ";
  845. libMultiLineOptions += lib;
  846. libMultiLineOptions += "\n";
  847. libMultiLineOptionsForDebug += "# ADD LINK32 ";
  848. libMultiLineOptionsForDebug += libDebug;
  849. libMultiLineOptionsForDebug += "\n";
  850. }
  851. if (j->second == cmTarget::DEBUG)
  852. {
  853. libDebugOptions += " ";
  854. libDebugOptions += lib;
  855. libMultiLineDebugOptions += "# ADD LINK32 ";
  856. libMultiLineDebugOptions += libDebug;
  857. libMultiLineDebugOptions += "\n";
  858. }
  859. if (j->second == cmTarget::OPTIMIZED)
  860. {
  861. libOptimizedOptions += " ";
  862. libOptimizedOptions += lib;
  863. libMultiLineOptimizedOptions += "# ADD LINK32 ";
  864. libMultiLineOptimizedOptions += lib;
  865. libMultiLineOptimizedOptions += "\n";
  866. }
  867. }
  868. }
  869. std::string extraLinkOptions;
  870. if(target.GetType() == cmTarget::EXECUTABLE)
  871. {
  872. extraLinkOptions =
  873. m_Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS");
  874. // if the executable has an output name then add the appropriate flag
  875. if (target.GetProperty("OUTPUT_NAME"))
  876. {
  877. libMultiLineOptions += "# ADD LINK32 /out:";
  878. libMultiLineOptions += target.GetProperty("OUTPUT_NAME");
  879. libMultiLineOptions += " \n";
  880. }
  881. }
  882. if(target.GetType() == cmTarget::SHARED_LIBRARY)
  883. {
  884. extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS");
  885. }
  886. if(target.GetType() == cmTarget::MODULE_LIBRARY)
  887. {
  888. extraLinkOptions = m_Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS");
  889. }
  890. if(extraLinkOptions.size())
  891. {
  892. libOptions += " ";
  893. libOptions += extraLinkOptions;
  894. libOptions += " ";
  895. libMultiLineOptions += "# ADD LINK32 ";
  896. libMultiLineOptions += extraLinkOptions;
  897. libMultiLineOptions += " \n";
  898. libMultiLineOptionsForDebug += "# ADD LINK32 ";
  899. libMultiLineOptionsForDebug += extraLinkOptions;
  900. libMultiLineOptionsForDebug += " \n";
  901. }
  902. if(const char* stdLibs = m_Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES"))
  903. {
  904. libOptions += " ";
  905. libOptions += stdLibs;
  906. libOptions += " ";
  907. libMultiLineOptions += "# ADD LINK32 ";
  908. libMultiLineOptions += stdLibs;
  909. libMultiLineOptions += " \n";
  910. libMultiLineOptionsForDebug += "# ADD LINK32 ";
  911. libMultiLineOptionsForDebug += stdLibs;
  912. libMultiLineOptionsForDebug += " \n";
  913. }
  914. if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"))
  915. {
  916. libOptions += " ";
  917. libOptions += targetLinkFlags;
  918. libOptions += " ";
  919. libMultiLineOptions += "# ADD LINK32 ";
  920. libMultiLineOptions += targetLinkFlags;
  921. libMultiLineOptions += " \n";
  922. libMultiLineOptionsForDebug += "# ADD LINK32 ";
  923. libMultiLineOptionsForDebug += targetLinkFlags;
  924. libMultiLineOptionsForDebug += " \n";
  925. }
  926. // are there any custom rules on the target itself
  927. // only if the target is a lib or exe
  928. std::string customRuleCode = this->CreateTargetRules(target, libName);
  929. std::ifstream fin(m_DSPHeaderTemplate.c_str());
  930. if(!fin)
  931. {
  932. cmSystemTools::Error("Error Reading ", m_DSPHeaderTemplate.c_str());
  933. }
  934. std::string staticLibOptions;
  935. if(target.GetType() == cmTarget::STATIC_LIBRARY )
  936. {
  937. if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
  938. {
  939. staticLibOptions = libflags;
  940. }
  941. }
  942. std::string exportSymbol;
  943. if (const char* custom_export_name = target.GetProperty("DEFINE_SYMBOL"))
  944. {
  945. exportSymbol = custom_export_name;
  946. }
  947. else
  948. {
  949. std::string in = libName;
  950. in += "_EXPORTS";
  951. exportSymbol = cmSystemTools::MakeCindentifier(in.c_str());
  952. }
  953. std::string line;
  954. while(cmSystemTools::GetLineFromStream(fin, line))
  955. {
  956. const char* mfcFlag = m_Makefile->GetDefinition("CMAKE_MFC_FLAG");
  957. if(!mfcFlag)
  958. {
  959. mfcFlag = "0";
  960. }
  961. cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME_EXPORTS",
  962. exportSymbol.c_str());
  963. cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE",
  964. customRuleCode.c_str());
  965. cmSystemTools::ReplaceString(line, "CMAKE_MFC_FLAG",
  966. mfcFlag);
  967. if(target.GetType() == cmTarget::STATIC_LIBRARY )
  968. {
  969. cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS",
  970. staticLibOptions.c_str());
  971. }
  972. if(m_Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"))
  973. {
  974. cmSystemTools::ReplaceString(line, "/nologo", "");
  975. }
  976. cmSystemTools::ReplaceString(line, "CM_LIBRARIES",
  977. libOptions.c_str());
  978. cmSystemTools::ReplaceString(line, "CM_DEBUG_LIBRARIES",
  979. libDebugOptions.c_str());
  980. cmSystemTools::ReplaceString(line, "CM_OPTIMIZED_LIBRARIES",
  981. libOptimizedOptions.c_str());
  982. cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES_FOR_DEBUG",
  983. libMultiLineOptionsForDebug.c_str());
  984. cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES",
  985. libMultiLineOptions.c_str());
  986. cmSystemTools::ReplaceString(line, "CM_MULTILINE_DEBUG_LIBRARIES",
  987. libMultiLineDebugOptions.c_str());
  988. cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIMIZED_LIBRARIES",
  989. libMultiLineOptimizedOptions.c_str());
  990. cmSystemTools::ReplaceString(line, "BUILD_INCLUDES",
  991. m_IncludeOptions.c_str());
  992. cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName);
  993. // because LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH
  994. // are already quoted in the template file,
  995. // we need to remove the quotes here, we still need
  996. // to convert to output path for unix to win32 conversion
  997. cmSystemTools::ReplaceString(line, "LIBRARY_OUTPUT_PATH",
  998. removeQuotes(
  999. this->ConvertToOptionallyRelativeOutputPath(libPath.c_str())).c_str());
  1000. cmSystemTools::ReplaceString(line, "EXECUTABLE_OUTPUT_PATH",
  1001. removeQuotes(
  1002. this->ConvertToOptionallyRelativeOutputPath(exePath.c_str())).c_str());
  1003. cmSystemTools::ReplaceString(line,
  1004. "EXTRA_DEFINES",
  1005. m_Makefile->GetDefineFlags());
  1006. const char* debugPostfix
  1007. = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
  1008. cmSystemTools::ReplaceString(line, "DEBUG_POSTFIX",
  1009. debugPostfix?debugPostfix:"");
  1010. // store flags for each configuration
  1011. std::string flags = " ";
  1012. std::string flagsRelease = " ";
  1013. std::string flagsMinSize = " ";
  1014. std::string flagsDebug = " ";
  1015. std::string flagsDebugRel = " ";
  1016. if(target.GetType() >= cmTarget::EXECUTABLE &&
  1017. target.GetType() <= cmTarget::MODULE_LIBRARY)
  1018. {
  1019. const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
  1020. if(!linkLanguage)
  1021. {
  1022. cmSystemTools::Error("CMake can not determine linker language for target:",
  1023. target.GetName());
  1024. return;
  1025. }
  1026. // if CXX is on and the target contains cxx code then add the cxx flags
  1027. std::string baseFlagVar = "CMAKE_";
  1028. baseFlagVar += linkLanguage;
  1029. baseFlagVar += "_FLAGS";
  1030. flags = m_Makefile->GetRequiredDefinition(baseFlagVar.c_str());
  1031. std::string flagVar = baseFlagVar + "_RELEASE";
  1032. flagsRelease = m_Makefile->GetRequiredDefinition(flagVar.c_str());
  1033. flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
  1034. flagVar = baseFlagVar + "_MINSIZEREL";
  1035. flagsMinSize = m_Makefile->GetRequiredDefinition(flagVar.c_str());
  1036. flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
  1037. flagVar = baseFlagVar + "_DEBUG";
  1038. flagsDebug = m_Makefile->GetRequiredDefinition(flagVar.c_str());
  1039. flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
  1040. flagVar = baseFlagVar + "_RELWITHDEBINFO";
  1041. flagsDebugRel = m_Makefile->GetRequiredDefinition(flagVar.c_str());
  1042. flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
  1043. }
  1044. // if unicode is not found, then add -D_MBCS
  1045. std::string defs = m_Makefile->GetDefineFlags();
  1046. if(flags.find("D_UNICODE") == flags.npos &&
  1047. defs.find("D_UNICODE") == flags.npos)
  1048. {
  1049. flags += " /D \"_MBCS\"";
  1050. }
  1051. // The template files have CXX FLAGS in them, that need to be replaced.
  1052. // There are not separate CXX and C template files, so we use the same
  1053. // variable names. The previous code sets up flags* variables to contain
  1054. // the correct C or CXX flags
  1055. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL", flagsMinSize.c_str());
  1056. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG", flagsDebug.c_str());
  1057. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELWITHDEBINFO", flagsDebugRel.c_str());
  1058. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE", flagsRelease.c_str());
  1059. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS", flags.c_str());
  1060. fout << line.c_str() << std::endl;
  1061. }
  1062. }
  1063. void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout)
  1064. {
  1065. std::ifstream fin(m_DSPFooterTemplate.c_str());
  1066. if(!fin)
  1067. {
  1068. cmSystemTools::Error("Error Reading ",
  1069. m_DSPFooterTemplate.c_str());
  1070. }
  1071. std::string line;
  1072. while(cmSystemTools::GetLineFromStream(fin, line))
  1073. {
  1074. fout << line << std::endl;
  1075. }
  1076. }