cmLocalVisualStudio7Generator.cxx 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196
  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.GetPropertyAsBool("WIN32_EXECUTABLE") )
  569. {
  570. fout << "\t\t\t\tSubSystem=\"2\"\n";
  571. }
  572. else
  573. {
  574. fout << "\t\t\t\tSubSystem=\"1\"\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. // check to see if the dependency is another target built by cmake
  919. std::string libPath = dep + "_CMAKE_PATH";
  920. const char* cacheValue = m_Makefile->GetDefinition(libPath.c_str());
  921. if (cacheValue && *cacheValue)
  922. {
  923. std::string exePath = "";
  924. if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
  925. {
  926. exePath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
  927. }
  928. if(exePath.size())
  929. {
  930. libPath = exePath;
  931. }
  932. else
  933. {
  934. libPath = cacheValue;
  935. }
  936. libPath += "/";
  937. libPath += "$(INTDIR)/";
  938. libPath += dep;
  939. libPath += ".exe";
  940. fout << this->ConvertToXMLOutputPath(libPath.c_str())
  941. << ";";
  942. }
  943. else
  944. {
  945. fout << this->ConvertToXMLOutputPath(d->c_str())
  946. << ";";
  947. }
  948. }
  949. fout << "\"\n";
  950. fout << "\t\t\t\t\tOutputs=\"";
  951. if(output == 0)
  952. {
  953. fout << source << "_force";
  954. }
  955. // Write a rule for the output generated by this command.
  956. fout << this->ConvertToXMLOutputPathSingle(output);
  957. fout << "\"/>\n";
  958. fout << "\t\t\t\t</FileConfiguration>\n";
  959. }
  960. }
  961. void cmLocalVisualStudio7Generator::WriteVCProjBeginGroup(std::ostream& fout,
  962. const char* group,
  963. const char* )
  964. {
  965. fout << "\t\t<Filter\n"
  966. << "\t\t\tName=\"" << group << "\"\n"
  967. << "\t\t\tFilter=\"\">\n";
  968. }
  969. void cmLocalVisualStudio7Generator::WriteVCProjEndGroup(std::ostream& fout)
  970. {
  971. fout << "\t\t</Filter>\n";
  972. }
  973. // look for custom rules on a target and collect them together
  974. void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout,
  975. const cmTarget &target,
  976. const char * /* libName */)
  977. {
  978. if (target.GetType() > cmTarget::UTILITY)
  979. {
  980. return;
  981. }
  982. // add the pre build rules
  983. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"";
  984. bool init = false;
  985. for (std::vector<cmCustomCommand>::const_iterator cr =
  986. target.GetPreBuildCommands().begin();
  987. cr != target.GetPreBuildCommands().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 pre Link rules
  1007. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"";
  1008. init = false;
  1009. for (std::vector<cmCustomCommand>::const_iterator cr =
  1010. target.GetPreLinkCommands().begin();
  1011. cr != target.GetPreLinkCommands().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. // add the PostBuild rules
  1031. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"";
  1032. init = false;
  1033. for (std::vector<cmCustomCommand>::const_iterator cr =
  1034. target.GetPostBuildCommands().begin();
  1035. cr != target.GetPostBuildCommands().end(); ++cr)
  1036. {
  1037. cmCustomCommand cc(*cr);
  1038. cc.ExpandVariables(*m_Makefile);
  1039. if(!init)
  1040. {
  1041. fout << "\nCommandLine=\"";
  1042. init = true;
  1043. }
  1044. std::string args = cc.GetArguments();
  1045. cmSystemTools::ReplaceString(args, "\"", "&quot;");
  1046. fout << this->ConvertToXMLOutputPath(cc.GetCommand().c_str()) << " " <<
  1047. args << "\n";
  1048. }
  1049. if (init)
  1050. {
  1051. fout << "\"";
  1052. }
  1053. fout << "/>\n";
  1054. }
  1055. void
  1056. cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
  1057. const char *libName,
  1058. const cmTarget &,
  1059. std::vector<cmSourceGroup> &)
  1060. {
  1061. fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
  1062. << "<VisualStudioProject\n"
  1063. << "\tProjectType=\"Visual C++\"\n";
  1064. if(m_Version71)
  1065. {
  1066. fout << "\tVersion=\"7.10\"\n";
  1067. }
  1068. else
  1069. {
  1070. fout << "\tVersion=\"7.00\"\n";
  1071. }
  1072. fout << "\tName=\"" << libName << "\"\n"
  1073. << "\tSccProjectName=\"\"\n"
  1074. << "\tSccLocalPath=\"\"\n"
  1075. << "\tKeyword=\"Win32Proj\">\n"
  1076. << "\t<Platforms>\n"
  1077. << "\t\t<Platform\n\t\t\tName=\"Win32\"/>\n"
  1078. << "\t</Platforms>\n";
  1079. }
  1080. void cmLocalVisualStudio7Generator::WriteVCProjFooter(std::ostream& fout)
  1081. {
  1082. fout << "\t<Globals>\n"
  1083. << "\t</Globals>\n"
  1084. << "</VisualStudioProject>\n";
  1085. }
  1086. std::string cmLocalVisualStudio7Generator::EscapeForXML(const char* s)
  1087. {
  1088. std::string ret = s;
  1089. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1090. cmSystemTools::ReplaceString(ret, "\"", "&quot;");
  1091. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1092. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1093. return ret;
  1094. }
  1095. std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPath(const char* path)
  1096. {
  1097. std::string ret = this->ConvertToRelativeOutputPath(path);
  1098. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1099. cmSystemTools::ReplaceString(ret, "\"", "&quot;");
  1100. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1101. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1102. return ret;
  1103. }
  1104. std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPathSingle(const char* path)
  1105. {
  1106. std::string ret = this->ConvertToRelativeOutputPath(path);
  1107. cmSystemTools::ReplaceString(ret, "\"", "");
  1108. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1109. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1110. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1111. return ret;
  1112. }