1
0

cmLocalVisualStudio7Generator.cxx 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmGlobalVisualStudio7Generator.h"
  11. #include "cmLocalVisualStudio7Generator.h"
  12. #include "cmXMLParser.h"
  13. #include <cm_expat.h>
  14. #include "cmMakefile.h"
  15. #include "cmSystemTools.h"
  16. #include "cmSourceFile.h"
  17. #include "cmCacheManager.h"
  18. #include "cmake.h"
  19. #include "cmComputeLinkInformation.h"
  20. #include "cmGeneratedFileStream.h"
  21. #include <cmsys/System.h>
  22. #include <ctype.h> // for isspace
  23. // Package GUID of Intel Visual Fortran plugin to VS IDE
  24. #define CM_INTEL_PLUGIN_GUID "{B68A201D-CB9B-47AF-A52F-7EEC72E217E4}"
  25. static bool cmLVS6G_IsFAT(const char* dir);
  26. class cmLocalVisualStudio7GeneratorInternals
  27. {
  28. public:
  29. cmLocalVisualStudio7GeneratorInternals(cmLocalVisualStudio7Generator* e):
  30. LocalGenerator(e) {}
  31. typedef cmComputeLinkInformation::ItemVector ItemVector;
  32. void OutputLibraries(std::ostream& fout, ItemVector const& libs);
  33. private:
  34. cmLocalVisualStudio7Generator* LocalGenerator;
  35. };
  36. extern cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[];
  37. //----------------------------------------------------------------------------
  38. cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator(VSVersion v):
  39. cmLocalVisualStudioGenerator(v)
  40. {
  41. this->PlatformName = "Win32";
  42. this->ExtraFlagTable = 0;
  43. this->Internal = new cmLocalVisualStudio7GeneratorInternals(this);
  44. }
  45. cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator()
  46. {
  47. delete this->Internal;
  48. }
  49. void cmLocalVisualStudio7Generator::AddHelperCommands()
  50. {
  51. std::set<cmStdString> lang;
  52. lang.insert("C");
  53. lang.insert("CXX");
  54. lang.insert("RC");
  55. lang.insert("IDL");
  56. lang.insert("DEF");
  57. lang.insert("Fortran");
  58. this->CreateCustomTargetsAndCommands(lang);
  59. // Now create GUIDs for targets
  60. cmTargets &tgts = this->Makefile->GetTargets();
  61. cmGlobalVisualStudio7Generator* gg =
  62. static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
  63. for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
  64. {
  65. const char* path = l->second.GetProperty("EXTERNAL_MSPROJECT");
  66. if(path)
  67. {
  68. this->ReadAndStoreExternalGUID(
  69. l->second.GetName(), path);
  70. }
  71. else
  72. {
  73. gg->CreateGUID(l->first.c_str());
  74. }
  75. }
  76. this->FixGlobalTargets();
  77. }
  78. void cmLocalVisualStudio7Generator::Generate()
  79. {
  80. this->WriteProjectFiles();
  81. this->WriteStampFiles();
  82. }
  83. void cmLocalVisualStudio7Generator::FixGlobalTargets()
  84. {
  85. // Visual Studio .NET 2003 Service Pack 1 will not run post-build
  86. // commands for targets in which no sources are built. Add dummy
  87. // rules to force these targets to build.
  88. cmTargets &tgts = this->Makefile->GetTargets();
  89. for(cmTargets::iterator l = tgts.begin();
  90. l != tgts.end(); l++)
  91. {
  92. cmTarget& tgt = l->second;
  93. if(tgt.GetType() == cmTarget::GLOBAL_TARGET)
  94. {
  95. std::vector<std::string> no_depends;
  96. cmCustomCommandLine force_command;
  97. force_command.push_back("cd");
  98. force_command.push_back(".");
  99. cmCustomCommandLines force_commands;
  100. force_commands.push_back(force_command);
  101. const char* no_main_dependency = 0;
  102. std::string force = this->Makefile->GetStartOutputDirectory();
  103. force += cmake::GetCMakeFilesDirectory();
  104. force += "/";
  105. force += tgt.GetName();
  106. force += "_force";
  107. this->Makefile->AddCustomCommandToOutput(force.c_str(), no_depends,
  108. no_main_dependency,
  109. force_commands, " ", 0, true);
  110. if(cmSourceFile* file =
  111. this->Makefile->GetSourceFileWithOutput(force.c_str()))
  112. {
  113. tgt.AddSourceFile(file);
  114. }
  115. }
  116. }
  117. }
  118. // TODO
  119. // for CommandLine= need to repleace quotes with &quot
  120. // write out configurations
  121. void cmLocalVisualStudio7Generator::WriteProjectFiles()
  122. {
  123. // If not an in source build, then create the output directory
  124. if(strcmp(this->Makefile->GetStartOutputDirectory(),
  125. this->Makefile->GetHomeDirectory()) != 0)
  126. {
  127. if(!cmSystemTools::MakeDirectory
  128. (this->Makefile->GetStartOutputDirectory()))
  129. {
  130. cmSystemTools::Error("Error creating directory ",
  131. this->Makefile->GetStartOutputDirectory());
  132. }
  133. }
  134. // Get the set of targets in this directory.
  135. cmTargets &tgts = this->Makefile->GetTargets();
  136. // Create the regeneration custom rule.
  137. if(!this->Makefile->IsOn("CMAKE_SUPPRESS_REGENERATION"))
  138. {
  139. // Create a rule to regenerate the build system when the target
  140. // specification source changes.
  141. if(cmSourceFile* sf = this->CreateVCProjBuildRule())
  142. {
  143. // Add the rule to targets that need it.
  144. for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l)
  145. {
  146. if(l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
  147. {
  148. l->second.AddSourceFile(sf);
  149. }
  150. }
  151. }
  152. }
  153. // Create the project file for each target.
  154. for(cmTargets::iterator l = tgts.begin();
  155. l != tgts.end(); l++)
  156. {
  157. // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
  158. // so don't build a projectfile for it
  159. if(!l->second.GetProperty("EXTERNAL_MSPROJECT"))
  160. {
  161. this->CreateSingleVCProj(l->first.c_str(),l->second);
  162. }
  163. }
  164. }
  165. //----------------------------------------------------------------------------
  166. void cmLocalVisualStudio7Generator::WriteStampFiles()
  167. {
  168. // Touch a timestamp file used to determine when the project file is
  169. // out of date.
  170. std::string stampName = this->Makefile->GetStartOutputDirectory();
  171. stampName += cmake::GetCMakeFilesDirectory();
  172. cmSystemTools::MakeDirectory(stampName.c_str());
  173. stampName += "/";
  174. stampName += "generate.stamp";
  175. std::ofstream stamp(stampName.c_str());
  176. stamp << "# CMake generation timestamp file this directory.\n";
  177. // Create a helper file so CMake can determine when it is run
  178. // through the rule created by CreateVCProjBuildRule whether it
  179. // really needs to regenerate the project. This file lists its own
  180. // dependencies. If any file listed in it is newer than itself then
  181. // CMake must rerun. Otherwise the project files are up to date and
  182. // the stamp file can just be touched.
  183. std::string depName = stampName;
  184. depName += ".depend";
  185. std::ofstream depFile(depName.c_str());
  186. depFile << "# CMake generation dependency list for this directory.\n";
  187. std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();
  188. for(std::vector<std::string>::const_iterator lf = listFiles.begin();
  189. lf != listFiles.end(); ++lf)
  190. {
  191. depFile << *lf << std::endl;
  192. }
  193. }
  194. //----------------------------------------------------------------------------
  195. void cmLocalVisualStudio7Generator
  196. ::CreateSingleVCProj(const char *lname, cmTarget &target)
  197. {
  198. this->FortranProject =
  199. static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
  200. ->TargetIsFortranOnly(target);
  201. // Intel Fortran for VS10 uses VS9 format ".vfproj" files.
  202. VSVersion realVersion = this->Version;
  203. if(this->FortranProject && this->Version >= VS10)
  204. {
  205. this->Version = VS9;
  206. }
  207. // add to the list of projects
  208. std::string pname = lname;
  209. target.SetProperty("GENERATOR_FILE_NAME",lname);
  210. // create the dsp.cmake file
  211. std::string fname;
  212. fname = this->Makefile->GetStartOutputDirectory();
  213. fname += "/";
  214. fname += lname;
  215. if(this->FortranProject)
  216. {
  217. fname += ".vfproj";
  218. }
  219. else
  220. {
  221. fname += ".vcproj";
  222. }
  223. // Generate the project file and replace it atomically with
  224. // copy-if-different. We use a separate timestamp so that the IDE
  225. // does not reload project files unnecessarily.
  226. cmGeneratedFileStream fout(fname.c_str());
  227. fout.SetCopyIfDifferent(true);
  228. this->WriteVCProjFile(fout,lname,target);
  229. if (fout.Close())
  230. {
  231. this->GlobalGenerator->FileReplacedDuringGenerate(fname);
  232. }
  233. this->Version = realVersion;
  234. }
  235. //----------------------------------------------------------------------------
  236. cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
  237. {
  238. std::string stampName = this->Makefile->GetCurrentOutputDirectory();
  239. stampName += "/";
  240. stampName += cmake::GetCMakeFilesDirectoryPostSlash();
  241. stampName += "generate.stamp";
  242. const char* dsprule =
  243. this->Makefile->GetRequiredDefinition("CMAKE_COMMAND");
  244. cmCustomCommandLine commandLine;
  245. commandLine.push_back(dsprule);
  246. std::string makefileIn = this->Makefile->GetStartDirectory();
  247. makefileIn += "/";
  248. makefileIn += "CMakeLists.txt";
  249. makefileIn = cmSystemTools::CollapseFullPath(makefileIn.c_str());
  250. if(!cmSystemTools::FileExists(makefileIn.c_str()))
  251. {
  252. return 0;
  253. }
  254. std::string comment = "Building Custom Rule ";
  255. comment += makefileIn;
  256. std::string args;
  257. args = "-H";
  258. args += this->Convert(this->Makefile->GetHomeDirectory(),
  259. START_OUTPUT, UNCHANGED, true);
  260. commandLine.push_back(args);
  261. args = "-B";
  262. args +=
  263. this->Convert(this->Makefile->GetHomeOutputDirectory(),
  264. START_OUTPUT, UNCHANGED, true);
  265. commandLine.push_back(args);
  266. commandLine.push_back("--check-stamp-file");
  267. std::string stampFilename = this->Convert(stampName.c_str(), FULL,
  268. SHELL);
  269. commandLine.push_back(stampFilename.c_str());
  270. std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();
  271. cmCustomCommandLines commandLines;
  272. commandLines.push_back(commandLine);
  273. const char* no_working_directory = 0;
  274. std::string fullpathStampName = this->Convert(stampName.c_str(), FULL,
  275. UNCHANGED);
  276. this->Makefile->AddCustomCommandToOutput(fullpathStampName.c_str(),
  277. listFiles, makefileIn.c_str(),
  278. commandLines, comment.c_str(),
  279. no_working_directory, true);
  280. if(cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str()))
  281. {
  282. return file;
  283. }
  284. else
  285. {
  286. cmSystemTools::Error("Error adding rule for ", makefileIn.c_str());
  287. return 0;
  288. }
  289. }
  290. void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout,
  291. const char *libName,
  292. cmTarget &target)
  293. {
  294. std::vector<std::string> *configs =
  295. static_cast<cmGlobalVisualStudio7Generator *>
  296. (this->GlobalGenerator)->GetConfigurations();
  297. fout << "\t<Configurations>\n";
  298. for( std::vector<std::string>::iterator i = configs->begin();
  299. i != configs->end(); ++i)
  300. {
  301. this->WriteConfiguration(fout, i->c_str(), libName, target);
  302. }
  303. fout << "\t</Configurations>\n";
  304. }
  305. cmVS7FlagTable cmLocalVisualStudio7GeneratorFortranFlagTable[] =
  306. {
  307. {"Preprocess", "fpp", "Run Preprocessor on files", "preprocessYes", 0},
  308. {"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "true", 0},
  309. {"SourceFileFormat", "fixed", "Use Fixed Format", "fileFormatFixed", 0},
  310. {"SourceFileFormat", "free", "Use Free Format", "fileFormatFree", 0},
  311. {"DebugInformationFormat", "Zi", "full debug", "debugEnabled", 0},
  312. {"DebugInformationFormat", "debug:full", "full debug", "debugEnabled", 0},
  313. {"DebugInformationFormat", "Z7", "c7 compat", "debugOldStyleInfo", 0},
  314. {"DebugInformationFormat", "Zd", "line numbers", "debugLineInfoOnly", 0},
  315. {"Optimization", "Od", "disable optimization", "optimizeDisabled", 0},
  316. {"Optimization", "O1", "min space", "optimizeMinSpace", 0},
  317. {"Optimization", "O3", "full optimize", "optimizeFull", 0},
  318. {"GlobalOptimizations", "Og", "global optimize", "true", 0},
  319. {"InlineFunctionExpansion", "Ob0", "", "expandDisable", 0},
  320. {"InlineFunctionExpansion", "Ob1", "", "expandOnlyInline", 0},
  321. {"FavorSizeOrSpeed", "Os", "", "favorSize", 0},
  322. {"OmitFramePointers", "Oy-", "", "false", 0},
  323. {"OptimizeForProcessor", "GB", "", "procOptimizeBlended", 0},
  324. {"OptimizeForProcessor", "G5", "", "procOptimizePentium", 0},
  325. {"OptimizeForProcessor", "G6", "", "procOptimizePentiumProThruIII", 0},
  326. {"UseProcessorExtensions", "QzxK", "", "codeForStreamingSIMD", 0},
  327. {"OptimizeForProcessor", "QaxN", "", "codeForPentium4", 0},
  328. {"OptimizeForProcessor", "QaxB", "", "codeForPentiumM", 0},
  329. {"OptimizeForProcessor", "QaxP", "", "codeForCodeNamedPrescott", 0},
  330. {"OptimizeForProcessor", "QaxT", "", "codeForCore2Duo", 0},
  331. {"OptimizeForProcessor", "QxK", "", "codeExclusivelyStreamingSIMD", 0},
  332. {"OptimizeForProcessor", "QxN", "", "codeExclusivelyPentium4", 0},
  333. {"OptimizeForProcessor", "QxB", "", "codeExclusivelyPentiumM", 0},
  334. {"OptimizeForProcessor", "QxP", "", "codeExclusivelyCodeNamedPrescott", 0},
  335. {"OptimizeForProcessor", "QxT", "", "codeExclusivelyCore2Duo", 0},
  336. {"OptimizeForProcessor", "QxO", "", "codeExclusivelyCore2StreamingSIMD", 0},
  337. {"OptimizeForProcessor", "QxS", "", "codeExclusivelyCore2StreamingSIMD4", 0},
  338. {"ModulePath", "module:", "", "",
  339. cmVS7FlagTable::UserValueRequired},
  340. {"LoopUnrolling", "Qunroll:", "", "",
  341. cmVS7FlagTable::UserValueRequired},
  342. {"AutoParallelThreshold", "Qpar-threshold:", "", "",
  343. cmVS7FlagTable::UserValueRequired},
  344. {"HeapArrays", "heap-arrays:", "", "",
  345. cmVS7FlagTable::UserValueRequired},
  346. {"ObjectText", "bintext:", "", "",
  347. cmVS7FlagTable::UserValueRequired},
  348. {"Parallelization", "Qparallel", "", "true", 0},
  349. {"PrefetchInsertion", "Qprefetch-", "", "false", 0},
  350. {"BufferedIO", "assume:buffered_io", "", "true", 0},
  351. {"CallingConvention", "iface:stdcall", "", "callConventionStdCall", 0},
  352. {"CallingConvention", "iface:cref", "", "callConventionCRef", 0},
  353. {"CallingConvention", "iface:stdref", "", "callConventionStdRef", 0},
  354. {"CallingConvention", "iface:stdcall", "", "callConventionStdCall", 0},
  355. {"CallingConvention", "iface:cvf", "", "callConventionCVF", 0},
  356. {"EnableRecursion", "recursive", "", "true", 0},
  357. {"ReentrantCode", "reentrancy", "", "true", 0},
  358. // done up to Language
  359. {0,0,0,0,0}
  360. };
  361. // fill the table here currently the comment field is not used for
  362. // anything other than documentation NOTE: Make sure the longer
  363. // commandFlag comes FIRST!
  364. cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] =
  365. {
  366. // option flags (some flags map to the same option)
  367. {"BasicRuntimeChecks", "GZ", "Stack frame checks", "1", 0},
  368. {"BasicRuntimeChecks", "RTCsu",
  369. "Both stack and uninitialized checks", "3", 0},
  370. {"BasicRuntimeChecks", "RTCs", "Stack frame checks", "1", 0},
  371. {"BasicRuntimeChecks", "RTCu", "Uninitialized Variables ", "2", 0},
  372. {"BasicRuntimeChecks", "RTC1",
  373. "Both stack and uninitialized checks", "3", 0},
  374. {"DebugInformationFormat", "Z7", "debug format", "1", 0},
  375. {"DebugInformationFormat", "Zd", "debug format", "2", 0},
  376. {"DebugInformationFormat", "Zi", "debug format", "3", 0},
  377. {"DebugInformationFormat", "ZI", "debug format", "4", 0},
  378. {"EnableEnhancedInstructionSet", "arch:SSE2",
  379. "Use sse2 instructions", "2", 0},
  380. {"EnableEnhancedInstructionSet", "arch:SSE",
  381. "Use sse instructions", "1", 0},
  382. {"FloatingPointModel", "fp:precise",
  383. "Use precise floating point model", "0", 0},
  384. {"FloatingPointModel", "fp:strict",
  385. "Use strict floating point model", "1", 0},
  386. {"FloatingPointModel", "fp:fast", "Use fast floating point model", "2", 0},
  387. {"FavorSizeOrSpeed", "Ot", "Favor fast code", "1", 0},
  388. {"FavorSizeOrSpeed", "Os", "Favor small code", "2", 0},
  389. {"CompileAs", "TC", "Compile as c code", "1", 0},
  390. {"CompileAs", "TP", "Compile as c++ code", "2", 0},
  391. {"Optimization", "Od", "Non Debug", "0", 0},
  392. {"Optimization", "O1", "Min Size", "1", 0},
  393. {"Optimization", "O2", "Max Speed", "2", 0},
  394. {"Optimization", "Ox", "Max Optimization", "3", 0},
  395. {"OptimizeForProcessor", "GB", "Blended processor mode", "0", 0},
  396. {"OptimizeForProcessor", "G5", "Pentium", "1", 0},
  397. {"OptimizeForProcessor", "G6", "PPro PII PIII", "2", 0},
  398. {"OptimizeForProcessor", "G7", "Pentium 4 or Athlon", "3", 0},
  399. {"InlineFunctionExpansion", "Ob0", "no inlines", "0", 0},
  400. {"InlineFunctionExpansion", "Ob1", "when inline keyword", "1", 0},
  401. {"InlineFunctionExpansion", "Ob2", "any time you can inline", "2", 0},
  402. {"RuntimeLibrary", "MTd", "Multithreded debug", "1", 0},
  403. {"RuntimeLibrary", "MT", "Multithreded", "0", 0},
  404. {"RuntimeLibrary", "MDd", "Multithreded dll debug", "3", 0},
  405. {"RuntimeLibrary", "MD", "Multithreded dll", "2", 0},
  406. {"RuntimeLibrary", "MLd", "Sinble Thread debug", "5", 0},
  407. {"RuntimeLibrary", "ML", "Sinble Thread", "4", 0},
  408. {"StructMemberAlignment", "Zp16", "struct align 16 byte ", "5", 0},
  409. {"StructMemberAlignment", "Zp1", "struct align 1 byte ", "1", 0},
  410. {"StructMemberAlignment", "Zp2", "struct align 2 byte ", "2", 0},
  411. {"StructMemberAlignment", "Zp4", "struct align 4 byte ", "3", 0},
  412. {"StructMemberAlignment", "Zp8", "struct align 8 byte ", "4", 0},
  413. {"WarningLevel", "W0", "Warning level", "0", 0},
  414. {"WarningLevel", "W1", "Warning level", "1", 0},
  415. {"WarningLevel", "W2", "Warning level", "2", 0},
  416. {"WarningLevel", "W3", "Warning level", "3", 0},
  417. {"WarningLevel", "W4", "Warning level", "4", 0},
  418. {"DisableSpecificWarnings", "wd", "Disable specific warnings", "",
  419. cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
  420. // Precompiled header and related options. Note that the
  421. // UsePrecompiledHeader entries are marked as "Continue" so that the
  422. // corresponding PrecompiledHeaderThrough entry can be found.
  423. {"UsePrecompiledHeader", "Yc", "Create Precompiled Header", "1",
  424. cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
  425. {"PrecompiledHeaderThrough", "Yc", "Precompiled Header Name", "",
  426. cmVS7FlagTable::UserValueRequired},
  427. {"PrecompiledHeaderFile", "Fp", "Generated Precompiled Header", "",
  428. cmVS7FlagTable::UserValue},
  429. // The YX and Yu options are in a per-global-generator table because
  430. // their values differ based on the VS IDE version.
  431. {"ForcedIncludeFiles", "FI", "Forced include files", "",
  432. cmVS7FlagTable::UserValueRequired | cmVS7FlagTable::SemicolonAppendable},
  433. // boolean flags
  434. {"BufferSecurityCheck", "GS", "Buffer security check", "TRUE", 0},
  435. {"BufferSecurityCheck", "GS-", "Turn off Buffer security check", "FALSE", 0},
  436. {"Detect64BitPortabilityProblems", "Wp64",
  437. "Detect 64-bit Portability Problems", "TRUE", 0},
  438. {"EnableFiberSafeOptimizations", "GT", "Enable Fiber-safe Optimizations",
  439. "TRUE", 0},
  440. {"EnableFunctionLevelLinking", "Gy",
  441. "EnableFunctionLevelLinking", "TRUE", 0},
  442. {"EnableIntrinsicFunctions", "Oi", "EnableIntrinsicFunctions", "TRUE", 0},
  443. {"GlobalOptimizations", "Og", "Global Optimize", "TRUE", 0},
  444. {"ImproveFloatingPointConsistency", "Op",
  445. "ImproveFloatingPointConsistency", "TRUE", 0},
  446. {"MinimalRebuild", "Gm", "minimal rebuild", "TRUE", 0},
  447. {"OmitFramePointers", "Oy", "OmitFramePointers", "TRUE", 0},
  448. {"OptimizeForWindowsApplication", "GA", "Optimize for windows", "TRUE", 0},
  449. {"RuntimeTypeInfo", "GR",
  450. "Turn on Run time type information for c++", "TRUE", 0},
  451. {"RuntimeTypeInfo", "GR-",
  452. "Turn off Run time type information for c++", "FALSE", 0},
  453. {"SmallerTypeCheck", "RTCc", "smaller type check", "TRUE", 0},
  454. {"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "TRUE", 0},
  455. {"WholeProgramOptimization", "GL",
  456. "Enables whole program optimization", "TRUE", 0},
  457. {"WholeProgramOptimization", "GL-",
  458. "Disables whole program optimization", "FALSE", 0},
  459. {"WarnAsError", "WX", "Treat warnings as errors", "TRUE", 0},
  460. {"BrowseInformation", "FR", "Generate browse information", "1", 0},
  461. {"StringPooling", "GF", "Enable StringPooling", "TRUE", 0},
  462. {0,0,0,0,0}
  463. };
  464. cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] =
  465. {
  466. // option flags (some flags map to the same option)
  467. {"GenerateManifest", "MANIFEST:NO",
  468. "disable manifest generation", "FALSE", 0},
  469. {"GenerateManifest", "MANIFEST", "enable manifest generation", "TRUE", 0},
  470. {"LinkIncremental", "INCREMENTAL:NO", "link incremental", "1", 0},
  471. {"LinkIncremental", "INCREMENTAL:YES", "link incremental", "2", 0},
  472. {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0},
  473. {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0},
  474. {"DataExecutionPrevention", "NXCOMPAT:NO",
  475. "Not known to work with Windows Data Execution Prevention", "1", 0},
  476. {"DataExecutionPrevention", "NXCOMPAT",
  477. "Known to work with Windows Data Execution Prevention", "2", 0},
  478. {"DelaySign", "DELAYSIGN:NO", "", "false", 0},
  479. {"DelaySign", "DELAYSIGN", "", "true", 0},
  480. {"EntryPointSymbol", "ENTRY:", "sets the starting address", "",
  481. cmVS7FlagTable::UserValue},
  482. {"IgnoreDefaultLibraryNames", "NODEFAULTLIB:", "default libs to ignore", "",
  483. cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
  484. {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "ignore all default libs",
  485. "TRUE", 0},
  486. {"FixedBaseAddress", "FIXED:NO", "Generate a relocation section", "1", 0},
  487. {"FixedBaseAddress", "FIXED", "Image must be loaded at a fixed address",
  488. "2", 0},
  489. {"EnableCOMDATFolding", "OPT:NOICF", "Do not remove redundant COMDATs",
  490. "1", 0},
  491. {"EnableCOMDATFolding", "OPT:ICF", "Remove redundant COMDATs", "2", 0},
  492. {"ResourceOnlyDLL", "NOENTRY", "Create DLL with no entry point", "true", 0},
  493. {"OptimizeReferences", "OPT:NOREF", "Keep unreferenced data", "1", 0},
  494. {"OptimizeReferences", "OPT:REF", "Eliminate unreferenced data", "2", 0},
  495. {"Profile", "PROFILE", "", "true", 0},
  496. {"RandomizedBaseAddress", "DYNAMICBASE:NO",
  497. "Image may not be rebased at load-time", "1", 0},
  498. {"RandomizedBaseAddress", "DYNAMICBASE",
  499. "Image may be rebased at load-time", "2", 0},
  500. {"SetChecksum", "RELEASE", "Enable setting checksum in header", "true", 0},
  501. {"SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0},
  502. {"TargetMachine", "MACHINE:I386", "Machine x86", "1", 0},
  503. {"TargetMachine", "MACHINE:X86", "Machine x86", "1", 0},
  504. {"TargetMachine", "MACHINE:AM33", "Machine AM33", "2", 0},
  505. {"TargetMachine", "MACHINE:ARM", "Machine ARM", "3", 0},
  506. {"TargetMachine", "MACHINE:EBC", "Machine EBC", "4", 0},
  507. {"TargetMachine", "MACHINE:IA64", "Machine IA64", "5", 0},
  508. {"TargetMachine", "MACHINE:M32R", "Machine M32R", "6", 0},
  509. {"TargetMachine", "MACHINE:MIPS", "Machine MIPS", "7", 0},
  510. {"TargetMachine", "MACHINE:MIPS16", "Machine MIPS16", "8", 0},
  511. {"TargetMachine", "MACHINE:MIPSFPU)", "Machine MIPSFPU", "9", 0},
  512. {"TargetMachine", "MACHINE:MIPSFPU16", "Machine MIPSFPU16", "10", 0},
  513. {"TargetMachine", "MACHINE:MIPSR41XX", "Machine MIPSR41XX", "11", 0},
  514. {"TargetMachine", "MACHINE:SH3", "Machine SH3", "12", 0},
  515. {"TargetMachine", "MACHINE:SH3DSP", "Machine SH3DSP", "13", 0},
  516. {"TargetMachine", "MACHINE:SH4", "Machine SH4", "14", 0},
  517. {"TargetMachine", "MACHINE:SH5", "Machine SH5", "15", 0},
  518. {"TargetMachine", "MACHINE:THUMB", "Machine THUMB", "16", 0},
  519. {"TargetMachine", "MACHINE:X64", "Machine x64", "17", 0},
  520. {"TurnOffAssemblyGeneration", "NOASSEMBLY",
  521. "No assembly even if CLR information is present in objects.", "true", 0},
  522. {"ModuleDefinitionFile", "DEF:", "add an export def file", "",
  523. cmVS7FlagTable::UserValue},
  524. {"GenerateMapFile", "MAP", "enable generation of map file", "TRUE", 0},
  525. {0,0,0,0,0}
  526. };
  527. //----------------------------------------------------------------------------
  528. // Helper class to write build event <Tool .../> elements.
  529. class cmLocalVisualStudio7Generator::EventWriter
  530. {
  531. public:
  532. EventWriter(cmLocalVisualStudio7Generator* lg,
  533. const char* config, std::ostream& os):
  534. LG(lg), Config(config), Stream(os), First(true) {}
  535. void Start(const char* tool)
  536. {
  537. this->First = true;
  538. this->Stream << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"";
  539. }
  540. void Finish()
  541. {
  542. this->Stream << (this->First? "" : "\"") << "/>\n";
  543. }
  544. void Write(std::vector<cmCustomCommand> const& ccs)
  545. {
  546. for(std::vector<cmCustomCommand>::const_iterator ci = ccs.begin();
  547. ci != ccs.end(); ++ci)
  548. {
  549. this->Write(*ci);
  550. }
  551. }
  552. void Write(cmCustomCommand const& cc)
  553. {
  554. if(this->First)
  555. {
  556. const char* comment = cc.GetComment();
  557. if(comment && *comment)
  558. {
  559. this->Stream << "\nDescription=\""
  560. << this->LG->EscapeForXML(comment) << "\"";
  561. }
  562. this->Stream << "\nCommandLine=\"";
  563. this->First = false;
  564. }
  565. else
  566. {
  567. this->Stream << this->LG->EscapeForXML("\n");
  568. }
  569. std::string script = this->LG->ConstructScript(cc, this->Config);
  570. this->Stream << this->LG->EscapeForXML(script.c_str());
  571. }
  572. private:
  573. cmLocalVisualStudio7Generator* LG;
  574. const char* Config;
  575. std::ostream& Stream;
  576. bool First;
  577. };
  578. //----------------------------------------------------------------------------
  579. void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
  580. const char* configName,
  581. const char *libName,
  582. cmTarget &target)
  583. {
  584. const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG");
  585. if(!mfcFlag)
  586. {
  587. mfcFlag = "0";
  588. }
  589. fout << "\t\t<Configuration\n"
  590. << "\t\t\tName=\"" << configName << "|" << this->PlatformName << "\"\n"
  591. << "\t\t\tOutputDirectory=\"" << configName << "\"\n";
  592. // This is an internal type to Visual Studio, it seems that:
  593. // 4 == static library
  594. // 2 == dll
  595. // 1 == executable
  596. // 10 == utility
  597. const char* configType = "10";
  598. const char* projectType = 0;
  599. bool targetBuilds = true;
  600. switch(target.GetType())
  601. {
  602. case cmTarget::STATIC_LIBRARY:
  603. projectType = "typeStaticLibrary";
  604. configType = "4";
  605. break;
  606. case cmTarget::SHARED_LIBRARY:
  607. case cmTarget::MODULE_LIBRARY:
  608. projectType = "typeDynamicLibrary";
  609. configType = "2";
  610. break;
  611. case cmTarget::EXECUTABLE:
  612. configType = "1";
  613. break;
  614. case cmTarget::UTILITY:
  615. case cmTarget::GLOBAL_TARGET:
  616. configType = "10";
  617. default:
  618. targetBuilds = false;
  619. break;
  620. }
  621. if(this->FortranProject && projectType)
  622. {
  623. configType = projectType;
  624. }
  625. std::string flags;
  626. if(strcmp(configType, "10") != 0)
  627. {
  628. const char* linkLanguage = (this->FortranProject? "Fortran":
  629. target.GetLinkerLanguage(configName));
  630. if(!linkLanguage)
  631. {
  632. cmSystemTools::Error
  633. ("CMake can not determine linker language for target:",
  634. target.GetName());
  635. return;
  636. }
  637. if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0
  638. || strcmp(linkLanguage, "Fortran") == 0)
  639. {
  640. std::string baseFlagVar = "CMAKE_";
  641. baseFlagVar += linkLanguage;
  642. baseFlagVar += "_FLAGS";
  643. flags = this->Makefile->GetRequiredDefinition(baseFlagVar.c_str());
  644. std::string flagVar = baseFlagVar + std::string("_") +
  645. cmSystemTools::UpperCase(configName);
  646. flags += " ";
  647. flags += this->Makefile->GetRequiredDefinition(flagVar.c_str());
  648. }
  649. // set the correct language
  650. if(strcmp(linkLanguage, "C") == 0)
  651. {
  652. flags += " /TC ";
  653. }
  654. if(strcmp(linkLanguage, "CXX") == 0)
  655. {
  656. flags += " /TP ";
  657. }
  658. }
  659. if(this->FortranProject)
  660. {
  661. switch(this->GetFortranFormat(target.GetProperty("Fortran_FORMAT")))
  662. {
  663. case FortranFormatFixed: flags += " -fixed"; break;
  664. case FortranFormatFree: flags += " -free"; break;
  665. default: break;
  666. }
  667. }
  668. // Add the target-specific flags.
  669. if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
  670. {
  671. flags += " ";
  672. flags += targetFlags;
  673. }
  674. std::string configUpper = cmSystemTools::UpperCase(configName);
  675. std::string defPropName = "COMPILE_DEFINITIONS_";
  676. defPropName += configUpper;
  677. // Get preprocessor definitions for this directory.
  678. std::string defineFlags = this->Makefile->GetDefineFlags();
  679. Options::Tool t = Options::Compiler;
  680. cmVS7FlagTable const* table = cmLocalVisualStudio7GeneratorFlagTable;
  681. if(this->FortranProject)
  682. {
  683. t = Options::FortranCompiler;
  684. table = cmLocalVisualStudio7GeneratorFortranFlagTable;
  685. }
  686. Options targetOptions(this, t,
  687. table,
  688. this->ExtraFlagTable);
  689. targetOptions.FixExceptionHandlingDefault();
  690. targetOptions.Parse(flags.c_str());
  691. targetOptions.Parse(defineFlags.c_str());
  692. targetOptions.ParseFinish();
  693. targetOptions.AddDefines
  694. (this->Makefile->GetProperty("COMPILE_DEFINITIONS"));
  695. targetOptions.AddDefines(target.GetProperty("COMPILE_DEFINITIONS"));
  696. targetOptions.AddDefines(this->Makefile->GetProperty(defPropName.c_str()));
  697. targetOptions.AddDefines(target.GetProperty(defPropName.c_str()));
  698. targetOptions.SetVerboseMakefile(
  699. this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
  700. // Add a definition for the configuration name.
  701. std::string configDefine = "CMAKE_INTDIR=\"";
  702. configDefine += configName;
  703. configDefine += "\"";
  704. targetOptions.AddDefine(configDefine);
  705. // Add the export symbol definition for shared library objects.
  706. if(const char* exportMacro = target.GetExportMacro())
  707. {
  708. targetOptions.AddDefine(exportMacro);
  709. }
  710. // The intermediate directory name consists of a directory for the
  711. // target and a subdirectory for the configuration name.
  712. std::string intermediateDir = this->GetTargetDirectory(target);
  713. intermediateDir += "/";
  714. intermediateDir += configName;
  715. fout << "\t\t\tIntermediateDirectory=\""
  716. << this->ConvertToXMLOutputPath(intermediateDir.c_str())
  717. << "\"\n"
  718. << "\t\t\tConfigurationType=\"" << configType << "\"\n"
  719. << "\t\t\tUseOfMFC=\"" << mfcFlag << "\"\n"
  720. << "\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n";
  721. // If unicode is enabled change the character set to unicode, if not
  722. // then default to MBCS.
  723. if(targetOptions.UsingUnicode())
  724. {
  725. fout << "\t\t\tCharacterSet=\"1\">\n";
  726. }
  727. else if(targetOptions.UsingSBCS())
  728. {
  729. fout << "\t\t\tCharacterSet=\"0\">\n";
  730. }
  731. else
  732. {
  733. fout << "\t\t\tCharacterSet=\"2\">\n";
  734. }
  735. const char* tool = "VCCLCompilerTool";
  736. if(this->FortranProject)
  737. {
  738. tool = "VFFortranCompilerTool";
  739. }
  740. fout << "\t\t\t<Tool\n"
  741. << "\t\t\t\tName=\"" << tool << "\"\n";
  742. if(this->FortranProject)
  743. {
  744. const char* target_mod_dir =
  745. target.GetProperty("Fortran_MODULE_DIRECTORY");
  746. std::string modDir;
  747. if(target_mod_dir)
  748. {
  749. modDir = this->Convert(target_mod_dir,
  750. cmLocalGenerator::START_OUTPUT,
  751. cmLocalGenerator::UNCHANGED);
  752. }
  753. else
  754. {
  755. modDir = ".";
  756. }
  757. fout << "\t\t\t\tModulePath=\""
  758. << this->ConvertToXMLOutputPath(modDir.c_str())
  759. << "\\$(ConfigurationName)\"\n";
  760. }
  761. targetOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
  762. fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
  763. std::vector<std::string> includes;
  764. this->GetIncludeDirectories(includes, &target);
  765. std::vector<std::string>::iterator i = includes.begin();
  766. for(;i != includes.end(); ++i)
  767. {
  768. // output the include path
  769. std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
  770. fout << ipath << ";";
  771. // if this is fortran then output the include with
  772. // a ConfigurationName on the end of it.
  773. if(this->FortranProject)
  774. {
  775. ipath = i->c_str();
  776. ipath += "/$(ConfigurationName)";
  777. ipath = this->ConvertToXMLOutputPath(ipath.c_str());
  778. fout << ipath << ";";
  779. }
  780. }
  781. fout << "\"\n";
  782. targetOptions.OutputFlagMap(fout, "\t\t\t\t");
  783. targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX");
  784. fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n";
  785. fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
  786. if(targetBuilds)
  787. {
  788. // We need to specify a program database file name even for
  789. // non-debug configurations because VS still creates .idb files.
  790. fout << "\t\t\t\tProgramDataBaseFileName=\""
  791. << this->ConvertToXMLOutputPathSingle(
  792. target.GetDirectory(configName).c_str())
  793. << "/"
  794. << target.GetPDBName(configName) << "\"\n";
  795. }
  796. fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
  797. tool = "VCCustomBuildTool";
  798. if(this->FortranProject)
  799. {
  800. tool = "VFCustomBuildTool";
  801. }
  802. fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"/>\n";
  803. tool = "VCResourceCompilerTool";
  804. if(this->FortranProject)
  805. {
  806. tool = "VFResourceCompilerTool";
  807. }
  808. fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"
  809. << "\t\t\t\tAdditionalIncludeDirectories=\"";
  810. for(i = includes.begin();i != includes.end(); ++i)
  811. {
  812. std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
  813. fout << ipath << ";";
  814. }
  815. // add the -D flags to the RC tool
  816. fout << "\"";
  817. targetOptions.OutputPreprocessorDefinitions(fout, "\n\t\t\t\t", "", "RC");
  818. fout << "/>\n";
  819. tool = "VCMIDLTool";
  820. if(this->FortranProject)
  821. {
  822. tool = "VFMIDLTool";
  823. }
  824. fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n";
  825. fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
  826. for(i = includes.begin(); i != includes.end(); ++i)
  827. {
  828. std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
  829. fout << ipath << ";";
  830. }
  831. fout << "\"\n";
  832. fout << "\t\t\t\tMkTypLibCompatible=\"FALSE\"\n";
  833. if( this->PlatformName == "x64" )
  834. {
  835. fout << "\t\t\t\tTargetEnvironment=\"3\"\n";
  836. }
  837. else if( this->PlatformName == "ia64" )
  838. {
  839. fout << "\t\t\t\tTargetEnvironment=\"2\"\n";
  840. }
  841. else
  842. {
  843. fout << "\t\t\t\tTargetEnvironment=\"1\"\n";
  844. }
  845. fout << "\t\t\t\tGenerateStublessProxies=\"TRUE\"\n";
  846. fout << "\t\t\t\tTypeLibraryName=\"$(InputName).tlb\"\n";
  847. fout << "\t\t\t\tOutputDirectory=\"$(IntDir)\"\n";
  848. fout << "\t\t\t\tHeaderFileName=\"$(InputName).h\"\n";
  849. fout << "\t\t\t\tDLLDataFileName=\"\"\n";
  850. fout << "\t\t\t\tInterfaceIdentifierFileName=\"$(InputName)_i.c\"\n";
  851. fout << "\t\t\t\tProxyFileName=\"$(InputName)_p.c\"/>\n";
  852. // end of <Tool Name=VCMIDLTool
  853. // Check if we need the FAT32 workaround.
  854. if(targetBuilds && this->Version >= VS8)
  855. {
  856. // Check the filesystem type where the target will be written.
  857. if(cmLVS6G_IsFAT(target.GetDirectory(configName).c_str()))
  858. {
  859. // Add a flag telling the manifest tool to use a workaround
  860. // for FAT32 file systems, which can cause an empty manifest
  861. // to be embedded into the resulting executable. See CMake
  862. // bug #2617.
  863. const char* tool = "VCManifestTool";
  864. if(this->FortranProject)
  865. {
  866. tool = "VFManifestTool";
  867. }
  868. fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"
  869. << "\t\t\t\tUseFAT32Workaround=\"true\"\n"
  870. << "\t\t\t/>\n";
  871. }
  872. }
  873. this->OutputTargetRules(fout, configName, target, libName);
  874. this->OutputBuildTool(fout, configName, target, targetOptions.IsDebug());
  875. fout << "\t\t</Configuration>\n";
  876. }
  877. //----------------------------------------------------------------------------
  878. std::string
  879. cmLocalVisualStudio7Generator
  880. ::GetBuildTypeLinkerFlags(std::string rootLinkerFlags, const char* configName)
  881. {
  882. std::string configTypeUpper = cmSystemTools::UpperCase(configName);
  883. std::string extraLinkOptionsBuildTypeDef =
  884. rootLinkerFlags + "_" + configTypeUpper;
  885. std::string extraLinkOptionsBuildType =
  886. this->Makefile->GetRequiredDefinition
  887. (extraLinkOptionsBuildTypeDef.c_str());
  888. return extraLinkOptionsBuildType;
  889. }
  890. void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
  891. const char* configName,
  892. cmTarget &target,
  893. bool isDebug)
  894. {
  895. cmGlobalVisualStudio7Generator* gg =
  896. static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
  897. std::string temp;
  898. std::string extraLinkOptions;
  899. if(target.GetType() == cmTarget::EXECUTABLE)
  900. {
  901. extraLinkOptions =
  902. this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS")
  903. + std::string(" ")
  904. + GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName);
  905. }
  906. if(target.GetType() == cmTarget::SHARED_LIBRARY)
  907. {
  908. extraLinkOptions =
  909. this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS")
  910. + std::string(" ")
  911. + GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName);
  912. }
  913. if(target.GetType() == cmTarget::MODULE_LIBRARY)
  914. {
  915. extraLinkOptions =
  916. this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS")
  917. + std::string(" ")
  918. + GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName);
  919. }
  920. const char* targetLinkFlags = target.GetProperty("LINK_FLAGS");
  921. if(targetLinkFlags)
  922. {
  923. extraLinkOptions += " ";
  924. extraLinkOptions += targetLinkFlags;
  925. }
  926. std::string configTypeUpper = cmSystemTools::UpperCase(configName);
  927. std::string linkFlagsConfig = "LINK_FLAGS_";
  928. linkFlagsConfig += configTypeUpper;
  929. targetLinkFlags = target.GetProperty(linkFlagsConfig.c_str());
  930. if(targetLinkFlags)
  931. {
  932. extraLinkOptions += " ";
  933. extraLinkOptions += targetLinkFlags;
  934. }
  935. Options linkOptions(this, Options::Linker,
  936. cmLocalVisualStudio7GeneratorLinkFlagTable);
  937. linkOptions.Parse(extraLinkOptions.c_str());
  938. if(!this->ModuleDefinitionFile.empty())
  939. {
  940. std::string defFile =
  941. this->ConvertToXMLOutputPath(this->ModuleDefinitionFile.c_str());
  942. linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str());
  943. }
  944. switch(target.GetType())
  945. {
  946. case cmTarget::STATIC_LIBRARY:
  947. {
  948. std::string targetNameFull = target.GetFullName(configName);
  949. std::string libpath = target.GetDirectory(configName);
  950. libpath += "/";
  951. libpath += targetNameFull;
  952. const char* tool = "VCLibrarianTool";
  953. if(this->FortranProject)
  954. {
  955. tool = "VFLibrarianTool";
  956. }
  957. fout << "\t\t\t<Tool\n"
  958. << "\t\t\t\tName=\"" << tool << "\"\n";
  959. std::string libflags;
  960. if(const char* flags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
  961. {
  962. libflags += flags;
  963. }
  964. std::string libFlagsConfig = "STATIC_LIBRARY_FLAGS_";
  965. libFlagsConfig += configTypeUpper;
  966. if(const char* flagsConfig = target.GetProperty(libFlagsConfig.c_str()))
  967. {
  968. libflags += " ";
  969. libflags += flagsConfig;
  970. }
  971. if(!libflags.empty())
  972. {
  973. fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
  974. }
  975. fout << "\t\t\t\tOutputFile=\""
  976. << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << "\"/>\n";
  977. break;
  978. }
  979. case cmTarget::SHARED_LIBRARY:
  980. case cmTarget::MODULE_LIBRARY:
  981. {
  982. std::string targetName;
  983. std::string targetNameSO;
  984. std::string targetNameFull;
  985. std::string targetNameImport;
  986. std::string targetNamePDB;
  987. target.GetLibraryNames(targetName, targetNameSO, targetNameFull,
  988. targetNameImport, targetNamePDB, configName);
  989. // Compute the link library and directory information.
  990. cmComputeLinkInformation* pcli = target.GetLinkInformation(configName);
  991. if(!pcli)
  992. {
  993. return;
  994. }
  995. cmComputeLinkInformation& cli = *pcli;
  996. const char* linkLanguage = cli.GetLinkLanguage();
  997. // Compute the variable name to lookup standard libraries for this
  998. // language.
  999. std::string standardLibsVar = "CMAKE_";
  1000. standardLibsVar += linkLanguage;
  1001. standardLibsVar += "_STANDARD_LIBRARIES";
  1002. const char* tool = "VCLinkerTool";
  1003. if(this->FortranProject)
  1004. {
  1005. tool = "VFLinkerTool";
  1006. }
  1007. fout << "\t\t\t<Tool\n"
  1008. << "\t\t\t\tName=\"" << tool << "\"\n";
  1009. if(!gg->NeedLinkLibraryDependencies(target))
  1010. {
  1011. fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
  1012. }
  1013. linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
  1014. // Use the NOINHERIT macro to avoid getting VS project default
  1015. // libraries which may be set by the user to something bad.
  1016. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
  1017. << this->Makefile->GetSafeDefinition(standardLibsVar.c_str())
  1018. << " ";
  1019. this->Internal->OutputLibraries(fout, cli.GetItems());
  1020. fout << "\"\n";
  1021. temp = target.GetDirectory(configName);
  1022. temp += "/";
  1023. temp += targetNameFull;
  1024. fout << "\t\t\t\tOutputFile=\""
  1025. << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  1026. this->WriteTargetVersionAttribute(fout, target);
  1027. linkOptions.OutputFlagMap(fout, "\t\t\t\t");
  1028. fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
  1029. this->OutputLibraryDirectories(fout, cli.GetDirectories());
  1030. fout << "\"\n";
  1031. temp = target.GetDirectory(configName);
  1032. temp += "/";
  1033. temp += targetNamePDB;
  1034. fout << "\t\t\t\tProgramDatabaseFile=\"" <<
  1035. this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  1036. if(isDebug)
  1037. {
  1038. fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
  1039. }
  1040. std::string stackVar = "CMAKE_";
  1041. stackVar += linkLanguage;
  1042. stackVar += "_STACK_SIZE";
  1043. const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
  1044. if(stackVal)
  1045. {
  1046. fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n";
  1047. }
  1048. temp = target.GetDirectory(configName, true);
  1049. temp += "/";
  1050. temp += targetNameImport;
  1051. fout << "\t\t\t\tImportLibrary=\""
  1052. << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"";
  1053. if(this->FortranProject)
  1054. {
  1055. fout << "\n\t\t\t\tLinkDLL=\"true\"";
  1056. }
  1057. fout << "/>\n";
  1058. }
  1059. break;
  1060. case cmTarget::EXECUTABLE:
  1061. {
  1062. std::string targetName;
  1063. std::string targetNameFull;
  1064. std::string targetNameImport;
  1065. std::string targetNamePDB;
  1066. target.GetExecutableNames(targetName, targetNameFull,
  1067. targetNameImport, targetNamePDB, configName);
  1068. // Compute the link library and directory information.
  1069. cmComputeLinkInformation* pcli = target.GetLinkInformation(configName);
  1070. if(!pcli)
  1071. {
  1072. return;
  1073. }
  1074. cmComputeLinkInformation& cli = *pcli;
  1075. const char* linkLanguage = cli.GetLinkLanguage();
  1076. // Compute the variable name to lookup standard libraries for this
  1077. // language.
  1078. std::string standardLibsVar = "CMAKE_";
  1079. standardLibsVar += linkLanguage;
  1080. standardLibsVar += "_STANDARD_LIBRARIES";
  1081. const char* tool = "VCLinkerTool";
  1082. if(this->FortranProject)
  1083. {
  1084. tool = "VFLinkerTool";
  1085. }
  1086. fout << "\t\t\t<Tool\n"
  1087. << "\t\t\t\tName=\"" << tool << "\"\n";
  1088. if(!gg->NeedLinkLibraryDependencies(target))
  1089. {
  1090. fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
  1091. }
  1092. linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
  1093. // Use the NOINHERIT macro to avoid getting VS project default
  1094. // libraries which may be set by the user to something bad.
  1095. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
  1096. << this->Makefile->GetSafeDefinition(standardLibsVar.c_str())
  1097. << " ";
  1098. this->Internal->OutputLibraries(fout, cli.GetItems());
  1099. fout << "\"\n";
  1100. temp = target.GetDirectory(configName);
  1101. temp += "/";
  1102. temp += targetNameFull;
  1103. fout << "\t\t\t\tOutputFile=\""
  1104. << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  1105. this->WriteTargetVersionAttribute(fout, target);
  1106. linkOptions.OutputFlagMap(fout, "\t\t\t\t");
  1107. fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
  1108. this->OutputLibraryDirectories(fout, cli.GetDirectories());
  1109. fout << "\"\n";
  1110. std::string path = this->ConvertToXMLOutputPathSingle(
  1111. target.GetDirectory(configName).c_str());
  1112. fout << "\t\t\t\tProgramDatabaseFile=\""
  1113. << path << "/" << targetNamePDB
  1114. << "\"\n";
  1115. if(isDebug)
  1116. {
  1117. fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
  1118. }
  1119. if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") )
  1120. {
  1121. fout << "\t\t\t\tSubSystem=\""
  1122. << (this->FortranProject? "subSystemWindows" : "2") << "\"\n";
  1123. }
  1124. else
  1125. {
  1126. fout << "\t\t\t\tSubSystem=\""
  1127. << (this->FortranProject? "subSystemConsole" : "1") << "\"\n";
  1128. }
  1129. std::string stackVar = "CMAKE_";
  1130. stackVar += linkLanguage;
  1131. stackVar += "_STACK_SIZE";
  1132. const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
  1133. if(stackVal)
  1134. {
  1135. fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"";
  1136. }
  1137. temp = target.GetDirectory(configName, true);
  1138. temp += "/";
  1139. temp += targetNameImport;
  1140. fout << "\t\t\t\tImportLibrary=\""
  1141. << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n";
  1142. break;
  1143. }
  1144. case cmTarget::UTILITY:
  1145. case cmTarget::GLOBAL_TARGET:
  1146. break;
  1147. }
  1148. }
  1149. //----------------------------------------------------------------------------
  1150. void
  1151. cmLocalVisualStudio7Generator
  1152. ::WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target)
  1153. {
  1154. int major;
  1155. int minor;
  1156. target.GetTargetVersion(major, minor);
  1157. fout << "\t\t\t\tVersion=\"" << major << "." << minor << "\"\n";
  1158. }
  1159. //----------------------------------------------------------------------------
  1160. void
  1161. cmLocalVisualStudio7GeneratorInternals
  1162. ::OutputLibraries(std::ostream& fout, ItemVector const& libs)
  1163. {
  1164. cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
  1165. for(ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l)
  1166. {
  1167. if(l->IsPath)
  1168. {
  1169. std::string rel = lg->Convert(l->Value.c_str(),
  1170. cmLocalGenerator::START_OUTPUT,
  1171. cmLocalGenerator::UNCHANGED);
  1172. fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " ";
  1173. }
  1174. else
  1175. {
  1176. fout << l->Value << " ";
  1177. }
  1178. }
  1179. }
  1180. //----------------------------------------------------------------------------
  1181. void
  1182. cmLocalVisualStudio7Generator
  1183. ::OutputLibraryDirectories(std::ostream& fout,
  1184. std::vector<std::string> const& dirs)
  1185. {
  1186. const char* comma = "";
  1187. for(std::vector<std::string>::const_iterator d = dirs.begin();
  1188. d != dirs.end(); ++d)
  1189. {
  1190. // Remove any trailing slash and skip empty paths.
  1191. std::string dir = *d;
  1192. if(dir[dir.size()-1] == '/')
  1193. {
  1194. dir = dir.substr(0, dir.size()-1);
  1195. }
  1196. if(dir.empty())
  1197. {
  1198. continue;
  1199. }
  1200. // Switch to a relative path specification if it is shorter.
  1201. if(cmSystemTools::FileIsFullPath(dir.c_str()))
  1202. {
  1203. std::string rel = this->Convert(dir.c_str(), START_OUTPUT, UNCHANGED);
  1204. if(rel.size() < dir.size())
  1205. {
  1206. dir = rel;
  1207. }
  1208. }
  1209. // First search a configuration-specific subdirectory and then the
  1210. // original directory.
  1211. fout << comma << this->ConvertToXMLOutputPath((dir+"/$(OutDir)").c_str())
  1212. << "," << this->ConvertToXMLOutputPath(dir.c_str());
  1213. comma = ",";
  1214. }
  1215. }
  1216. void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
  1217. const char *libName,
  1218. cmTarget &target)
  1219. {
  1220. // get the configurations
  1221. std::vector<std::string> *configs =
  1222. static_cast<cmGlobalVisualStudio7Generator *>
  1223. (this->GlobalGenerator)->GetConfigurations();
  1224. // We may be modifying the source groups temporarily, so make a copy.
  1225. std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
  1226. // get the classes from the source lists then add them to the groups
  1227. this->ModuleDefinitionFile = "";
  1228. std::vector<cmSourceFile*>const & classes = target.GetSourceFiles();
  1229. for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
  1230. i != classes.end(); i++)
  1231. {
  1232. // Add the file to the list of sources.
  1233. std::string source = (*i)->GetFullPath();
  1234. if(cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF")
  1235. {
  1236. this->ModuleDefinitionFile = (*i)->GetFullPath();
  1237. }
  1238. cmSourceGroup& sourceGroup =
  1239. this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
  1240. sourceGroup.AssignSource(*i);
  1241. }
  1242. // Compute which sources need unique object computation.
  1243. this->ComputeObjectNameRequirements(sourceGroups);
  1244. // open the project
  1245. this->WriteProjectStart(fout, libName, target, sourceGroups);
  1246. // write the configuration information
  1247. this->WriteConfigurations(fout, libName, target);
  1248. fout << "\t<Files>\n";
  1249. // Loop through every source group.
  1250. for(unsigned int i = 0; i < sourceGroups.size(); ++i)
  1251. {
  1252. cmSourceGroup sg = sourceGroups[i];
  1253. this->WriteGroup(&sg, target, fout, libName, configs);
  1254. }
  1255. //}
  1256. fout << "\t</Files>\n";
  1257. // Write the VCProj file's footer.
  1258. this->WriteVCProjFooter(fout, target);
  1259. }
  1260. struct cmLVS7GFileConfig
  1261. {
  1262. std::string ObjectName;
  1263. std::string CompileFlags;
  1264. std::string CompileDefs;
  1265. std::string CompileDefsConfig;
  1266. std::string AdditionalDeps;
  1267. bool ExcludedFromBuild;
  1268. };
  1269. class cmLocalVisualStudio7GeneratorFCInfo
  1270. {
  1271. public:
  1272. cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg,
  1273. cmTarget& target,
  1274. cmSourceFile const& sf,
  1275. std::vector<std::string>* configs,
  1276. std::string const& dir_max);
  1277. std::map<cmStdString, cmLVS7GFileConfig> FileConfigMap;
  1278. };
  1279. cmLocalVisualStudio7GeneratorFCInfo
  1280. ::cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg,
  1281. cmTarget& target,
  1282. cmSourceFile const& sf,
  1283. std::vector<std::string>* configs,
  1284. std::string const& dir_max)
  1285. {
  1286. std::string objectName;
  1287. if(lg->NeedObjectName.find(&sf) != lg->NeedObjectName.end())
  1288. {
  1289. objectName = lg->GetObjectFileNameWithoutTarget(sf, dir_max);
  1290. }
  1291. // Compute per-source, per-config information.
  1292. for(std::vector<std::string>::iterator i = configs->begin();
  1293. i != configs->end(); ++i)
  1294. {
  1295. std::string configUpper = cmSystemTools::UpperCase(*i);
  1296. cmLVS7GFileConfig fc;
  1297. bool needfc = false;
  1298. if(!objectName.empty())
  1299. {
  1300. fc.ObjectName = objectName;
  1301. needfc = true;
  1302. }
  1303. if(const char* cflags = sf.GetProperty("COMPILE_FLAGS"))
  1304. {
  1305. fc.CompileFlags = cflags;
  1306. needfc = true;
  1307. }
  1308. if(lg->FortranProject)
  1309. {
  1310. switch(lg->GetFortranFormat(sf.GetProperty("Fortran_FORMAT")))
  1311. {
  1312. case cmLocalGenerator::FortranFormatFixed:
  1313. fc.CompileFlags = "-fixed " + fc.CompileFlags;
  1314. needfc = true;
  1315. break;
  1316. case cmLocalGenerator::FortranFormatFree:
  1317. fc.CompileFlags = "-free " + fc.CompileFlags;
  1318. needfc = true;
  1319. break;
  1320. default: break;
  1321. }
  1322. }
  1323. if(const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS"))
  1324. {
  1325. fc.CompileDefs = cdefs;
  1326. needfc = true;
  1327. }
  1328. std::string defPropName = "COMPILE_DEFINITIONS_";
  1329. defPropName += configUpper;
  1330. if(const char* ccdefs = sf.GetProperty(defPropName.c_str()))
  1331. {
  1332. fc.CompileDefsConfig = ccdefs;
  1333. needfc = true;
  1334. }
  1335. // Check for extra object-file dependencies.
  1336. if(const char* deps = sf.GetProperty("OBJECT_DEPENDS"))
  1337. {
  1338. std::vector<std::string> depends;
  1339. cmSystemTools::ExpandListArgument(deps, depends);
  1340. const char* sep = "";
  1341. for(std::vector<std::string>::iterator j = depends.begin();
  1342. j != depends.end(); ++j)
  1343. {
  1344. fc.AdditionalDeps += sep;
  1345. fc.AdditionalDeps += lg->ConvertToXMLOutputPath(j->c_str());
  1346. sep = ";";
  1347. needfc = true;
  1348. }
  1349. }
  1350. const char* lang =
  1351. lg->GlobalGenerator->GetLanguageFromExtension
  1352. (sf.GetExtension().c_str());
  1353. const char* sourceLang = lg->GetSourceFileLanguage(sf);
  1354. const char* linkLanguage = target.GetLinkerLanguage(i->c_str());
  1355. bool needForceLang = false;
  1356. // source file does not match its extension language
  1357. if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
  1358. {
  1359. needForceLang = true;
  1360. lang = sourceLang;
  1361. }
  1362. // If HEADER_FILE_ONLY is set, we must suppress this generation in
  1363. // the project file
  1364. fc.ExcludedFromBuild =
  1365. (sf.GetPropertyAsBool("HEADER_FILE_ONLY"));
  1366. if(fc.ExcludedFromBuild)
  1367. {
  1368. needfc = true;
  1369. }
  1370. // if the source file does not match the linker language
  1371. // then force c or c++
  1372. if(needForceLang || (linkLanguage && lang
  1373. && strcmp(lang, linkLanguage) != 0))
  1374. {
  1375. if(strcmp(lang, "CXX") == 0)
  1376. {
  1377. // force a C++ file type
  1378. fc.CompileFlags += " /TP ";
  1379. needfc = true;
  1380. }
  1381. else if(strcmp(lang, "C") == 0)
  1382. {
  1383. // force to c
  1384. fc.CompileFlags += " /TC ";
  1385. needfc = true;
  1386. }
  1387. }
  1388. if(needfc)
  1389. {
  1390. this->FileConfigMap[*i] = fc;
  1391. }
  1392. }
  1393. }
  1394. void cmLocalVisualStudio7Generator
  1395. ::ComputeMaxDirectoryLength(std::string& maxdir,
  1396. cmTarget& target)
  1397. {
  1398. std::vector<std::string> *configs =
  1399. static_cast<cmGlobalVisualStudio7Generator *>
  1400. (this->GlobalGenerator)->GetConfigurations();
  1401. // Compute the maximum length configuration name.
  1402. std::string config_max;
  1403. for(std::vector<std::string>::iterator i = configs->begin();
  1404. i != configs->end(); ++i)
  1405. {
  1406. if(i->size() > config_max.size())
  1407. {
  1408. config_max = *i;
  1409. }
  1410. }
  1411. // Compute the maximum length full path to the intermediate
  1412. // files directory for any configuration. This is used to construct
  1413. // object file names that do not produce paths that are too long.
  1414. std::string dir_max;
  1415. dir_max += this->Makefile->GetCurrentOutputDirectory();
  1416. dir_max += "/";
  1417. dir_max += this->GetTargetDirectory(target);
  1418. dir_max += "/";
  1419. dir_max += config_max;
  1420. dir_max += "/";
  1421. maxdir = dir_max;
  1422. }
  1423. void cmLocalVisualStudio7Generator
  1424. ::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
  1425. std::ostream &fout, const char *libName,
  1426. std::vector<std::string> *configs)
  1427. {
  1428. const std::vector<const cmSourceFile *> &sourceFiles =
  1429. sg->GetSourceFiles();
  1430. // If the group is empty, don't write it at all.
  1431. if(sourceFiles.empty() && sg->GetGroupChildren().empty())
  1432. {
  1433. return;
  1434. }
  1435. // If the group has a name, write the header.
  1436. std::string name = sg->GetName();
  1437. if(name != "")
  1438. {
  1439. this->WriteVCProjBeginGroup(fout, name.c_str(), "");
  1440. }
  1441. // Compute the maximum length full path to the intermediate
  1442. // files directory for any configuration. This is used to construct
  1443. // object file names that do not produce paths that are too long.
  1444. std::string dir_max;
  1445. this->ComputeMaxDirectoryLength(dir_max, target);
  1446. // Loop through each source in the source group.
  1447. std::string objectName;
  1448. for(std::vector<const cmSourceFile *>::const_iterator sf =
  1449. sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
  1450. {
  1451. std::string source = (*sf)->GetFullPath();
  1452. FCInfo fcinfo(this, target, *(*sf), configs, dir_max);
  1453. if (source != libName || target.GetType() == cmTarget::UTILITY ||
  1454. target.GetType() == cmTarget::GLOBAL_TARGET )
  1455. {
  1456. fout << "\t\t\t<File\n";
  1457. std::string d = this->ConvertToXMLOutputPathSingle(source.c_str());
  1458. // Tell MS-Dev what the source is. If the compiler knows how to
  1459. // build it, then it will.
  1460. fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
  1461. if(cmCustomCommand const* command = (*sf)->GetCustomCommand())
  1462. {
  1463. this->WriteCustomRule(fout, source.c_str(), *command, fcinfo);
  1464. }
  1465. else if(!fcinfo.FileConfigMap.empty())
  1466. {
  1467. const char* aCompilerTool = "VCCLCompilerTool";
  1468. const char* lang = "CXX";
  1469. if(this->FortranProject)
  1470. {
  1471. aCompilerTool = "VFFortranCompilerTool";
  1472. }
  1473. std::string ext = (*sf)->GetExtension();
  1474. ext = cmSystemTools::LowerCase(ext);
  1475. if(ext == "idl")
  1476. {
  1477. aCompilerTool = "VCMIDLTool";
  1478. if(this->FortranProject)
  1479. {
  1480. aCompilerTool = "VFMIDLTool";
  1481. }
  1482. }
  1483. if(ext == "rc")
  1484. {
  1485. aCompilerTool = "VCResourceCompilerTool";
  1486. lang = "RC";
  1487. if(this->FortranProject)
  1488. {
  1489. aCompilerTool = "VFResourceCompilerTool";
  1490. }
  1491. }
  1492. if(ext == "def")
  1493. {
  1494. aCompilerTool = "VCCustomBuildTool";
  1495. if(this->FortranProject)
  1496. {
  1497. aCompilerTool = "VFCustomBuildTool";
  1498. }
  1499. }
  1500. for(std::map<cmStdString, cmLVS7GFileConfig>::const_iterator
  1501. fci = fcinfo.FileConfigMap.begin();
  1502. fci != fcinfo.FileConfigMap.end(); ++fci)
  1503. {
  1504. cmLVS7GFileConfig const& fc = fci->second;
  1505. fout << "\t\t\t\t<FileConfiguration\n"
  1506. << "\t\t\t\t\tName=\"" << fci->first
  1507. << "|" << this->PlatformName << "\"";
  1508. if(fc.ExcludedFromBuild)
  1509. {
  1510. fout << " ExcludedFromBuild=\"true\"";
  1511. }
  1512. fout << ">\n";
  1513. fout << "\t\t\t\t\t<Tool\n"
  1514. << "\t\t\t\t\tName=\"" << aCompilerTool << "\"\n";
  1515. if(!fc.CompileFlags.empty() ||
  1516. !fc.CompileDefs.empty() ||
  1517. !fc.CompileDefsConfig.empty())
  1518. {
  1519. Options::Tool tool = Options::Compiler;
  1520. cmVS7FlagTable const* table =
  1521. cmLocalVisualStudio7GeneratorFlagTable;
  1522. if(this->FortranProject)
  1523. {
  1524. tool = Options::FortranCompiler;
  1525. table = cmLocalVisualStudio7GeneratorFortranFlagTable;
  1526. }
  1527. Options fileOptions(this, tool, table,
  1528. this->ExtraFlagTable);
  1529. fileOptions.Parse(fc.CompileFlags.c_str());
  1530. fileOptions.AddDefines(fc.CompileDefs.c_str());
  1531. fileOptions.AddDefines(fc.CompileDefsConfig.c_str());
  1532. fileOptions.OutputAdditionalOptions(fout, "\t\t\t\t\t", "\n");
  1533. fileOptions.OutputFlagMap(fout, "\t\t\t\t\t");
  1534. fileOptions.OutputPreprocessorDefinitions(fout,
  1535. "\t\t\t\t\t", "\n",
  1536. lang);
  1537. }
  1538. if(!fc.AdditionalDeps.empty())
  1539. {
  1540. fout << "\t\t\t\t\tAdditionalDependencies=\""
  1541. << fc.AdditionalDeps.c_str() << "\"\n";
  1542. }
  1543. if(!fc.ObjectName.empty())
  1544. {
  1545. fout << "\t\t\t\t\tObjectFile=\"$(IntDir)/"
  1546. << fc.ObjectName.c_str() << "\"\n";
  1547. }
  1548. fout << "\t\t\t\t\t/>\n"
  1549. << "\t\t\t\t</FileConfiguration>\n";
  1550. }
  1551. }
  1552. fout << "\t\t\t</File>\n";
  1553. }
  1554. }
  1555. std::vector<cmSourceGroup> const& children = sg->GetGroupChildren();
  1556. for(unsigned int i=0;i<children.size();++i)
  1557. {
  1558. this->WriteGroup(&children[i], target, fout, libName, configs);
  1559. }
  1560. // If the group has a name, write the footer.
  1561. if(name != "")
  1562. {
  1563. this->WriteVCProjEndGroup(fout);
  1564. }
  1565. }
  1566. void cmLocalVisualStudio7Generator::
  1567. WriteCustomRule(std::ostream& fout,
  1568. const char* source,
  1569. const cmCustomCommand& command,
  1570. FCInfo& fcinfo)
  1571. {
  1572. std::string comment = this->ConstructComment(command);
  1573. // Write the rule for each configuration.
  1574. std::vector<std::string>::iterator i;
  1575. std::vector<std::string> *configs =
  1576. static_cast<cmGlobalVisualStudio7Generator *>
  1577. (this->GlobalGenerator)->GetConfigurations();
  1578. const char* compileTool = "VCCLCompilerTool";
  1579. if(this->FortranProject)
  1580. {
  1581. compileTool = "VFCLCompilerTool";
  1582. }
  1583. const char* customTool = "VCCustomBuildTool";
  1584. if(this->FortranProject)
  1585. {
  1586. customTool = "VFCustomBuildTool";
  1587. }
  1588. for(i = configs->begin(); i != configs->end(); ++i)
  1589. {
  1590. cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i];
  1591. fout << "\t\t\t\t<FileConfiguration\n";
  1592. fout << "\t\t\t\t\tName=\"" << *i << "|" << this->PlatformName << "\">\n";
  1593. if(!fc.CompileFlags.empty())
  1594. {
  1595. fout << "\t\t\t\t\t<Tool\n"
  1596. << "\t\t\t\t\tName=\"" << compileTool << "\"\n"
  1597. << "\t\t\t\t\tAdditionalOptions=\""
  1598. << this->EscapeForXML(fc.CompileFlags.c_str()) << "\"/>\n";
  1599. }
  1600. std::string script = this->ConstructScript(command, i->c_str());
  1601. if(this->FortranProject)
  1602. {
  1603. cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str());
  1604. }
  1605. fout << "\t\t\t\t\t<Tool\n"
  1606. << "\t\t\t\t\tName=\"" << customTool << "\"\n"
  1607. << "\t\t\t\t\tDescription=\""
  1608. << this->EscapeForXML(comment.c_str()) << "\"\n"
  1609. << "\t\t\t\t\tCommandLine=\""
  1610. << this->EscapeForXML(script.c_str()) << "\"\n"
  1611. << "\t\t\t\t\tAdditionalDependencies=\"";
  1612. if(command.GetDepends().empty())
  1613. {
  1614. // There are no real dependencies. Produce an artificial one to
  1615. // make sure the rule runs reliably.
  1616. if(!cmSystemTools::FileExists(source))
  1617. {
  1618. std::ofstream depout(source);
  1619. depout << "Artificial dependency for a custom command.\n";
  1620. }
  1621. fout << this->ConvertToXMLOutputPath(source);
  1622. }
  1623. else
  1624. {
  1625. // Write out the dependencies for the rule.
  1626. for(std::vector<std::string>::const_iterator d =
  1627. command.GetDepends().begin();
  1628. d != command.GetDepends().end();
  1629. ++d)
  1630. {
  1631. // Get the real name of the dependency in case it is a CMake target.
  1632. std::string dep;
  1633. if(this->GetRealDependency(d->c_str(), i->c_str(), dep))
  1634. {
  1635. fout << this->ConvertToXMLOutputPath(dep.c_str())
  1636. << ";";
  1637. }
  1638. }
  1639. }
  1640. fout << "\"\n";
  1641. fout << "\t\t\t\t\tOutputs=\"";
  1642. if(command.GetOutputs().empty())
  1643. {
  1644. fout << source << "_force";
  1645. }
  1646. else
  1647. {
  1648. // Write a rule for the output generated by this command.
  1649. const char* sep = "";
  1650. for(std::vector<std::string>::const_iterator o =
  1651. command.GetOutputs().begin();
  1652. o != command.GetOutputs().end();
  1653. ++o)
  1654. {
  1655. fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str());
  1656. sep = ";";
  1657. }
  1658. }
  1659. fout << "\"/>\n";
  1660. fout << "\t\t\t\t</FileConfiguration>\n";
  1661. }
  1662. }
  1663. void cmLocalVisualStudio7Generator::WriteVCProjBeginGroup(std::ostream& fout,
  1664. const char* group,
  1665. const char* )
  1666. {
  1667. fout << "\t\t<Filter\n"
  1668. << "\t\t\tName=\"" << group << "\"\n"
  1669. << "\t\t\tFilter=\"\">\n";
  1670. }
  1671. void cmLocalVisualStudio7Generator::WriteVCProjEndGroup(std::ostream& fout)
  1672. {
  1673. fout << "\t\t</Filter>\n";
  1674. }
  1675. // look for custom rules on a target and collect them together
  1676. void cmLocalVisualStudio7Generator
  1677. ::OutputTargetRules(std::ostream& fout,
  1678. const char* configName,
  1679. cmTarget &target,
  1680. const char * /*libName*/)
  1681. {
  1682. if (target.GetType() > cmTarget::GLOBAL_TARGET)
  1683. {
  1684. return;
  1685. }
  1686. EventWriter event(this, configName, fout);
  1687. // Add pre-build event.
  1688. const char* tool =
  1689. this->FortranProject? "VFPreBuildEventTool":"VCPreBuildEventTool";
  1690. event.Start(tool);
  1691. event.Write(target.GetPreBuildCommands());
  1692. event.Finish();
  1693. // Add pre-link event.
  1694. tool = this->FortranProject? "VFPreLinkEventTool":"VCPreLinkEventTool";
  1695. event.Start(tool);
  1696. event.Write(target.GetPreLinkCommands());
  1697. cmsys::auto_ptr<cmCustomCommand> pcc(
  1698. this->MaybeCreateImplibDir(target, configName, this->FortranProject));
  1699. if(pcc.get())
  1700. {
  1701. event.Write(*pcc);
  1702. }
  1703. event.Finish();
  1704. // Add post-build event.
  1705. tool = this->FortranProject? "VFPostBuildEventTool":"VCPostBuildEventTool";
  1706. event.Start(tool);
  1707. event.Write(target.GetPostBuildCommands());
  1708. event.Finish();
  1709. }
  1710. void cmLocalVisualStudio7Generator::WriteProjectSCC(std::ostream& fout,
  1711. cmTarget& target)
  1712. {
  1713. // if we have all the required Source code control tags
  1714. // then add that to the project
  1715. const char* vsProjectname = target.GetProperty("VS_SCC_PROJECTNAME");
  1716. const char* vsLocalpath = target.GetProperty("VS_SCC_LOCALPATH");
  1717. const char* vsProvider = target.GetProperty("VS_SCC_PROVIDER");
  1718. if(vsProvider && vsLocalpath && vsProjectname)
  1719. {
  1720. fout << "\tSccProjectName=\"" << vsProjectname << "\"\n"
  1721. << "\tSccLocalPath=\"" << vsLocalpath << "\"\n"
  1722. << "\tSccProvider=\"" << vsProvider << "\"\n";
  1723. const char* vsAuxPath = target.GetProperty("VS_SCC_AUXPATH");
  1724. if(vsAuxPath)
  1725. {
  1726. fout << "\tSccAuxPath=\"" << vsAuxPath << "\"\n";
  1727. }
  1728. }
  1729. }
  1730. void
  1731. cmLocalVisualStudio7Generator
  1732. ::WriteProjectStartFortran(std::ostream& fout,
  1733. const char *libName,
  1734. cmTarget & target)
  1735. {
  1736. cmGlobalVisualStudio7Generator* gg =
  1737. static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
  1738. // Compute the version of the Intel plugin to the VS IDE.
  1739. // If the key does not exist then use a default guess.
  1740. std::string intelVersion = "9.10";
  1741. std::string vskey = gg->GetRegistryBase();
  1742. vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion";
  1743. cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion,
  1744. cmSystemTools::KeyWOW64_32);
  1745. if (intelVersion.find("12") == 0 || (intelVersion.find("11") == 0))
  1746. {
  1747. // Version 11.x and 12.x actually use 11.0 in project files!
  1748. intelVersion = "11.0" ;
  1749. }
  1750. else if(intelVersion.find("10") == 0)
  1751. {
  1752. // Version 10.x actually uses 9.10 in project files!
  1753. intelVersion = "9.10";
  1754. }
  1755. fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
  1756. << "<VisualStudioProject\n"
  1757. << "\tProjectCreator=\"Intel Fortran\"\n"
  1758. << "\tVersion=\"" << intelVersion << "\"\n";
  1759. const char* keyword = target.GetProperty("VS_KEYWORD");
  1760. if(!keyword)
  1761. {
  1762. keyword = "Console Application";
  1763. }
  1764. const char* projectType = 0;
  1765. switch(target.GetType())
  1766. {
  1767. case cmTarget::STATIC_LIBRARY:
  1768. projectType = "typeStaticLibrary";
  1769. if(keyword)
  1770. {
  1771. keyword = "Static Library";
  1772. }
  1773. break;
  1774. case cmTarget::SHARED_LIBRARY:
  1775. case cmTarget::MODULE_LIBRARY:
  1776. projectType = "typeDynamicLibrary";
  1777. if(!keyword)
  1778. {
  1779. keyword = "Dll";
  1780. }
  1781. break;
  1782. case cmTarget::EXECUTABLE:
  1783. if(!keyword)
  1784. {
  1785. keyword = "Console Application";
  1786. }
  1787. projectType = 0;
  1788. break;
  1789. case cmTarget::UTILITY:
  1790. case cmTarget::GLOBAL_TARGET:
  1791. default:
  1792. break;
  1793. }
  1794. if(projectType)
  1795. {
  1796. fout << "\tProjectType=\"" << projectType << "\"\n";
  1797. }
  1798. this->WriteProjectSCC(fout, target);
  1799. fout<< "\tKeyword=\"" << keyword << "\">\n"
  1800. << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\">\n"
  1801. << "\t<Platforms>\n"
  1802. << "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n"
  1803. << "\t</Platforms>\n";
  1804. }
  1805. void
  1806. cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
  1807. const char *libName,
  1808. cmTarget & target,
  1809. std::vector<cmSourceGroup> &)
  1810. {
  1811. if(this->FortranProject)
  1812. {
  1813. this->WriteProjectStartFortran(fout, libName, target);
  1814. return;
  1815. }
  1816. fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
  1817. << "<VisualStudioProject\n"
  1818. << "\tProjectType=\"Visual C++\"\n";
  1819. if(this->Version == VS71)
  1820. {
  1821. fout << "\tVersion=\"7.10\"\n";
  1822. }
  1823. else
  1824. {
  1825. fout << "\tVersion=\"" << (this->Version/10) << ".00\"\n";
  1826. }
  1827. const char* projLabel = target.GetProperty("PROJECT_LABEL");
  1828. if(!projLabel)
  1829. {
  1830. projLabel = libName;
  1831. }
  1832. const char* keyword = target.GetProperty("VS_KEYWORD");
  1833. if(!keyword)
  1834. {
  1835. keyword = "Win32Proj";
  1836. }
  1837. cmGlobalVisualStudio7Generator* gg =
  1838. static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
  1839. fout << "\tName=\"" << projLabel << "\"\n";
  1840. if(this->Version >= VS8)
  1841. {
  1842. fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n";
  1843. }
  1844. this->WriteProjectSCC(fout, target);
  1845. fout << "\tKeyword=\"" << keyword << "\">\n"
  1846. << "\t<Platforms>\n"
  1847. << "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n"
  1848. << "\t</Platforms>\n";
  1849. }
  1850. void cmLocalVisualStudio7Generator::WriteVCProjFooter(std::ostream& fout,
  1851. cmTarget &target)
  1852. {
  1853. fout << "\t<Globals>\n";
  1854. cmPropertyMap const& props = target.GetProperties();
  1855. for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i)
  1856. {
  1857. if(i->first.find("VS_GLOBAL_") == 0)
  1858. {
  1859. std::string name = i->first.substr(10);
  1860. if(name != "")
  1861. {
  1862. fout << "\t\t<Global\n"
  1863. << "\t\t\tName=\"" << name << "\"\n"
  1864. << "\t\t\tValue=\"" << i->second.GetValue() << "\"\n"
  1865. << "\t\t/>\n";
  1866. }
  1867. }
  1868. }
  1869. fout << "\t</Globals>\n"
  1870. << "</VisualStudioProject>\n";
  1871. }
  1872. std::string cmLocalVisualStudio7GeneratorEscapeForXML(const char* s)
  1873. {
  1874. std::string ret = s;
  1875. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1876. cmSystemTools::ReplaceString(ret, "\"", "&quot;");
  1877. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1878. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1879. cmSystemTools::ReplaceString(ret, "\n", "&#x0D;&#x0A;");
  1880. return ret;
  1881. }
  1882. std::string cmLocalVisualStudio7Generator::EscapeForXML(const char* s)
  1883. {
  1884. return cmLocalVisualStudio7GeneratorEscapeForXML(s);
  1885. }
  1886. std::string cmLocalVisualStudio7Generator
  1887. ::ConvertToXMLOutputPath(const char* path)
  1888. {
  1889. std::string ret = this->ConvertToOptionallyRelativeOutputPath(path);
  1890. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1891. cmSystemTools::ReplaceString(ret, "\"", "&quot;");
  1892. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1893. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1894. return ret;
  1895. }
  1896. std::string cmLocalVisualStudio7Generator
  1897. ::ConvertToXMLOutputPathSingle(const char* path)
  1898. {
  1899. std::string ret = this->ConvertToOptionallyRelativeOutputPath(path);
  1900. cmSystemTools::ReplaceString(ret, "\"", "");
  1901. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1902. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1903. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1904. return ret;
  1905. }
  1906. // This class is used to parse an existing vs 7 project
  1907. // and extract the GUID
  1908. class cmVS7XMLParser : public cmXMLParser
  1909. {
  1910. public:
  1911. virtual void EndElement(const char* /* name */)
  1912. {
  1913. }
  1914. virtual void StartElement(const char* name, const char** atts)
  1915. {
  1916. // once the GUID is found do nothing
  1917. if(this->GUID.size())
  1918. {
  1919. return;
  1920. }
  1921. int i =0;
  1922. if(strcmp("VisualStudioProject", name) == 0)
  1923. {
  1924. while(atts[i])
  1925. {
  1926. if(strcmp(atts[i], "ProjectGUID") == 0)
  1927. {
  1928. if(atts[i+1])
  1929. {
  1930. this->GUID = atts[i+1];
  1931. this->GUID = this->GUID.substr(1, this->GUID.size()-2);
  1932. }
  1933. else
  1934. {
  1935. this->GUID = "";
  1936. }
  1937. return;
  1938. }
  1939. ++i;
  1940. }
  1941. }
  1942. }
  1943. int InitializeParser()
  1944. {
  1945. int ret = cmXMLParser::InitializeParser();
  1946. if(ret == 0)
  1947. {
  1948. return ret;
  1949. }
  1950. // visual studio projects have a strange encoding, but it is
  1951. // really utf-8
  1952. XML_SetEncoding(static_cast<XML_Parser>(this->Parser), "utf-8");
  1953. return 1;
  1954. }
  1955. std::string GUID;
  1956. };
  1957. void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID(
  1958. const char* name,
  1959. const char* path)
  1960. {
  1961. cmVS7XMLParser parser;
  1962. parser.ParseFile(path);
  1963. // if we can not find a GUID then create one
  1964. if(parser.GUID.size() == 0)
  1965. {
  1966. cmGlobalVisualStudio7Generator* gg =
  1967. static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
  1968. gg->CreateGUID(name);
  1969. return;
  1970. }
  1971. std::string guidStoreName = name;
  1972. guidStoreName += "_GUID_CMAKE";
  1973. // save the GUID in the cache
  1974. this->GlobalGenerator->GetCMakeInstance()->
  1975. AddCacheEntry(guidStoreName.c_str(),
  1976. parser.GUID.c_str(),
  1977. "Stored GUID",
  1978. cmCacheManager::INTERNAL);
  1979. }
  1980. //----------------------------------------------------------------------------
  1981. std::string cmLocalVisualStudio7Generator
  1982. ::GetTargetDirectory(cmTarget const& target) const
  1983. {
  1984. std::string dir;
  1985. dir += target.GetName();
  1986. dir += ".dir";
  1987. return dir;
  1988. }
  1989. void cmLocalVisualStudio7Generator::
  1990. GetTargetObjectFileDirectories(cmTarget* target,
  1991. std::vector<std::string>&
  1992. dirs)
  1993. {
  1994. std::string dir = this->Makefile->GetCurrentOutputDirectory();
  1995. dir += "/";
  1996. dir += this->GetTargetDirectory(*target);
  1997. dir += "/";
  1998. dir += this->GetGlobalGenerator()->GetCMakeCFGInitDirectory();
  1999. dirs.push_back(dir);
  2000. }
  2001. //----------------------------------------------------------------------------
  2002. #include <windows.h>
  2003. static bool cmLVS6G_IsFAT(const char* dir)
  2004. {
  2005. if(dir[0] && dir[1] == ':')
  2006. {
  2007. char volRoot[4] = "_:/";
  2008. volRoot[0] = dir[0];
  2009. char fsName[16];
  2010. if(GetVolumeInformation(volRoot, 0, 0, 0, 0, 0, fsName, 16) &&
  2011. strstr(fsName, "FAT") != 0)
  2012. {
  2013. return true;
  2014. }
  2015. }
  2016. return false;
  2017. }