cmLocalVisualStudio7Generator.cxx 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170
  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. // check the flags for the run time library flag options
  319. // if there is a match set the run time flag
  320. if(flags.find("MTd") != flags.npos)
  321. {
  322. cmSystemTools::ReplaceString(flags, "-MTd", "");
  323. cmSystemTools::ReplaceString(flags, "/MTd", "");
  324. runtime = 1;
  325. }
  326. else if (flags.find("MDd") != flags.npos)
  327. {
  328. cmSystemTools::ReplaceString(flags, "-MDd", "");
  329. cmSystemTools::ReplaceString(flags, "/MDd", "");
  330. runtime = 3;
  331. }
  332. else if (flags.find("MLd") != flags.npos)
  333. {
  334. cmSystemTools::ReplaceString(flags, "-MLd", "");
  335. cmSystemTools::ReplaceString(flags, "/MLd", "");
  336. runtime = 5;
  337. }
  338. else if (flags.find("MT") != flags.npos)
  339. {
  340. cmSystemTools::ReplaceString(flags, "-MT", "");
  341. cmSystemTools::ReplaceString(flags, "/MT", "");
  342. runtime = 0;
  343. }
  344. else if (flags.find("MD") != flags.npos)
  345. {
  346. cmSystemTools::ReplaceString(flags, "-MD", "");
  347. cmSystemTools::ReplaceString(flags, "/MD", "");
  348. runtime = 2;
  349. }
  350. else if (flags.find("ML") != flags.npos)
  351. {
  352. cmSystemTools::ReplaceString(flags, "-ML", "");
  353. cmSystemTools::ReplaceString(flags, "/ML", "");
  354. runtime = 4;
  355. }
  356. fout << this->EscapeForXML(flags.c_str()).c_str();
  357. fout << " -DCMAKE_INTDIR=\\&quot;" << configName << "\\&quot;"
  358. << "\"\n";
  359. fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
  360. std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
  361. std::vector<std::string>::iterator i = includes.begin();
  362. for(;i != includes.end(); ++i)
  363. {
  364. std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
  365. fout << ipath << ";";
  366. }
  367. fout << "\"\n";
  368. fout << "\t\t\t\tOptimization=\"" << optimized << "\"\n"
  369. << "\t\t\t\tRuntimeLibrary=\"" << runtime << "\"\n"
  370. << "\t\t\t\tInlineFunctionExpansion=\"" << inlineFunctions << "\"\n"
  371. << "\t\t\t\tPreprocessorDefinitions=\"" << pre;
  372. if(target.GetType() == cmTarget::SHARED_LIBRARY
  373. || target.GetType() == cmTarget::MODULE_LIBRARY)
  374. {
  375. std::string exportSymbol;
  376. if (const char* custom_export_name = target.GetProperty("DEFINE_SYMBOL"))
  377. {
  378. exportSymbol = custom_export_name;
  379. }
  380. else
  381. {
  382. std::string id = libName;
  383. id += "_EXPORTS";
  384. exportSymbol = cmSystemTools::MakeCindentifier(id.c_str());
  385. }
  386. fout << "," << exportSymbol;
  387. }
  388. this->OutputDefineFlags(fout);
  389. fout << "\"\n";
  390. if(m_Makefile->IsOn("CMAKE_CXX_USE_RTTI"))
  391. {
  392. fout << "\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n";
  393. }
  394. fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n";
  395. fout << "\t\t\t\tObjectFile=\"" << configName << "\\\"\n";
  396. if ( m_Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL") )
  397. {
  398. fout << "\t\t\t\tWarningLevel=\"" << m_Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL") << "\"\n";
  399. }
  400. fout << "\t\t\t\tDebugInformationFormat=\"3\"";
  401. fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
  402. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n";
  403. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n"
  404. << "\t\t\t\tAdditionalIncludeDirectories=\"";
  405. for(i = includes.begin();i != includes.end(); ++i)
  406. {
  407. std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
  408. fout << ipath << ";";
  409. }
  410. fout << "\"\n"
  411. << "\t\t\t\tPreprocessorDefinitions=\"" << pre;
  412. this->OutputDefineFlags(fout);
  413. fout << "\" />\n";
  414. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n";
  415. this->OutputTargetRules(fout, target, libName);
  416. this->OutputBuildTool(fout, configName, libName, target);
  417. fout << "\t\t</Configuration>\n";
  418. }
  419. void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
  420. const char* configName,
  421. const char *libName,
  422. const cmTarget &target)
  423. {
  424. std::string temp;
  425. std::string debugPostfix = "";
  426. bool debug = !strcmp(configName,"Debug");
  427. if (debug && m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"))
  428. {
  429. debugPostfix = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
  430. }
  431. std::string extraLinkOptions;
  432. if((target.GetType() == cmTarget::EXECUTABLE) ||
  433. (target.GetType() == cmTarget::WIN32_EXECUTABLE))
  434. {
  435. extraLinkOptions = m_Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS");
  436. }
  437. if(target.GetType() == cmTarget::SHARED_LIBRARY)
  438. {
  439. extraLinkOptions = m_Makefile->GetDefinition("CMAKE_SHARED_LINKER_FLAGS");
  440. }
  441. if(target.GetType() == cmTarget::MODULE_LIBRARY)
  442. {
  443. extraLinkOptions = m_Makefile->GetDefinition("CMAKE_MODULE_LINKER_FLAGS");
  444. }
  445. const char* targetLinkFlags = target.GetProperty("LINK_FLAGS");
  446. if(targetLinkFlags)
  447. {
  448. extraLinkOptions += " ";
  449. extraLinkOptions += targetLinkFlags;
  450. }
  451. switch(target.GetType())
  452. {
  453. case cmTarget::STATIC_LIBRARY:
  454. {
  455. std::string libpath = m_LibraryOutputPath +
  456. "$(OutDir)/" + libName + debugPostfix + ".lib";
  457. fout << "\t\t\t<Tool\n"
  458. << "\t\t\t\tName=\"VCLibrarianTool\"\n"
  459. << "\t\t\t\t\tOutputFile=\""
  460. << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << ".\"/>\n";
  461. break;
  462. }
  463. case cmTarget::SHARED_LIBRARY:
  464. case cmTarget::MODULE_LIBRARY:
  465. fout << "\t\t\t<Tool\n"
  466. << "\t\t\t\tName=\"VCLinkerTool\"\n"
  467. << "\t\t\t\tAdditionalOptions=\"/MACHINE:I386";
  468. if(extraLinkOptions.size())
  469. {
  470. fout << " " << cmLocalVisualStudio7Generator::EscapeForXML(
  471. extraLinkOptions.c_str()).c_str();
  472. }
  473. fout << "\"\n"
  474. << "\t\t\t\tAdditionalDependencies=\" odbc32.lib odbccp32.lib ";
  475. this->OutputLibraries(fout, configName, libName, target);
  476. fout << "\"\n";
  477. temp = m_LibraryOutputPath;
  478. temp += configName;
  479. temp += "/";
  480. temp += libName;
  481. temp += debugPostfix;
  482. temp += ".dll";
  483. fout << "\t\t\t\tOutputFile=\""
  484. << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  485. fout << "\t\t\t\tLinkIncremental=\"1\"\n";
  486. fout << "\t\t\t\tSuppressStartupBanner=\"TRUE\"\n";
  487. fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
  488. this->OutputLibraryDirectories(fout, configName, libName, target);
  489. fout << "\"\n";
  490. this->OutputModuleDefinitionFile(fout, target);
  491. temp = m_LibraryOutputPath;
  492. temp += "$(OutDir)/";
  493. temp += libName;
  494. temp += debugPostfix;
  495. temp += ".pdb";
  496. fout << "\t\t\t\tProgramDatabaseFile=\"" <<
  497. this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  498. if(strcmp(configName, "Debug") == 0
  499. || strcmp(configName, "RelWithDebInfo") == 0)
  500. {
  501. fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
  502. }
  503. fout << "\t\t\t\tStackReserveSize=\""
  504. << m_Makefile->GetDefinition("CMAKE_CXX_STACK_SIZE") << "\"\n";
  505. temp = m_ExecutableOutputPath;
  506. temp += configName;
  507. temp += "/";
  508. temp += libName;
  509. temp += debugPostfix;
  510. temp += ".lib";
  511. fout << "\t\t\t\tImportLibrary=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n";
  512. break;
  513. case cmTarget::EXECUTABLE:
  514. case cmTarget::WIN32_EXECUTABLE:
  515. fout << "\t\t\t<Tool\n"
  516. << "\t\t\t\tName=\"VCLinkerTool\"\n"
  517. << "\t\t\t\tAdditionalOptions=\"/MACHINE:I386";
  518. if(extraLinkOptions.size())
  519. {
  520. fout << " " << cmLocalVisualStudio7Generator::EscapeForXML(
  521. extraLinkOptions.c_str()).c_str();
  522. }
  523. fout << "\"\n"
  524. << "\t\t\t\tAdditionalDependencies=\" odbc32.lib odbccp32.lib ";
  525. this->OutputLibraries(fout, configName, libName, target);
  526. fout << "\"\n";
  527. temp = m_ExecutableOutputPath;
  528. temp += configName;
  529. temp += "/";
  530. temp += libName;
  531. temp += ".exe";
  532. fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  533. fout << "\t\t\t\tLinkIncremental=\"1\"\n";
  534. fout << "\t\t\t\tSuppressStartupBanner=\"TRUE\"\n";
  535. fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
  536. this->OutputLibraryDirectories(fout, configName, libName, target);
  537. fout << "\"\n";
  538. fout << "\t\t\t\tProgramDatabaseFile=\"" << m_LibraryOutputPath
  539. << "$(OutDir)\\" << libName << ".pdb\"\n";
  540. if(strcmp(configName, "Debug") == 0
  541. || strcmp(configName, "RelWithDebInfo") == 0)
  542. {
  543. fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
  544. }
  545. if( target.GetType() == cmTarget::EXECUTABLE)
  546. {
  547. fout << "\t\t\t\tSubSystem=\"1\"\n";
  548. }
  549. else
  550. {
  551. fout << "\t\t\t\tSubSystem=\"2\"\n";
  552. }
  553. fout << "\t\t\t\tStackReserveSize=\""
  554. << m_Makefile->GetDefinition("CMAKE_CXX_STACK_SIZE") << "\"/>\n";
  555. break;
  556. case cmTarget::UTILITY:
  557. break;
  558. }
  559. }
  560. void cmLocalVisualStudio7Generator::OutputModuleDefinitionFile(std::ostream& fout,
  561. const cmTarget &target)
  562. {
  563. std::vector<cmSourceFile*> const& classes = target.GetSourceFiles();
  564. for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
  565. i != classes.end(); i++)
  566. {
  567. if(cmSystemTools::UpperCase((*i)->GetSourceExtension()) == "DEF")
  568. {
  569. fout << "\t\t\t\tModuleDefinitionFile=\""
  570. << this->ConvertToXMLOutputPath((*i)->GetFullPath().c_str())
  571. << "\"\n";
  572. return;
  573. }
  574. }
  575. }
  576. void cmLocalVisualStudio7Generator::OutputLibraryDirectories(std::ostream& fout,
  577. const char*,
  578. const char*,
  579. const cmTarget &tgt)
  580. {
  581. bool hasone = false;
  582. if(m_LibraryOutputPath.size())
  583. {
  584. hasone = true;
  585. std::string temp = m_LibraryOutputPath;
  586. temp += "$(INTDIR)";
  587. fout << this->ConvertToXMLOutputPath(temp.c_str()) << "," <<
  588. this->ConvertToXMLOutputPath(m_LibraryOutputPath.c_str());
  589. }
  590. if(m_ExecutableOutputPath.size() &&
  591. (m_LibraryOutputPath != m_ExecutableOutputPath))
  592. {
  593. if (hasone)
  594. {
  595. fout << ",";
  596. }
  597. hasone = true;
  598. std::string temp = m_ExecutableOutputPath;
  599. temp += "$(INTDIR)";
  600. fout << this->ConvertToXMLOutputPath(temp.c_str()) << "," <<
  601. this->ConvertToXMLOutputPath(m_ExecutableOutputPath.c_str());
  602. }
  603. std::set<std::string> pathEmitted;
  604. std::vector<std::string>::const_iterator i;
  605. const std::vector<std::string>& libdirs = tgt.GetLinkDirectories();
  606. for(i = libdirs.begin(); i != libdirs.end(); ++i)
  607. {
  608. std::string lpath = *i;
  609. if(lpath[lpath.size()-1] != '/')
  610. {
  611. lpath += "/";
  612. }
  613. if(pathEmitted.insert(lpath).second)
  614. {
  615. if(hasone)
  616. {
  617. fout << ",";
  618. }
  619. std::string lpathi = lpath + "$(INTDIR)";
  620. fout << this->ConvertToXMLOutputPath(lpathi.c_str()) << "," <<
  621. this->ConvertToXMLOutputPath(lpath.c_str());
  622. hasone = true;
  623. }
  624. }
  625. }
  626. void cmLocalVisualStudio7Generator::OutputLibraries(std::ostream& fout,
  627. const char* configName,
  628. const char* libName,
  629. const cmTarget &target)
  630. {
  631. const cmTarget::LinkLibraries& libs = target.GetLinkLibraries();
  632. cmTarget::LinkLibraries::const_iterator j;
  633. for(j = libs.begin(); j != libs.end(); ++j)
  634. {
  635. if(j->first != libName)
  636. {
  637. std::string lib = j->first;
  638. std::string debugPostfix = "";
  639. // if this is a library we are building then watch for a debugPostfix
  640. if (!strcmp(configName,"Debug"))
  641. {
  642. std::string libPath = j->first + "_CMAKE_PATH";
  643. const char* cacheValue
  644. = m_GlobalGenerator->GetCMakeInstance()->GetCacheDefinition(libPath.c_str());
  645. if(cacheValue && *cacheValue && m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"))
  646. {
  647. debugPostfix = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
  648. }
  649. }
  650. if(j->first.find(".lib") == std::string::npos)
  651. {
  652. lib += debugPostfix + ".lib";
  653. }
  654. lib = this->ConvertToXMLOutputPath(lib.c_str());
  655. if (j->second == cmTarget::GENERAL
  656. || (j->second == cmTarget::DEBUG && strcmp(configName, "Debug") == 0)
  657. || (j->second == cmTarget::OPTIMIZED && strcmp(configName, "Debug") != 0))
  658. {
  659. fout << lib << " ";
  660. }
  661. }
  662. }
  663. }
  664. void cmLocalVisualStudio7Generator::OutputDefineFlags(std::ostream& fout)
  665. {
  666. std::string defs = m_Makefile->GetDefineFlags();
  667. cmSystemTools::ReplaceString(defs, "/D","-D");
  668. std::string::size_type pos = defs.find("-D");
  669. bool done = pos == std::string::npos;
  670. if(!done)
  671. {
  672. fout << ",";
  673. }
  674. while(!done)
  675. {
  676. std::string::size_type nextpos = defs.find("-D", pos+2);
  677. std::string define;
  678. if(nextpos != std::string::npos)
  679. {
  680. define = defs.substr(pos+2, nextpos - pos -3);
  681. }
  682. else
  683. {
  684. define = defs.substr(pos+2);
  685. done = true;
  686. }
  687. cmSystemTools::ReplaceString(define, "\"", "&quot;");
  688. fout << define << ",";
  689. if(!done)
  690. {
  691. pos = defs.find("-D", nextpos);
  692. }
  693. }
  694. }
  695. void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
  696. const char *libName,
  697. cmTarget &target)
  698. {
  699. // get the configurations
  700. std::vector<std::string> *configs =
  701. static_cast<cmGlobalVisualStudio7Generator *>
  702. (m_GlobalGenerator)->GetConfigurations();
  703. // if we should add regen rule then...
  704. const char *suppRegenRule =
  705. m_Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION");
  706. if (!cmSystemTools::IsOn(suppRegenRule))
  707. {
  708. this->AddVCProjBuildRule();
  709. }
  710. // trace the visual studio dependencies
  711. std::string name = libName;
  712. name += ".vcproj.cmake";
  713. target.TraceVSDependencies(name, m_Makefile);
  714. // We may be modifying the source groups temporarily, so make a copy.
  715. std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups();
  716. // get the classes from the source lists then add them to the groups
  717. std::vector<cmSourceFile*> & classes = target.GetSourceFiles();
  718. for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
  719. i != classes.end(); i++)
  720. {
  721. // Add the file to the list of sources.
  722. std::string source = (*i)->GetFullPath();
  723. if(cmSystemTools::UpperCase((*i)->GetSourceExtension()) == "DEF")
  724. {
  725. m_ModuleDefinitionFile = (*i)->GetFullPath();
  726. }
  727. cmSourceGroup& sourceGroup =
  728. m_Makefile->FindSourceGroup(source.c_str(), sourceGroups);
  729. sourceGroup.AssignSource(*i);
  730. }
  731. // open the project
  732. this->WriteProjectStart(fout, libName, target, sourceGroups);
  733. // write the configuration information
  734. this->WriteConfigurations(fout, libName, target);
  735. fout << "\t<Files>\n";
  736. // Loop through every source group.
  737. for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin();
  738. sg != sourceGroups.end(); ++sg)
  739. {
  740. const std::vector<const cmSourceFile *> &sourceFiles =
  741. sg->GetSourceFiles();
  742. // If the group is empty, don't write it at all.
  743. if(sourceFiles.empty())
  744. {
  745. continue;
  746. }
  747. // If the group has a name, write the header.
  748. std::string name = sg->GetName();
  749. if(name != "")
  750. {
  751. this->WriteVCProjBeginGroup(fout, name.c_str(), "");
  752. }
  753. // Loop through each source in the source group.
  754. for(std::vector<const cmSourceFile *>::const_iterator sf =
  755. sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
  756. {
  757. std::string source = (*sf)->GetFullPath();
  758. const cmCustomCommand *command = (*sf)->GetCustomCommand();
  759. std::string compileFlags;
  760. std::string additionalDeps;
  761. // Check for extra compiler flags.
  762. const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS");
  763. if(cflags)
  764. {
  765. compileFlags = cflags;
  766. }
  767. if(cmSystemTools::GetFileFormat((*sf)->GetSourceExtension().c_str())
  768. == cmSystemTools::CXX_FILE_FORMAT)
  769. {
  770. // force a C++ file type
  771. compileFlags += " /TP ";
  772. }
  773. // Check for extra object-file dependencies.
  774. const char* deps = (*sf)->GetProperty("OBJECT_DEPENDS");
  775. if(deps)
  776. {
  777. std::vector<std::string> depends;
  778. cmSystemTools::ExpandListArgument(deps, depends);
  779. if(!depends.empty())
  780. {
  781. std::vector<std::string>::iterator i = depends.begin();
  782. additionalDeps = this->ConvertToXMLOutputPath(i->c_str());
  783. for(++i;i != depends.end(); ++i)
  784. {
  785. additionalDeps += ";";
  786. additionalDeps += this->ConvertToXMLOutputPath(i->c_str());
  787. }
  788. }
  789. }
  790. if (source != libName || target.GetType() == cmTarget::UTILITY)
  791. {
  792. fout << "\t\t\t<File\n";
  793. std::string d = this->ConvertToXMLOutputPathSingle(source.c_str());
  794. // Tell MS-Dev what the source is. If the compiler knows how to
  795. // build it, then it will.
  796. fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
  797. if (command)
  798. {
  799. std::string totalCommandStr;
  800. totalCommandStr =
  801. cmSystemTools::ConvertToOutputPath(command->GetCommand().c_str());
  802. totalCommandStr += " ";
  803. totalCommandStr += command->GetArguments();
  804. totalCommandStr += "\n";
  805. const char* comment = command->GetComment().c_str();
  806. const char* flags = compileFlags.size() ? compileFlags.c_str(): 0;
  807. this->WriteCustomRule(fout, source.c_str(), totalCommandStr.c_str(),
  808. (*comment?comment:"Custom Rule"),
  809. command->GetDepends(),
  810. command->GetOutput().c_str(), flags);
  811. }
  812. else if(compileFlags.size() || additionalDeps.length())
  813. {
  814. const char* aCompilerTool = "VCCLCompilerTool";
  815. if((*sf)->GetSourceExtension() == "idl")
  816. {
  817. aCompilerTool = "VCMIDLTool";
  818. }
  819. for(std::vector<std::string>::iterator i = configs->begin();
  820. i != configs->end(); ++i)
  821. {
  822. fout << "\t\t\t\t<FileConfiguration\n"
  823. << "\t\t\t\t\tName=\"" << *i << "|Win32\">\n"
  824. << "\t\t\t\t\t<Tool\n"
  825. << "\t\t\t\t\tName=\"" << aCompilerTool << "\"\n";
  826. if(compileFlags.size())
  827. {
  828. fout << "\t\t\t\t\tAdditionalOptions=\""
  829. << this->EscapeForXML(compileFlags.c_str()) << "\"\n";
  830. }
  831. if(additionalDeps.length())
  832. {
  833. fout << "\t\t\t\t\tAdditionalDependencies=\""
  834. << additionalDeps.c_str() << "\"\n";
  835. }
  836. fout << "\t\t\t\t\t/>\n"
  837. << "\t\t\t\t</FileConfiguration>\n";
  838. }
  839. }
  840. fout << "\t\t\t</File>\n";
  841. }
  842. }
  843. // If the group has a name, write the footer.
  844. if(name != "")
  845. {
  846. this->WriteVCProjEndGroup(fout);
  847. }
  848. }
  849. fout << "\t</Files>\n";
  850. // Write the VCProj file's footer.
  851. this->WriteVCProjFooter(fout);
  852. }
  853. void cmLocalVisualStudio7Generator::
  854. WriteCustomRule(std::ostream& fout,
  855. const char* source,
  856. const char* command,
  857. const char* comment,
  858. const std::vector<std::string>& depends,
  859. const char *output,
  860. const char* compileFlags)
  861. {
  862. std::string cmd = command;
  863. cmSystemTools::ReplaceString(cmd, "\"", "&quot;");
  864. std::vector<std::string>::iterator i;
  865. std::vector<std::string> *configs =
  866. static_cast<cmGlobalVisualStudio7Generator *>(m_GlobalGenerator)->GetConfigurations();
  867. for(i = configs->begin(); i != configs->end(); ++i)
  868. {
  869. fout << "\t\t\t\t<FileConfiguration\n";
  870. fout << "\t\t\t\t\tName=\"" << *i << "|Win32\">\n";
  871. if(compileFlags)
  872. {
  873. fout << "\t\t\t\t\t<Tool\n"
  874. << "\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
  875. << "\t\t\t\t\tAdditionalOptions=\""
  876. << this->EscapeForXML(compileFlags) << "\"/>\n";
  877. }
  878. fout << "\t\t\t\t\t<Tool\n"
  879. << "\t\t\t\t\tName=\"VCCustomBuildTool\"\n"
  880. << "\t\t\t\t\tDescription=\"Building " << comment;
  881. fout << " " << output;
  882. fout << "\"\n"
  883. << "\t\t\t\t\tCommandLine=\"" << cmd << "\n\"\n"
  884. << "\t\t\t\t\tAdditionalDependencies=\"";
  885. // Write out the dependencies for the rule.
  886. std::string temp;
  887. for(std::vector<std::string>::const_iterator d = depends.begin();
  888. d != depends.end(); ++d)
  889. {
  890. std::string dep = cmSystemTools::GetFilenameName(*d);
  891. if (cmSystemTools::GetFilenameLastExtension(dep) == ".exe")
  892. {
  893. dep = cmSystemTools::GetFilenameWithoutLastExtension(dep);
  894. }
  895. std::string libPath = dep + "_CMAKE_PATH";
  896. const char* cacheValue = m_Makefile->GetDefinition(libPath.c_str());
  897. if (cacheValue && *cacheValue)
  898. {
  899. std::string exePath = "";
  900. if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
  901. {
  902. exePath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
  903. }
  904. if(exePath.size())
  905. {
  906. libPath = exePath;
  907. }
  908. else
  909. {
  910. libPath = cacheValue;
  911. }
  912. libPath += "/";
  913. libPath += "$(INTDIR)";
  914. libPath += dep;
  915. libPath += ".exe";
  916. fout << this->ConvertToXMLOutputPath(libPath.c_str())
  917. << ";";
  918. }
  919. else
  920. {
  921. fout << this->ConvertToXMLOutputPath(d->c_str())
  922. << ";";
  923. }
  924. }
  925. fout << "\"\n";
  926. fout << "\t\t\t\t\tOutputs=\"";
  927. if(output == 0)
  928. {
  929. fout << source << "_force";
  930. }
  931. // Write a rule for the output generated by this command.
  932. fout << this->ConvertToXMLOutputPathSingle(output);
  933. fout << "\"/>\n";
  934. fout << "\t\t\t\t</FileConfiguration>\n";
  935. }
  936. }
  937. void cmLocalVisualStudio7Generator::WriteVCProjBeginGroup(std::ostream& fout,
  938. const char* group,
  939. const char* )
  940. {
  941. fout << "\t\t<Filter\n"
  942. << "\t\t\tName=\"" << group << "\"\n"
  943. << "\t\t\tFilter=\"\">\n";
  944. }
  945. void cmLocalVisualStudio7Generator::WriteVCProjEndGroup(std::ostream& fout)
  946. {
  947. fout << "\t\t</Filter>\n";
  948. }
  949. // look for custom rules on a target and collect them together
  950. void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout,
  951. const cmTarget &target,
  952. const char * /* libName */)
  953. {
  954. if (target.GetType() > cmTarget::UTILITY)
  955. {
  956. return;
  957. }
  958. // add the pre build rules
  959. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"";
  960. bool init = false;
  961. for (std::vector<cmCustomCommand>::const_iterator cr =
  962. target.GetPreBuildCommands().begin();
  963. cr != target.GetPreBuildCommands().end(); ++cr)
  964. {
  965. cmCustomCommand cc(*cr);
  966. cc.ExpandVariables(*m_Makefile);
  967. if(!init)
  968. {
  969. fout << "\nCommandLine=\"";
  970. init = true;
  971. }
  972. std::string args = cc.GetArguments();
  973. cmSystemTools::ReplaceString(args, "\"", "&quot;");
  974. fout << this->ConvertToXMLOutputPath(cc.GetCommand().c_str()) << " " <<
  975. args << "\n";
  976. }
  977. if (init)
  978. {
  979. fout << "\"";
  980. }
  981. fout << "/>\n";
  982. // add the pre Link rules
  983. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"";
  984. init = false;
  985. for (std::vector<cmCustomCommand>::const_iterator cr =
  986. target.GetPreLinkCommands().begin();
  987. cr != target.GetPreLinkCommands().end(); ++cr)
  988. {
  989. cmCustomCommand cc(*cr);
  990. cc.ExpandVariables(*m_Makefile);
  991. if(!init)
  992. {
  993. fout << "\nCommandLine=\"";
  994. init = true;
  995. }
  996. std::string args = cc.GetArguments();
  997. cmSystemTools::ReplaceString(args, "\"", "&quot;");
  998. fout << this->ConvertToXMLOutputPath(cc.GetCommand().c_str()) << " " <<
  999. args << "\n";
  1000. }
  1001. if (init)
  1002. {
  1003. fout << "\"";
  1004. }
  1005. fout << "/>\n";
  1006. // add the PostBuild rules
  1007. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"";
  1008. init = false;
  1009. for (std::vector<cmCustomCommand>::const_iterator cr =
  1010. target.GetPostBuildCommands().begin();
  1011. cr != target.GetPostBuildCommands().end(); ++cr)
  1012. {
  1013. cmCustomCommand cc(*cr);
  1014. cc.ExpandVariables(*m_Makefile);
  1015. if(!init)
  1016. {
  1017. fout << "\nCommandLine=\"";
  1018. init = true;
  1019. }
  1020. std::string args = cc.GetArguments();
  1021. cmSystemTools::ReplaceString(args, "\"", "&quot;");
  1022. fout << this->ConvertToXMLOutputPath(cc.GetCommand().c_str()) << " " <<
  1023. args << "\n";
  1024. }
  1025. if (init)
  1026. {
  1027. fout << "\"";
  1028. }
  1029. fout << "/>\n";
  1030. }
  1031. void
  1032. cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
  1033. const char *libName,
  1034. const cmTarget &,
  1035. std::vector<cmSourceGroup> &)
  1036. {
  1037. fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
  1038. << "<VisualStudioProject\n"
  1039. << "\tProjectType=\"Visual C++\"\n";
  1040. if(m_Version71)
  1041. {
  1042. fout << "\tVersion=\"7.10\"\n";
  1043. }
  1044. else
  1045. {
  1046. fout << "\tVersion=\"7.00\"\n";
  1047. }
  1048. fout << "\tName=\"" << libName << "\"\n"
  1049. << "\tSccProjectName=\"\"\n"
  1050. << "\tSccLocalPath=\"\"\n"
  1051. << "\tKeyword=\"Win32Proj\">\n"
  1052. << "\t<Platforms>\n"
  1053. << "\t\t<Platform\n\t\t\tName=\"Win32\"/>\n"
  1054. << "\t</Platforms>\n";
  1055. }
  1056. void cmLocalVisualStudio7Generator::WriteVCProjFooter(std::ostream& fout)
  1057. {
  1058. fout << "\t<Globals>\n"
  1059. << "\t</Globals>\n"
  1060. << "</VisualStudioProject>\n";
  1061. }
  1062. std::string cmLocalVisualStudio7Generator::EscapeForXML(const char* s)
  1063. {
  1064. std::string ret = s;
  1065. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1066. cmSystemTools::ReplaceString(ret, "\"", "&quot;");
  1067. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1068. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1069. return ret;
  1070. }
  1071. std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPath(const char* path)
  1072. {
  1073. std::string ret = cmSystemTools::ConvertToOutputPath(path);
  1074. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1075. cmSystemTools::ReplaceString(ret, "\"", "&quot;");
  1076. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1077. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1078. return ret;
  1079. }
  1080. std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPathSingle(const char* path)
  1081. {
  1082. std::string ret = cmSystemTools::ConvertToOutputPath(path);
  1083. cmSystemTools::ReplaceString(ret, "\"", "");
  1084. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1085. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1086. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1087. return ret;
  1088. }