cmLocalVisualStudio7Generator.cxx 38 KB

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