cmLocalVisualStudio7Generator.cxx 72 KB

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