cmLocalVisualStudio7Generator.cxx 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  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 "cmGlobalVisualStudio7Generator.h"
  14. #include "cmLocalVisualStudio7Generator.h"
  15. #include "cmMakefile.h"
  16. #include "cmSystemTools.h"
  17. #include "cmSourceFile.h"
  18. #include "cmCacheManager.h"
  19. #include "cmake.h"
  20. cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator()
  21. {
  22. m_Version71 = false;
  23. }
  24. cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator()
  25. {
  26. }
  27. void cmLocalVisualStudio7Generator::Generate(bool /* fromTheTop */)
  28. {
  29. this->OutputVCProjFile();
  30. }
  31. // TODO
  32. // for CommandLine= need to repleace quotes with &quot
  33. // write out configurations
  34. void cmLocalVisualStudio7Generator::OutputVCProjFile()
  35. {
  36. // If not an in source build, then create the output directory
  37. if(strcmp(m_Makefile->GetStartOutputDirectory(),
  38. m_Makefile->GetHomeDirectory()) != 0)
  39. {
  40. if(!cmSystemTools::MakeDirectory(m_Makefile->GetStartOutputDirectory()))
  41. {
  42. cmSystemTools::Error("Error creating directory ",
  43. m_Makefile->GetStartOutputDirectory());
  44. }
  45. }
  46. m_LibraryOutputPath = "";
  47. if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
  48. {
  49. m_LibraryOutputPath = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
  50. }
  51. if(m_LibraryOutputPath.size())
  52. {
  53. // make sure there is a trailing slash
  54. if(m_LibraryOutputPath[m_LibraryOutputPath.size()-1] != '/')
  55. {
  56. m_LibraryOutputPath += "/";
  57. }
  58. }
  59. m_ExecutableOutputPath = "";
  60. if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
  61. {
  62. m_ExecutableOutputPath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
  63. }
  64. if(m_ExecutableOutputPath.size())
  65. {
  66. // make sure there is a trailing slash
  67. if(m_ExecutableOutputPath[m_ExecutableOutputPath.size()-1] != '/')
  68. {
  69. m_ExecutableOutputPath += "/";
  70. }
  71. }
  72. // Create the VCProj or set of VCProj's for libraries and executables
  73. // clear project names
  74. m_CreatedProjectNames.clear();
  75. // expand vars for custom commands
  76. m_Makefile->ExpandVariablesInCustomCommands();
  77. // build any targets
  78. cmTargets &tgts = m_Makefile->GetTargets();
  79. for(cmTargets::iterator l = tgts.begin();
  80. l != tgts.end(); l++)
  81. {
  82. // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
  83. // so don't build a projectfile for it
  84. if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  85. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)
  86. && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0))
  87. {
  88. this->CreateSingleVCProj(l->first.c_str(),l->second);
  89. }
  90. }
  91. }
  92. void cmLocalVisualStudio7Generator::CreateSingleVCProj(const char *lname, cmTarget &target)
  93. {
  94. // add to the list of projects
  95. std::string pname = lname;
  96. m_CreatedProjectNames.push_back(pname);
  97. // create the dsp.cmake file
  98. std::string fname;
  99. fname = m_Makefile->GetStartOutputDirectory();
  100. fname += "/";
  101. fname += lname;
  102. fname += ".vcproj";
  103. // save the name of the real dsp file
  104. std::string realVCProj = fname;
  105. fname += ".cmake";
  106. std::ofstream fout(fname.c_str());
  107. if(!fout)
  108. {
  109. cmSystemTools::Error("Error Writing ", fname.c_str());
  110. }
  111. this->WriteVCProjFile(fout,lname,target);
  112. fout.close();
  113. // if the dsp file has changed, then write it.
  114. cmSystemTools::CopyFileIfDifferent(fname.c_str(), realVCProj.c_str());
  115. }
  116. void cmLocalVisualStudio7Generator::AddVCProjBuildRule()
  117. {
  118. std::string dspname = *(m_CreatedProjectNames.end()-1);
  119. if(dspname == "ALL_BUILD")
  120. {
  121. return;
  122. }
  123. dspname += ".vcproj.cmake";
  124. std::string makefileIn = m_Makefile->GetStartDirectory();
  125. makefileIn += "/";
  126. makefileIn += "CMakeLists.txt";
  127. makefileIn = cmSystemTools::ConvertToOutputPath(makefileIn.c_str());
  128. std::string dsprule = "${CMAKE_COMMAND}";
  129. m_Makefile->ExpandVariablesInString(dsprule);
  130. dsprule = cmSystemTools::ConvertToOutputPath(dsprule.c_str());
  131. std::vector<std::string> argv;
  132. argv.push_back(makefileIn);
  133. makefileIn = m_Makefile->GetStartDirectory();
  134. makefileIn += "/";
  135. makefileIn += "CMakeLists.txt";
  136. std::string args;
  137. args = "-H";
  138. args +=
  139. cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeDirectory());
  140. argv.push_back(args);
  141. args = "-S";
  142. args +=
  143. cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartDirectory());
  144. argv.push_back(args);
  145. args = "-O";
  146. args +=
  147. cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartOutputDirectory());
  148. argv.push_back(args);
  149. args = "-B";
  150. args +=
  151. cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeOutputDirectory());
  152. argv.push_back(args);
  153. std::string configFile =
  154. m_Makefile->GetDefinition("CMAKE_ROOT");
  155. configFile += "/Templates/CMakeWindowsSystemConfig.cmake";
  156. std::vector<std::string> listFiles = m_Makefile->GetListFiles();
  157. bool found = false;
  158. for(std::vector<std::string>::iterator i = listFiles.begin();
  159. i != listFiles.end(); ++i)
  160. {
  161. if(*i == configFile)
  162. {
  163. found = true;
  164. }
  165. }
  166. if(!found)
  167. {
  168. listFiles.push_back(configFile);
  169. }
  170. m_Makefile->AddCustomCommandToOutput(dspname.c_str(), dsprule.c_str(),
  171. argv, makefileIn.c_str(), listFiles,
  172. NULL, true);
  173. }
  174. void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout,
  175. const char *libName,
  176. const cmTarget &target)
  177. {
  178. std::vector<std::string> *configs =
  179. static_cast<cmGlobalVisualStudio7Generator *>(m_GlobalGenerator)->GetConfigurations();
  180. fout << "\t<Configurations>\n";
  181. for( std::vector<std::string>::iterator i = configs->begin();
  182. i != configs->end(); ++i)
  183. {
  184. this->WriteConfiguration(fout, i->c_str(), libName, target);
  185. }
  186. fout << "\t</Configurations>\n";
  187. }
  188. void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
  189. const char* configName,
  190. const char *libName,
  191. const cmTarget &target)
  192. {
  193. const char* mfcFlag = m_Makefile->GetDefinition("CMAKE_MFC_FLAG");
  194. if(!mfcFlag)
  195. {
  196. mfcFlag = "0";
  197. }
  198. fout << "\t\t<Configuration\n"
  199. << "\t\t\tName=\"" << configName << "|Win32\"\n"
  200. << "\t\t\tOutputDirectory=\"" << configName << "\"\n";
  201. // This is an internal type to Visual Studio, it seems that:
  202. // 4 == static library
  203. // 2 == dll
  204. // 1 == executable
  205. // 10 == utility
  206. const char* configType = "10";
  207. switch(target.GetType())
  208. {
  209. case cmTarget::STATIC_LIBRARY:
  210. configType = "4";
  211. break;
  212. case cmTarget::SHARED_LIBRARY:
  213. case cmTarget::MODULE_LIBRARY:
  214. configType = "2";
  215. break;
  216. case cmTarget::EXECUTABLE:
  217. case cmTarget::WIN32_EXECUTABLE:
  218. configType = "1";
  219. break;
  220. case cmTarget::UTILITY:
  221. configType = "10";
  222. default:
  223. break;
  224. }
  225. std::string flags;
  226. std::string flagsRelease = " ";
  227. std::string flagsMinSize = " ";
  228. std::string flagsDebug = " ";
  229. std::string flagsDebugRel = " ";
  230. if(target.HasCxx())
  231. {
  232. flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS");
  233. flagsRelease += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELEASE");
  234. flagsMinSize += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_MINSIZEREL");
  235. flagsDebug += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_DEBUG");
  236. flagsDebugRel += m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO");
  237. }
  238. else
  239. {
  240. flags = m_Makefile->GetDefinition("CMAKE_C_FLAGS");
  241. flagsRelease += m_Makefile->GetDefinition("CMAKE_C_FLAGS_RELEASE");
  242. flagsMinSize += m_Makefile->GetDefinition("CMAKE_C_FLAGS_MINSIZEREL");
  243. flagsDebug += m_Makefile->GetDefinition("CMAKE_C_FLAGS_DEBUG");
  244. flagsDebugRel += m_Makefile->GetDefinition("CMAKE_C_FLAGS_RELWITHDEBINFO");
  245. }
  246. // Optimization = 0 None Debug /O0
  247. // Optimization = 1 MinSize /O1
  248. // Optimization = 2 MaxSpeed /O2
  249. // Optimization = 3 Max Optimization /O3
  250. // RuntimeLibrary = 0 /MT multithread
  251. // RuntimeLibrary = 1 /MTd multithread debug
  252. // RuntimeLibrary = 2 /MD multithread dll
  253. // RuntimeLibrary = 3 /MDd multithread dll debug
  254. // RuntimeLibrary = 4 /ML single thread
  255. // RuntimeLibrary = 5 /MLd single thread debug
  256. // InlineFunctionExpansion = 0 none
  257. // InlineFunctionExpansion = 1 when inline keyword
  258. // InlineFunctionExpansion = 2 any time you can
  259. int runtime = 0;
  260. int optimized = 0;
  261. int inlineFunctions = 0;
  262. const char* pre = "WIN32,_DEBUG,_WINDOWS";
  263. // set the flags and defaults for
  264. // runtime, optimized, and inlineFunctions , and
  265. // default pre processor flags
  266. if(strcmp(configName, "Debug") == 0)
  267. {
  268. inlineFunctions = 0;
  269. flags += flagsDebug;
  270. optimized = 0;
  271. runtime = 3;
  272. pre = "WIN32,_DEBUG,_WINDOWS";
  273. }
  274. else if (strcmp(configName, "Release") == 0)
  275. {
  276. inlineFunctions = 1;
  277. optimized =2;
  278. pre = "WIN32,NDEBUG,_WINDOWS";
  279. flags += flagsRelease;
  280. runtime = 2;
  281. }
  282. else if(strcmp(configName, "MinSizeRel") == 0)
  283. {
  284. inlineFunctions = 1;
  285. runtime = 2;
  286. optimized = 1;
  287. pre = "WIN32,NDEBUG,_WINDOWS";
  288. flags += flagsMinSize;
  289. }
  290. else if(strcmp(configName, "RelWithDebInfo") == 0)
  291. {
  292. inlineFunctions = 1;
  293. optimized = 2;
  294. runtime = 2;
  295. pre = "WIN32,NDEBUG,_WINDOWS";
  296. flags += flagsDebugRel;
  297. }
  298. fout << "\t\t\tIntermediateDirectory=\".\\" << configName << "\"\n"
  299. << "\t\t\tConfigurationType=\"" << configType << "\"\n"
  300. << "\t\t\tUseOfMFC=\"" << mfcFlag << "\"\n"
  301. << "\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n";
  302. // if -D_UNICODE or /D_UNICODE is found in the flags
  303. // change the character set to unicode, if not then
  304. // default to MBCS
  305. std::string defs = m_Makefile->GetDefineFlags();
  306. if(flags.find("D_UNICODE") != flags.npos ||
  307. defs.find("D_UNICODE") != flags.npos)
  308. {
  309. fout << "\t\t\tCharacterSet=\"1\">\n";
  310. }
  311. else
  312. {
  313. fout << "\t\t\tCharacterSet=\"2\">\n";
  314. }
  315. fout << "\t\t\t<Tool\n"
  316. << "\t\t\t\tName=\"VCCLCompilerTool\"\n"
  317. << "\t\t\t\tAdditionalOptions=\"";
  318. cmSystemTools::ReplaceString(flags, "\"", "&quot;");
  319. // check the flags for the run time library flag options
  320. // if there is a match set the run time flag
  321. if(flags.find("MTd") != flags.npos)
  322. {
  323. cmSystemTools::ReplaceString(flags, "-MTd", "");
  324. cmSystemTools::ReplaceString(flags, "/MTd", "");
  325. runtime = 1;
  326. }
  327. else if (flags.find("MDd") != flags.npos)
  328. {
  329. cmSystemTools::ReplaceString(flags, "-MDd", "");
  330. cmSystemTools::ReplaceString(flags, "/MDd", "");
  331. runtime = 3;
  332. }
  333. else if (flags.find("MLd") != flags.npos)
  334. {
  335. cmSystemTools::ReplaceString(flags, "-MLd", "");
  336. cmSystemTools::ReplaceString(flags, "/MLd", "");
  337. runtime = 5;
  338. }
  339. else if (flags.find("MT") != flags.npos)
  340. {
  341. cmSystemTools::ReplaceString(flags, "-MT", "");
  342. cmSystemTools::ReplaceString(flags, "/MT", "");
  343. runtime = 0;
  344. }
  345. else if (flags.find("MD") != flags.npos)
  346. {
  347. cmSystemTools::ReplaceString(flags, "-MD", "");
  348. cmSystemTools::ReplaceString(flags, "/MD", "");
  349. runtime = 2;
  350. }
  351. else if (flags.find("ML") != flags.npos)
  352. {
  353. cmSystemTools::ReplaceString(flags, "-ML", "");
  354. cmSystemTools::ReplaceString(flags, "/ML", "");
  355. runtime = 4;
  356. }
  357. fout << flags;
  358. fout << " -DCMAKE_INTDIR=\\&quot;" << configName << "\\&quot;"
  359. << "\"\n";
  360. fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
  361. std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
  362. std::vector<std::string>::iterator i = includes.begin();
  363. for(;i != includes.end(); ++i)
  364. {
  365. std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
  366. fout << ipath << ";";
  367. }
  368. fout << "\"\n";
  369. fout << "\t\t\t\tOptimization=\"" << optimized << "\"\n"
  370. << "\t\t\t\tRuntimeLibrary=\"" << runtime << "\"\n"
  371. << "\t\t\t\tInlineFunctionExpansion=\"" << inlineFunctions << "\"\n"
  372. << "\t\t\t\tPreprocessorDefinitions=\"" << pre;
  373. if(target.GetType() == cmTarget::SHARED_LIBRARY
  374. || target.GetType() == cmTarget::MODULE_LIBRARY)
  375. {
  376. std::string exportSymbol;
  377. if (const char* custom_export_name = target.GetProperty("DEFINE_SYMBOL"))
  378. {
  379. exportSymbol = custom_export_name;
  380. }
  381. else
  382. {
  383. std::string id = libName;
  384. id += "_EXPORTS";
  385. exportSymbol = cmSystemTools::MakeCindentifier(id.c_str());
  386. }
  387. fout << "," << exportSymbol;
  388. }
  389. this->OutputDefineFlags(fout);
  390. fout << "\"\n";
  391. if(m_Makefile->IsOn("CMAKE_CXX_USE_RTTI"))
  392. {
  393. fout << "\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n";
  394. }
  395. fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n";
  396. fout << "\t\t\t\tObjectFile=\"" << configName << "\\\"\n";
  397. if ( m_Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL") )
  398. {
  399. fout << "\t\t\t\tWarningLevel=\"" << m_Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL") << "\"\n";
  400. }
  401. fout << "\t\t\t\tDebugInformationFormat=\"3\"";
  402. fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
  403. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n";
  404. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n"
  405. << "\t\t\t\tAdditionalIncludeDirectories=\"";
  406. for(i = includes.begin();i != includes.end(); ++i)
  407. {
  408. std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
  409. fout << ipath << ";";
  410. }
  411. fout << "\"\n"
  412. << "\t\t\t\tPreprocessorDefinitions=\"" << pre;
  413. this->OutputDefineFlags(fout);
  414. fout << "\" />\n";
  415. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n";
  416. this->OutputTargetRules(fout, target, libName);
  417. this->OutputBuildTool(fout, configName, libName, target);
  418. fout << "\t\t</Configuration>\n";
  419. }
  420. void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
  421. const char* configName,
  422. const char *libName,
  423. const cmTarget &target)
  424. {
  425. std::string temp;
  426. std::string debugPostfix = "";
  427. bool debug = !strcmp(configName,"Debug");
  428. if (debug && m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"))
  429. {
  430. debugPostfix = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
  431. }
  432. std::string extraLinkOptions;
  433. if((target.GetType() == cmTarget::EXECUTABLE) ||
  434. (target.GetType() == cmTarget::WIN32_EXECUTABLE))
  435. {
  436. extraLinkOptions = m_Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS");
  437. }
  438. if(target.GetType() == cmTarget::SHARED_LIBRARY)
  439. {
  440. extraLinkOptions = m_Makefile->GetDefinition("CMAKE_SHARED_LINKER_FLAGS");
  441. }
  442. if(target.GetType() == cmTarget::MODULE_LIBRARY)
  443. {
  444. extraLinkOptions = m_Makefile->GetDefinition("CMAKE_MODULE_LINKER_FLAGS");
  445. }
  446. const char* targetLinkFlags = target.GetProperty("LINK_FLAGS");
  447. if(targetLinkFlags)
  448. {
  449. extraLinkOptions += " ";
  450. extraLinkOptions += targetLinkFlags;
  451. }
  452. switch(target.GetType())
  453. {
  454. case cmTarget::STATIC_LIBRARY:
  455. {
  456. std::string libpath = m_LibraryOutputPath +
  457. "$(OutDir)/" + libName + debugPostfix + ".lib";
  458. fout << "\t\t\t<Tool\n"
  459. << "\t\t\t\tName=\"VCLibrarianTool\"\n"
  460. << "\t\t\t\t\tOutputFile=\""
  461. << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << ".\"/>\n";
  462. break;
  463. }
  464. case cmTarget::SHARED_LIBRARY:
  465. case cmTarget::MODULE_LIBRARY:
  466. fout << "\t\t\t<Tool\n"
  467. << "\t\t\t\tName=\"VCLinkerTool\"\n"
  468. << "\t\t\t\tAdditionalOptions=\"/MACHINE:I386";
  469. if(extraLinkOptions.size())
  470. {
  471. fout << " " << cmLocalVisualStudio7Generator::EscapeForXML(
  472. extraLinkOptions.c_str()).c_str();
  473. }
  474. fout << "\"\n"
  475. << "\t\t\t\tAdditionalDependencies=\" odbc32.lib odbccp32.lib ";
  476. this->OutputLibraries(fout, configName, libName, target);
  477. fout << "\"\n";
  478. temp = m_LibraryOutputPath;
  479. temp += configName;
  480. temp += "/";
  481. temp += libName;
  482. temp += debugPostfix;
  483. temp += ".dll";
  484. fout << "\t\t\t\tOutputFile=\""
  485. << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  486. fout << "\t\t\t\tLinkIncremental=\"1\"\n";
  487. fout << "\t\t\t\tSuppressStartupBanner=\"TRUE\"\n";
  488. fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
  489. this->OutputLibraryDirectories(fout, configName, libName, target);
  490. fout << "\"\n";
  491. this->OutputModuleDefinitionFile(fout, target);
  492. temp = m_LibraryOutputPath;
  493. temp += "$(OutDir)/";
  494. temp += libName;
  495. temp += debugPostfix;
  496. temp += ".pdb";
  497. fout << "\t\t\t\tProgramDatabaseFile=\"" <<
  498. this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  499. if(strcmp(configName, "Debug") == 0
  500. || strcmp(configName, "RelWithDebInfo") == 0)
  501. {
  502. fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
  503. }
  504. fout << "\t\t\t\tStackReserveSize=\""
  505. << m_Makefile->GetDefinition("CMAKE_CXX_STACK_SIZE") << "\"\n";
  506. temp = m_ExecutableOutputPath;
  507. temp += configName;
  508. temp += "/";
  509. temp += libName;
  510. temp += debugPostfix;
  511. temp += ".lib";
  512. fout << "\t\t\t\tImportLibrary=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n";
  513. break;
  514. case cmTarget::EXECUTABLE:
  515. case cmTarget::WIN32_EXECUTABLE:
  516. fout << "\t\t\t<Tool\n"
  517. << "\t\t\t\tName=\"VCLinkerTool\"\n"
  518. << "\t\t\t\tAdditionalOptions=\"/MACHINE:I386";
  519. if(extraLinkOptions.size())
  520. {
  521. fout << " " << cmLocalVisualStudio7Generator::EscapeForXML(
  522. extraLinkOptions.c_str()).c_str();
  523. }
  524. fout << "\"\n"
  525. << "\t\t\t\tAdditionalDependencies=\" odbc32.lib odbccp32.lib ";
  526. this->OutputLibraries(fout, configName, libName, target);
  527. fout << "\"\n";
  528. temp = m_ExecutableOutputPath;
  529. temp += configName;
  530. temp += "/";
  531. temp += libName;
  532. temp += ".exe";
  533. fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  534. fout << "\t\t\t\tLinkIncremental=\"1\"\n";
  535. fout << "\t\t\t\tSuppressStartupBanner=\"TRUE\"\n";
  536. fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
  537. this->OutputLibraryDirectories(fout, configName, libName, target);
  538. fout << "\"\n";
  539. fout << "\t\t\t\tProgramDatabaseFile=\"" << m_LibraryOutputPath
  540. << "$(OutDir)\\" << libName << ".pdb\"\n";
  541. if(strcmp(configName, "Debug") == 0
  542. || strcmp(configName, "RelWithDebInfo") == 0)
  543. {
  544. fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
  545. }
  546. if( target.GetType() == cmTarget::EXECUTABLE)
  547. {
  548. fout << "\t\t\t\tSubSystem=\"1\"\n";
  549. }
  550. else
  551. {
  552. fout << "\t\t\t\tSubSystem=\"2\"\n";
  553. }
  554. fout << "\t\t\t\tStackReserveSize=\""
  555. << m_Makefile->GetDefinition("CMAKE_CXX_STACK_SIZE") << "\"/>\n";
  556. break;
  557. case cmTarget::UTILITY:
  558. break;
  559. }
  560. }
  561. void cmLocalVisualStudio7Generator::OutputModuleDefinitionFile(std::ostream& fout,
  562. const cmTarget &target)
  563. {
  564. std::vector<cmSourceFile*> const& classes = target.GetSourceFiles();
  565. for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
  566. i != classes.end(); i++)
  567. {
  568. if(cmSystemTools::UpperCase((*i)->GetSourceExtension()) == "DEF")
  569. {
  570. fout << "\t\t\t\tModuleDefinitionFile=\""
  571. << this->ConvertToXMLOutputPath((*i)->GetFullPath().c_str())
  572. << "\"\n";
  573. return;
  574. }
  575. }
  576. }
  577. void cmLocalVisualStudio7Generator::OutputLibraryDirectories(std::ostream& fout,
  578. const char*,
  579. const char*,
  580. const cmTarget &tgt)
  581. {
  582. bool hasone = false;
  583. if(m_LibraryOutputPath.size())
  584. {
  585. hasone = true;
  586. std::string temp = m_LibraryOutputPath;
  587. temp += "$(INTDIR)";
  588. fout << this->ConvertToXMLOutputPath(temp.c_str()) << "," <<
  589. this->ConvertToXMLOutputPath(m_LibraryOutputPath.c_str());
  590. }
  591. if(m_ExecutableOutputPath.size() &&
  592. (m_LibraryOutputPath != m_ExecutableOutputPath))
  593. {
  594. if (hasone)
  595. {
  596. fout << ",";
  597. }
  598. hasone = true;
  599. std::string temp = m_ExecutableOutputPath;
  600. temp += "$(INTDIR)";
  601. fout << this->ConvertToXMLOutputPath(temp.c_str()) << "," <<
  602. this->ConvertToXMLOutputPath(m_ExecutableOutputPath.c_str());
  603. }
  604. std::set<std::string> pathEmitted;
  605. std::vector<std::string>::const_iterator i;
  606. const std::vector<std::string>& libdirs = tgt.GetLinkDirectories();
  607. for(i = libdirs.begin(); i != libdirs.end(); ++i)
  608. {
  609. std::string lpath = *i;
  610. if(lpath[lpath.size()-1] != '/')
  611. {
  612. lpath += "/";
  613. }
  614. if(pathEmitted.insert(lpath).second)
  615. {
  616. if(hasone)
  617. {
  618. fout << ",";
  619. }
  620. std::string lpathi = lpath + "$(INTDIR)";
  621. fout << this->ConvertToXMLOutputPath(lpathi.c_str()) << "," <<
  622. this->ConvertToXMLOutputPath(lpath.c_str());
  623. hasone = true;
  624. }
  625. }
  626. }
  627. void cmLocalVisualStudio7Generator::OutputLibraries(std::ostream& fout,
  628. const char* configName,
  629. const char* libName,
  630. const cmTarget &target)
  631. {
  632. const cmTarget::LinkLibraries& libs = target.GetLinkLibraries();
  633. cmTarget::LinkLibraries::const_iterator j;
  634. for(j = libs.begin(); j != libs.end(); ++j)
  635. {
  636. if(j->first != libName)
  637. {
  638. std::string lib = j->first;
  639. std::string debugPostfix = "";
  640. // if this is a library we are building then watch for a debugPostfix
  641. if (!strcmp(configName,"Debug"))
  642. {
  643. std::string libPath = j->first + "_CMAKE_PATH";
  644. const char* cacheValue
  645. = m_GlobalGenerator->GetCMakeInstance()->GetCacheDefinition(libPath.c_str());
  646. if(cacheValue && m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"))
  647. {
  648. debugPostfix = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
  649. }
  650. }
  651. if(j->first.find(".lib") == std::string::npos)
  652. {
  653. lib += debugPostfix + ".lib";
  654. }
  655. lib = this->ConvertToXMLOutputPath(lib.c_str());
  656. if (j->second == cmTarget::GENERAL
  657. || (j->second == cmTarget::DEBUG && strcmp(configName, "Debug") == 0)
  658. || (j->second == cmTarget::OPTIMIZED && strcmp(configName, "Debug") != 0))
  659. {
  660. fout << lib << " ";
  661. }
  662. }
  663. }
  664. }
  665. void cmLocalVisualStudio7Generator::OutputDefineFlags(std::ostream& fout)
  666. {
  667. std::string defs = m_Makefile->GetDefineFlags();
  668. cmSystemTools::ReplaceString(defs, "/D","-D");
  669. std::string::size_type pos = defs.find("-D");
  670. bool done = pos == std::string::npos;
  671. if(!done)
  672. {
  673. fout << ",";
  674. }
  675. while(!done)
  676. {
  677. std::string::size_type nextpos = defs.find("-D", pos+2);
  678. std::string define;
  679. if(nextpos != std::string::npos)
  680. {
  681. define = defs.substr(pos+2, nextpos - pos -3);
  682. }
  683. else
  684. {
  685. define = defs.substr(pos+2);
  686. done = true;
  687. }
  688. cmSystemTools::ReplaceString(define, "\"", "&quot;");
  689. fout << define << ",";
  690. if(!done)
  691. {
  692. pos = defs.find("-D", nextpos);
  693. }
  694. }
  695. }
  696. void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
  697. const char *libName,
  698. cmTarget &target)
  699. {
  700. // get the configurations
  701. std::vector<std::string> *configs =
  702. static_cast<cmGlobalVisualStudio7Generator *>
  703. (m_GlobalGenerator)->GetConfigurations();
  704. // if we should add regen rule then...
  705. const char *suppRegenRule =
  706. m_Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION");
  707. if (!cmSystemTools::IsOn(suppRegenRule))
  708. {
  709. this->AddVCProjBuildRule();
  710. }
  711. // trace the visual studio dependencies
  712. std::string name = libName;
  713. name += ".vcproj.cmake";
  714. target.TraceVSDependencies(name, m_Makefile);
  715. // We may be modifying the source groups temporarily, so make a copy.
  716. std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups();
  717. // get the classes from the source lists then add them to the groups
  718. std::vector<cmSourceFile*> & classes = target.GetSourceFiles();
  719. for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
  720. i != classes.end(); i++)
  721. {
  722. // Add the file to the list of sources.
  723. std::string source = (*i)->GetFullPath();
  724. if(cmSystemTools::UpperCase((*i)->GetSourceExtension()) == "DEF")
  725. {
  726. m_ModuleDefinitionFile = (*i)->GetFullPath();
  727. }
  728. cmSourceGroup& sourceGroup =
  729. m_Makefile->FindSourceGroup(source.c_str(), sourceGroups);
  730. sourceGroup.AssignSource(*i);
  731. }
  732. // open the project
  733. this->WriteProjectStart(fout, libName, target, sourceGroups);
  734. // write the configuration information
  735. this->WriteConfigurations(fout, libName, target);
  736. fout << "\t<Files>\n";
  737. // Loop through every source group.
  738. for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin();
  739. sg != sourceGroups.end(); ++sg)
  740. {
  741. const std::vector<const cmSourceFile *> &sourceFiles =
  742. sg->GetSourceFiles();
  743. // If the group is empty, don't write it at all.
  744. if(sourceFiles.empty())
  745. {
  746. continue;
  747. }
  748. // If the group has a name, write the header.
  749. std::string name = sg->GetName();
  750. if(name != "")
  751. {
  752. this->WriteVCProjBeginGroup(fout, name.c_str(), "");
  753. }
  754. // Loop through each source in the source group.
  755. for(std::vector<const cmSourceFile *>::const_iterator sf =
  756. sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
  757. {
  758. std::string source = (*sf)->GetFullPath();
  759. const cmCustomCommand *command = (*sf)->GetCustomCommand();
  760. std::string compileFlags;
  761. std::string additionalDeps;
  762. // Check for extra compiler flags.
  763. const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS");
  764. if(cflags)
  765. {
  766. compileFlags = cflags;
  767. }
  768. if(cmSystemTools::GetFileFormat((*sf)->GetSourceExtension().c_str())
  769. == cmSystemTools::CXX_FILE_FORMAT)
  770. {
  771. // force a C++ file type
  772. compileFlags += " /TP ";
  773. }
  774. // Check for extra object-file dependencies.
  775. const char* deps = (*sf)->GetProperty("OBJECT_DEPENDS");
  776. if(deps)
  777. {
  778. std::vector<std::string> depends;
  779. cmSystemTools::ExpandListArgument(deps, depends);
  780. if(!depends.empty())
  781. {
  782. std::vector<std::string>::iterator i = depends.begin();
  783. additionalDeps = this->ConvertToXMLOutputPath(i->c_str());
  784. for(++i;i != depends.end(); ++i)
  785. {
  786. additionalDeps += ";";
  787. additionalDeps += this->ConvertToXMLOutputPath(i->c_str());
  788. }
  789. }
  790. }
  791. if (source != libName || target.GetType() == cmTarget::UTILITY)
  792. {
  793. fout << "\t\t\t<File\n";
  794. std::string d = this->ConvertToXMLOutputPathSingle(source.c_str());
  795. // Tell MS-Dev what the source is. If the compiler knows how to
  796. // build it, then it will.
  797. fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
  798. if (command)
  799. {
  800. std::string totalCommandStr;
  801. totalCommandStr =
  802. cmSystemTools::ConvertToOutputPath(command->GetCommand().c_str());
  803. totalCommandStr += " ";
  804. totalCommandStr += command->GetArguments();
  805. totalCommandStr += "\n";
  806. const char* comment = command->GetComment().c_str();
  807. const char* flags = compileFlags.size() ? compileFlags.c_str(): 0;
  808. this->WriteCustomRule(fout, source.c_str(), totalCommandStr.c_str(),
  809. (*comment?comment:"Custom Rule"),
  810. command->GetDepends(),
  811. command->GetOutput().c_str(), flags);
  812. }
  813. else if(compileFlags.size() || additionalDeps.length())
  814. {
  815. for(std::vector<std::string>::iterator i = configs->begin();
  816. i != configs->end(); ++i)
  817. {
  818. fout << "\t\t\t\t<FileConfiguration\n"
  819. << "\t\t\t\t\tName=\"" << *i << "|Win32\">\n"
  820. << "\t\t\t\t\t<Tool\n"
  821. << "\t\t\t\t\tName=\"VCCLCompilerTool\"\n";
  822. if(compileFlags.size())
  823. {
  824. fout << "\t\t\t\t\tAdditionalOptions=\""
  825. << compileFlags << "\"\n";
  826. }
  827. if(additionalDeps.length())
  828. {
  829. fout << "\t\t\t\t\tAdditionalDependencies=\""
  830. << additionalDeps.c_str() << "\"\n";
  831. }
  832. fout << "\t\t\t\t\t/>\n"
  833. << "\t\t\t\t</FileConfiguration>\n";
  834. }
  835. }
  836. fout << "\t\t\t</File>\n";
  837. }
  838. }
  839. // If the group has a name, write the footer.
  840. if(name != "")
  841. {
  842. this->WriteVCProjEndGroup(fout);
  843. }
  844. }
  845. fout << "\t</Files>\n";
  846. // Write the VCProj file's footer.
  847. this->WriteVCProjFooter(fout);
  848. }
  849. void cmLocalVisualStudio7Generator::
  850. WriteCustomRule(std::ostream& fout,
  851. const char* source,
  852. const char* command,
  853. const char* comment,
  854. const std::vector<std::string>& depends,
  855. const char *output,
  856. const char* compileFlags)
  857. {
  858. std::string cmd = command;
  859. cmSystemTools::ReplaceString(cmd, "\"", "&quot;");
  860. std::vector<std::string>::iterator i;
  861. std::vector<std::string> *configs =
  862. static_cast<cmGlobalVisualStudio7Generator *>(m_GlobalGenerator)->GetConfigurations();
  863. for(i = configs->begin(); i != configs->end(); ++i)
  864. {
  865. fout << "\t\t\t\t<FileConfiguration\n";
  866. fout << "\t\t\t\t\tName=\"" << *i << "|Win32\">\n";
  867. if(compileFlags)
  868. {
  869. fout << "\t\t\t\t\t<Tool\n"
  870. << "\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
  871. << "\t\t\t\t\tAdditionalOptions=\""
  872. << compileFlags << "\"/>\n";
  873. }
  874. fout << "\t\t\t\t\t<Tool\n"
  875. << "\t\t\t\t\tName=\"VCCustomBuildTool\"\n"
  876. << "\t\t\t\t\tDescription=\"Building " << comment;
  877. fout << " " << output;
  878. fout << "\"\n"
  879. << "\t\t\t\t\tCommandLine=\"" << cmd << "\n\"\n"
  880. << "\t\t\t\t\tAdditionalDependencies=\"";
  881. // Write out the dependencies for the rule.
  882. std::string temp;
  883. for(std::vector<std::string>::const_iterator d = depends.begin();
  884. d != depends.end(); ++d)
  885. {
  886. std::string dep = cmSystemTools::GetFilenameName(*d);
  887. if (cmSystemTools::GetFilenameLastExtension(dep) == ".exe")
  888. {
  889. dep = cmSystemTools::GetFilenameWithoutLastExtension(dep);
  890. }
  891. std::string libPath = dep + "_CMAKE_PATH";
  892. const char* cacheValue = m_Makefile->GetDefinition(libPath.c_str());
  893. if (cacheValue)
  894. {
  895. std::string exePath = "";
  896. if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
  897. {
  898. exePath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
  899. }
  900. if(exePath.size())
  901. {
  902. libPath = exePath;
  903. }
  904. else
  905. {
  906. libPath = cacheValue;
  907. }
  908. libPath += "/";
  909. libPath += "$(INTDIR)";
  910. libPath += dep;
  911. libPath += ".exe";
  912. fout << this->ConvertToXMLOutputPath(libPath.c_str())
  913. << ";";
  914. }
  915. else
  916. {
  917. fout << this->ConvertToXMLOutputPath(d->c_str())
  918. << ";";
  919. }
  920. }
  921. fout << "\"\n";
  922. fout << "\t\t\t\t\tOutputs=\"";
  923. if(output == 0)
  924. {
  925. fout << source << "_force";
  926. }
  927. // Write a rule for the output generated by this command.
  928. fout << this->ConvertToXMLOutputPathSingle(output);
  929. fout << "\"/>\n";
  930. fout << "\t\t\t\t</FileConfiguration>\n";
  931. }
  932. }
  933. void cmLocalVisualStudio7Generator::WriteVCProjBeginGroup(std::ostream& fout,
  934. const char* group,
  935. const char* )
  936. {
  937. fout << "\t\t<Filter\n"
  938. << "\t\t\tName=\"" << group << "\"\n"
  939. << "\t\t\tFilter=\"\">\n";
  940. }
  941. void cmLocalVisualStudio7Generator::WriteVCProjEndGroup(std::ostream& fout)
  942. {
  943. fout << "\t\t</Filter>\n";
  944. }
  945. // look for custom rules on a target and collect them together
  946. void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout,
  947. const cmTarget &target,
  948. const char * /* libName */)
  949. {
  950. if (target.GetType() > cmTarget::UTILITY)
  951. {
  952. return;
  953. }
  954. // add the pre build rules
  955. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"";
  956. bool init = false;
  957. for (std::vector<cmCustomCommand>::const_iterator cr =
  958. target.GetPreBuildCommands().begin();
  959. cr != target.GetPreBuildCommands().end(); ++cr)
  960. {
  961. cmCustomCommand cc(*cr);
  962. cc.ExpandVariables(*m_Makefile);
  963. if(!init)
  964. {
  965. fout << "\nCommandLine=\"";
  966. init = true;
  967. }
  968. std::string args = cc.GetArguments();
  969. cmSystemTools::ReplaceString(args, "\"", "&quot;");
  970. fout << this->ConvertToXMLOutputPath(cc.GetCommand().c_str()) << " " <<
  971. args << "\n";
  972. }
  973. if (init)
  974. {
  975. fout << "\"";
  976. }
  977. fout << "/>\n";
  978. // add the pre Link rules
  979. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"";
  980. init = false;
  981. for (std::vector<cmCustomCommand>::const_iterator cr =
  982. target.GetPreLinkCommands().begin();
  983. cr != target.GetPreLinkCommands().end(); ++cr)
  984. {
  985. cmCustomCommand cc(*cr);
  986. cc.ExpandVariables(*m_Makefile);
  987. if(!init)
  988. {
  989. fout << "\nCommandLine=\"";
  990. init = true;
  991. }
  992. std::string args = cc.GetArguments();
  993. cmSystemTools::ReplaceString(args, "\"", "&quot;");
  994. fout << this->ConvertToXMLOutputPath(cc.GetCommand().c_str()) << " " <<
  995. args << "\n";
  996. }
  997. if (init)
  998. {
  999. fout << "\"";
  1000. }
  1001. fout << "/>\n";
  1002. // add the PostBuild rules
  1003. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"";
  1004. init = false;
  1005. for (std::vector<cmCustomCommand>::const_iterator cr =
  1006. target.GetPostBuildCommands().begin();
  1007. cr != target.GetPostBuildCommands().end(); ++cr)
  1008. {
  1009. cmCustomCommand cc(*cr);
  1010. cc.ExpandVariables(*m_Makefile);
  1011. if(!init)
  1012. {
  1013. fout << "\nCommandLine=\"";
  1014. init = true;
  1015. }
  1016. std::string args = cc.GetArguments();
  1017. cmSystemTools::ReplaceString(args, "\"", "&quot;");
  1018. fout << this->ConvertToXMLOutputPath(cc.GetCommand().c_str()) << " " <<
  1019. args << "\n";
  1020. }
  1021. if (init)
  1022. {
  1023. fout << "\"";
  1024. }
  1025. fout << "/>\n";
  1026. }
  1027. void
  1028. cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
  1029. const char *libName,
  1030. const cmTarget &,
  1031. std::vector<cmSourceGroup> &)
  1032. {
  1033. fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
  1034. << "<VisualStudioProject\n"
  1035. << "\tProjectType=\"Visual C++\"\n";
  1036. if(m_Version71)
  1037. {
  1038. fout << "\tVersion=\"7.10\"\n";
  1039. }
  1040. else
  1041. {
  1042. fout << "\tVersion=\"7.00\"\n";
  1043. }
  1044. fout << "\tName=\"" << libName << "\"\n"
  1045. << "\tSccProjectName=\"\"\n"
  1046. << "\tSccLocalPath=\"\"\n"
  1047. << "\tKeyword=\"Win32Proj\">\n"
  1048. << "\t<Platforms>\n"
  1049. << "\t\t<Platform\n\t\t\tName=\"Win32\"/>\n"
  1050. << "\t</Platforms>\n";
  1051. }
  1052. void cmLocalVisualStudio7Generator::WriteVCProjFooter(std::ostream& fout)
  1053. {
  1054. fout << "\t<Globals>\n"
  1055. << "\t</Globals>\n"
  1056. << "</VisualStudioProject>\n";
  1057. }
  1058. std::string cmLocalVisualStudio7Generator::EscapeForXML(const char* s)
  1059. {
  1060. std::string ret = s;
  1061. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1062. cmSystemTools::ReplaceString(ret, "\"", "&quot;");
  1063. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1064. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1065. return ret;
  1066. }
  1067. std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPath(const char* path)
  1068. {
  1069. std::string ret = cmSystemTools::ConvertToOutputPath(path);
  1070. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1071. cmSystemTools::ReplaceString(ret, "\"", "&quot;");
  1072. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1073. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1074. return ret;
  1075. }
  1076. std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPathSingle(const char* path)
  1077. {
  1078. std::string ret = cmSystemTools::ConvertToOutputPath(path);
  1079. cmSystemTools::ReplaceString(ret, "\"", "");
  1080. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1081. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1082. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1083. return ret;
  1084. }