cmLocalVisualStudio7Generator.cxx 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133
  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
  728. {
  729. fout << "\t\t\tCharacterSet=\"2\">\n";
  730. }
  731. const char* tool = "VCCLCompilerTool";
  732. if(this->FortranProject)
  733. {
  734. tool = "VFFortranCompilerTool";
  735. }
  736. fout << "\t\t\t<Tool\n"
  737. << "\t\t\t\tName=\"" << tool << "\"\n";
  738. if(this->FortranProject)
  739. {
  740. const char* target_mod_dir =
  741. target.GetProperty("Fortran_MODULE_DIRECTORY");
  742. std::string modDir;
  743. if(target_mod_dir)
  744. {
  745. modDir = this->Convert(target_mod_dir,
  746. cmLocalGenerator::START_OUTPUT,
  747. cmLocalGenerator::UNCHANGED);
  748. }
  749. else
  750. {
  751. modDir = ".";
  752. }
  753. fout << "\t\t\t\tModulePath=\""
  754. << this->ConvertToXMLOutputPath(modDir.c_str())
  755. << "\\$(ConfigurationName)\"\n";
  756. }
  757. targetOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
  758. fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
  759. std::vector<std::string> includes;
  760. this->GetIncludeDirectories(includes);
  761. std::vector<std::string>::iterator i = includes.begin();
  762. for(;i != includes.end(); ++i)
  763. {
  764. // output the include path
  765. std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
  766. fout << ipath << ";";
  767. // if this is fortran then output the include with
  768. // a ConfigurationName on the end of it.
  769. if(this->FortranProject)
  770. {
  771. ipath = i->c_str();
  772. ipath += "/$(ConfigurationName)";
  773. ipath = this->ConvertToXMLOutputPath(ipath.c_str());
  774. fout << ipath << ";";
  775. }
  776. }
  777. fout << "\"\n";
  778. targetOptions.OutputFlagMap(fout, "\t\t\t\t");
  779. targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX");
  780. fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n";
  781. fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
  782. if(targetBuilds)
  783. {
  784. // We need to specify a program database file name even for
  785. // non-debug configurations because VS still creates .idb files.
  786. fout << "\t\t\t\tProgramDataBaseFileName=\""
  787. << this->ConvertToXMLOutputPathSingle(
  788. target.GetDirectory(configName).c_str())
  789. << "/"
  790. << target.GetPDBName(configName) << "\"\n";
  791. }
  792. fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
  793. tool = "VCCustomBuildTool";
  794. if(this->FortranProject)
  795. {
  796. tool = "VFCustomBuildTool";
  797. }
  798. fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"/>\n";
  799. tool = "VCResourceCompilerTool";
  800. if(this->FortranProject)
  801. {
  802. tool = "VFResourceCompilerTool";
  803. }
  804. fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"
  805. << "\t\t\t\tAdditionalIncludeDirectories=\"";
  806. for(i = includes.begin();i != includes.end(); ++i)
  807. {
  808. std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
  809. fout << ipath << ";";
  810. }
  811. // add the -D flags to the RC tool
  812. fout << "\"";
  813. targetOptions.OutputPreprocessorDefinitions(fout, "\n\t\t\t\t", "", "RC");
  814. fout << "/>\n";
  815. tool = "VCMIDLTool";
  816. if(this->FortranProject)
  817. {
  818. tool = "VFMIDLTool";
  819. }
  820. fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n";
  821. fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
  822. for(i = includes.begin(); i != includes.end(); ++i)
  823. {
  824. std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
  825. fout << ipath << ";";
  826. }
  827. fout << "\"\n";
  828. fout << "\t\t\t\tMkTypLibCompatible=\"FALSE\"\n";
  829. if( this->PlatformName == "x64" )
  830. {
  831. fout << "\t\t\t\tTargetEnvironment=\"3\"\n";
  832. }
  833. else if( this->PlatformName == "ia64" )
  834. {
  835. fout << "\t\t\t\tTargetEnvironment=\"2\"\n";
  836. }
  837. else
  838. {
  839. fout << "\t\t\t\tTargetEnvironment=\"1\"\n";
  840. }
  841. fout << "\t\t\t\tGenerateStublessProxies=\"TRUE\"\n";
  842. fout << "\t\t\t\tTypeLibraryName=\"$(InputName).tlb\"\n";
  843. fout << "\t\t\t\tOutputDirectory=\"$(IntDir)\"\n";
  844. fout << "\t\t\t\tHeaderFileName=\"$(InputName).h\"\n";
  845. fout << "\t\t\t\tDLLDataFileName=\"\"\n";
  846. fout << "\t\t\t\tInterfaceIdentifierFileName=\"$(InputName)_i.c\"\n";
  847. fout << "\t\t\t\tProxyFileName=\"$(InputName)_p.c\"/>\n";
  848. // end of <Tool Name=VCMIDLTool
  849. // Check if we need the FAT32 workaround.
  850. if(targetBuilds && this->Version >= VS8)
  851. {
  852. // Check the filesystem type where the target will be written.
  853. if(cmLVS6G_IsFAT(target.GetDirectory(configName).c_str()))
  854. {
  855. // Add a flag telling the manifest tool to use a workaround
  856. // for FAT32 file systems, which can cause an empty manifest
  857. // to be embedded into the resulting executable. See CMake
  858. // bug #2617.
  859. const char* tool = "VCManifestTool";
  860. if(this->FortranProject)
  861. {
  862. tool = "VFManifestTool";
  863. }
  864. fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"
  865. << "\t\t\t\tUseFAT32Workaround=\"true\"\n"
  866. << "\t\t\t/>\n";
  867. }
  868. }
  869. this->OutputTargetRules(fout, configName, target, libName);
  870. this->OutputBuildTool(fout, configName, target, targetOptions.IsDebug());
  871. fout << "\t\t</Configuration>\n";
  872. }
  873. //----------------------------------------------------------------------------
  874. std::string
  875. cmLocalVisualStudio7Generator
  876. ::GetBuildTypeLinkerFlags(std::string rootLinkerFlags, const char* configName)
  877. {
  878. std::string configTypeUpper = cmSystemTools::UpperCase(configName);
  879. std::string extraLinkOptionsBuildTypeDef =
  880. rootLinkerFlags + "_" + configTypeUpper;
  881. std::string extraLinkOptionsBuildType =
  882. this->Makefile->GetRequiredDefinition
  883. (extraLinkOptionsBuildTypeDef.c_str());
  884. return extraLinkOptionsBuildType;
  885. }
  886. void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
  887. const char* configName,
  888. cmTarget &target,
  889. bool isDebug)
  890. {
  891. cmGlobalVisualStudio7Generator* gg =
  892. static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
  893. std::string temp;
  894. std::string extraLinkOptions;
  895. if(target.GetType() == cmTarget::EXECUTABLE)
  896. {
  897. extraLinkOptions =
  898. this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS")
  899. + std::string(" ")
  900. + GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName);
  901. }
  902. if(target.GetType() == cmTarget::SHARED_LIBRARY)
  903. {
  904. extraLinkOptions =
  905. this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS")
  906. + std::string(" ")
  907. + GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName);
  908. }
  909. if(target.GetType() == cmTarget::MODULE_LIBRARY)
  910. {
  911. extraLinkOptions =
  912. this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS")
  913. + std::string(" ")
  914. + GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName);
  915. }
  916. const char* targetLinkFlags = target.GetProperty("LINK_FLAGS");
  917. if(targetLinkFlags)
  918. {
  919. extraLinkOptions += " ";
  920. extraLinkOptions += targetLinkFlags;
  921. }
  922. std::string configTypeUpper = cmSystemTools::UpperCase(configName);
  923. std::string linkFlagsConfig = "LINK_FLAGS_";
  924. linkFlagsConfig += configTypeUpper;
  925. targetLinkFlags = target.GetProperty(linkFlagsConfig.c_str());
  926. if(targetLinkFlags)
  927. {
  928. extraLinkOptions += " ";
  929. extraLinkOptions += targetLinkFlags;
  930. }
  931. Options linkOptions(this, Options::Linker,
  932. cmLocalVisualStudio7GeneratorLinkFlagTable);
  933. linkOptions.Parse(extraLinkOptions.c_str());
  934. if(!this->ModuleDefinitionFile.empty())
  935. {
  936. std::string defFile =
  937. this->ConvertToXMLOutputPath(this->ModuleDefinitionFile.c_str());
  938. linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str());
  939. }
  940. switch(target.GetType())
  941. {
  942. case cmTarget::STATIC_LIBRARY:
  943. {
  944. std::string targetNameFull = target.GetFullName(configName);
  945. std::string libpath = target.GetDirectory(configName);
  946. libpath += "/";
  947. libpath += targetNameFull;
  948. const char* tool = "VCLibrarianTool";
  949. if(this->FortranProject)
  950. {
  951. tool = "VFLibrarianTool";
  952. }
  953. fout << "\t\t\t<Tool\n"
  954. << "\t\t\t\tName=\"" << tool << "\"\n";
  955. std::string libflags;
  956. if(const char* flags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
  957. {
  958. libflags += flags;
  959. }
  960. std::string libFlagsConfig = "STATIC_LIBRARY_FLAGS_";
  961. libFlagsConfig += configTypeUpper;
  962. if(const char* flagsConfig = target.GetProperty(libFlagsConfig.c_str()))
  963. {
  964. libflags += " ";
  965. libflags += flagsConfig;
  966. }
  967. if(!libflags.empty())
  968. {
  969. fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
  970. }
  971. fout << "\t\t\t\tOutputFile=\""
  972. << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << "\"/>\n";
  973. break;
  974. }
  975. case cmTarget::SHARED_LIBRARY:
  976. case cmTarget::MODULE_LIBRARY:
  977. {
  978. std::string targetName;
  979. std::string targetNameSO;
  980. std::string targetNameFull;
  981. std::string targetNameImport;
  982. std::string targetNamePDB;
  983. target.GetLibraryNames(targetName, targetNameSO, targetNameFull,
  984. targetNameImport, targetNamePDB, configName);
  985. // Compute the link library and directory information.
  986. cmComputeLinkInformation* pcli = target.GetLinkInformation(configName);
  987. if(!pcli)
  988. {
  989. return;
  990. }
  991. cmComputeLinkInformation& cli = *pcli;
  992. const char* linkLanguage = cli.GetLinkLanguage();
  993. // Compute the variable name to lookup standard libraries for this
  994. // language.
  995. std::string standardLibsVar = "CMAKE_";
  996. standardLibsVar += linkLanguage;
  997. standardLibsVar += "_STANDARD_LIBRARIES";
  998. const char* tool = "VCLinkerTool";
  999. if(this->FortranProject)
  1000. {
  1001. tool = "VFLinkerTool";
  1002. }
  1003. fout << "\t\t\t<Tool\n"
  1004. << "\t\t\t\tName=\"" << tool << "\"\n";
  1005. if(!gg->NeedLinkLibraryDependencies(target))
  1006. {
  1007. fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
  1008. }
  1009. linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
  1010. // Use the NOINHERIT macro to avoid getting VS project default
  1011. // libraries which may be set by the user to something bad.
  1012. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
  1013. << this->Makefile->GetSafeDefinition(standardLibsVar.c_str())
  1014. << " ";
  1015. this->Internal->OutputLibraries(fout, cli.GetItems());
  1016. fout << "\"\n";
  1017. temp = target.GetDirectory(configName);
  1018. temp += "/";
  1019. temp += targetNameFull;
  1020. fout << "\t\t\t\tOutputFile=\""
  1021. << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  1022. this->WriteTargetVersionAttribute(fout, target);
  1023. linkOptions.OutputFlagMap(fout, "\t\t\t\t");
  1024. fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
  1025. this->OutputLibraryDirectories(fout, cli.GetDirectories());
  1026. fout << "\"\n";
  1027. temp = target.GetDirectory(configName);
  1028. temp += "/";
  1029. temp += targetNamePDB;
  1030. fout << "\t\t\t\tProgramDatabaseFile=\"" <<
  1031. this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  1032. if(isDebug)
  1033. {
  1034. fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
  1035. }
  1036. std::string stackVar = "CMAKE_";
  1037. stackVar += linkLanguage;
  1038. stackVar += "_STACK_SIZE";
  1039. const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
  1040. if(stackVal)
  1041. {
  1042. fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n";
  1043. }
  1044. temp = target.GetDirectory(configName, true);
  1045. temp += "/";
  1046. temp += targetNameImport;
  1047. fout << "\t\t\t\tImportLibrary=\""
  1048. << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"";
  1049. if(this->FortranProject)
  1050. {
  1051. fout << "\n\t\t\t\tLinkDLL=\"true\"";
  1052. }
  1053. fout << "/>\n";
  1054. }
  1055. break;
  1056. case cmTarget::EXECUTABLE:
  1057. {
  1058. std::string targetName;
  1059. std::string targetNameFull;
  1060. std::string targetNameImport;
  1061. std::string targetNamePDB;
  1062. target.GetExecutableNames(targetName, targetNameFull,
  1063. targetNameImport, targetNamePDB, configName);
  1064. // Compute the link library and directory information.
  1065. cmComputeLinkInformation* pcli = target.GetLinkInformation(configName);
  1066. if(!pcli)
  1067. {
  1068. return;
  1069. }
  1070. cmComputeLinkInformation& cli = *pcli;
  1071. const char* linkLanguage = cli.GetLinkLanguage();
  1072. // Compute the variable name to lookup standard libraries for this
  1073. // language.
  1074. std::string standardLibsVar = "CMAKE_";
  1075. standardLibsVar += linkLanguage;
  1076. standardLibsVar += "_STANDARD_LIBRARIES";
  1077. const char* tool = "VCLinkerTool";
  1078. if(this->FortranProject)
  1079. {
  1080. tool = "VFLinkerTool";
  1081. }
  1082. fout << "\t\t\t<Tool\n"
  1083. << "\t\t\t\tName=\"" << tool << "\"\n";
  1084. if(!gg->NeedLinkLibraryDependencies(target))
  1085. {
  1086. fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
  1087. }
  1088. linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
  1089. // Use the NOINHERIT macro to avoid getting VS project default
  1090. // libraries which may be set by the user to something bad.
  1091. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
  1092. << this->Makefile->GetSafeDefinition(standardLibsVar.c_str())
  1093. << " ";
  1094. this->Internal->OutputLibraries(fout, cli.GetItems());
  1095. fout << "\"\n";
  1096. temp = target.GetDirectory(configName);
  1097. temp += "/";
  1098. temp += targetNameFull;
  1099. fout << "\t\t\t\tOutputFile=\""
  1100. << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  1101. this->WriteTargetVersionAttribute(fout, target);
  1102. linkOptions.OutputFlagMap(fout, "\t\t\t\t");
  1103. fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
  1104. this->OutputLibraryDirectories(fout, cli.GetDirectories());
  1105. fout << "\"\n";
  1106. std::string path = this->ConvertToXMLOutputPathSingle(
  1107. target.GetDirectory(configName).c_str());
  1108. fout << "\t\t\t\tProgramDatabaseFile=\""
  1109. << path << "/" << targetNamePDB
  1110. << "\"\n";
  1111. if(isDebug)
  1112. {
  1113. fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
  1114. }
  1115. if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") )
  1116. {
  1117. fout << "\t\t\t\tSubSystem=\""
  1118. << (this->FortranProject? "subSystemWindows" : "2") << "\"\n";
  1119. }
  1120. else
  1121. {
  1122. fout << "\t\t\t\tSubSystem=\""
  1123. << (this->FortranProject? "subSystemConsole" : "1") << "\"\n";
  1124. }
  1125. std::string stackVar = "CMAKE_";
  1126. stackVar += linkLanguage;
  1127. stackVar += "_STACK_SIZE";
  1128. const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
  1129. if(stackVal)
  1130. {
  1131. fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"";
  1132. }
  1133. temp = target.GetDirectory(configName, true);
  1134. temp += "/";
  1135. temp += targetNameImport;
  1136. fout << "\t\t\t\tImportLibrary=\""
  1137. << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n";
  1138. break;
  1139. }
  1140. case cmTarget::UTILITY:
  1141. case cmTarget::GLOBAL_TARGET:
  1142. break;
  1143. }
  1144. }
  1145. //----------------------------------------------------------------------------
  1146. void
  1147. cmLocalVisualStudio7Generator
  1148. ::WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target)
  1149. {
  1150. int major;
  1151. int minor;
  1152. target.GetTargetVersion(major, minor);
  1153. fout << "\t\t\t\tVersion=\"" << major << "." << minor << "\"\n";
  1154. }
  1155. //----------------------------------------------------------------------------
  1156. void
  1157. cmLocalVisualStudio7GeneratorInternals
  1158. ::OutputLibraries(std::ostream& fout, ItemVector const& libs)
  1159. {
  1160. cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
  1161. for(ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l)
  1162. {
  1163. if(l->IsPath)
  1164. {
  1165. std::string rel = lg->Convert(l->Value.c_str(),
  1166. cmLocalGenerator::START_OUTPUT,
  1167. cmLocalGenerator::UNCHANGED);
  1168. fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " ";
  1169. }
  1170. else
  1171. {
  1172. fout << l->Value << " ";
  1173. }
  1174. }
  1175. }
  1176. //----------------------------------------------------------------------------
  1177. void
  1178. cmLocalVisualStudio7Generator
  1179. ::OutputLibraryDirectories(std::ostream& fout,
  1180. std::vector<std::string> const& dirs)
  1181. {
  1182. const char* comma = "";
  1183. for(std::vector<std::string>::const_iterator d = dirs.begin();
  1184. d != dirs.end(); ++d)
  1185. {
  1186. // Remove any trailing slash and skip empty paths.
  1187. std::string dir = *d;
  1188. if(dir[dir.size()-1] == '/')
  1189. {
  1190. dir = dir.substr(0, dir.size()-1);
  1191. }
  1192. if(dir.empty())
  1193. {
  1194. continue;
  1195. }
  1196. // Switch to a relative path specification if it is shorter.
  1197. if(cmSystemTools::FileIsFullPath(dir.c_str()))
  1198. {
  1199. std::string rel = this->Convert(dir.c_str(), START_OUTPUT, UNCHANGED);
  1200. if(rel.size() < dir.size())
  1201. {
  1202. dir = rel;
  1203. }
  1204. }
  1205. // First search a configuration-specific subdirectory and then the
  1206. // original directory.
  1207. fout << comma << this->ConvertToXMLOutputPath((dir+"/$(OutDir)").c_str())
  1208. << "," << this->ConvertToXMLOutputPath(dir.c_str());
  1209. comma = ",";
  1210. }
  1211. }
  1212. void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
  1213. const char *libName,
  1214. cmTarget &target)
  1215. {
  1216. // get the configurations
  1217. std::vector<std::string> *configs =
  1218. static_cast<cmGlobalVisualStudio7Generator *>
  1219. (this->GlobalGenerator)->GetConfigurations();
  1220. // We may be modifying the source groups temporarily, so make a copy.
  1221. std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
  1222. // get the classes from the source lists then add them to the groups
  1223. this->ModuleDefinitionFile = "";
  1224. std::vector<cmSourceFile*>const & classes = target.GetSourceFiles();
  1225. for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
  1226. i != classes.end(); i++)
  1227. {
  1228. // Add the file to the list of sources.
  1229. std::string source = (*i)->GetFullPath();
  1230. if(cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF")
  1231. {
  1232. this->ModuleDefinitionFile = (*i)->GetFullPath();
  1233. }
  1234. cmSourceGroup& sourceGroup =
  1235. this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
  1236. sourceGroup.AssignSource(*i);
  1237. }
  1238. // Compute which sources need unique object computation.
  1239. this->ComputeObjectNameRequirements(sourceGroups);
  1240. // open the project
  1241. this->WriteProjectStart(fout, libName, target, sourceGroups);
  1242. // write the configuration information
  1243. this->WriteConfigurations(fout, libName, target);
  1244. fout << "\t<Files>\n";
  1245. // Loop through every source group.
  1246. for(unsigned int i = 0; i < sourceGroups.size(); ++i)
  1247. {
  1248. cmSourceGroup sg = sourceGroups[i];
  1249. this->WriteGroup(&sg, target, fout, libName, configs);
  1250. }
  1251. //}
  1252. fout << "\t</Files>\n";
  1253. // Write the VCProj file's footer.
  1254. this->WriteVCProjFooter(fout, target);
  1255. }
  1256. struct cmLVS7GFileConfig
  1257. {
  1258. std::string ObjectName;
  1259. std::string CompileFlags;
  1260. std::string CompileDefs;
  1261. std::string CompileDefsConfig;
  1262. std::string AdditionalDeps;
  1263. bool ExcludedFromBuild;
  1264. };
  1265. class cmLocalVisualStudio7GeneratorFCInfo
  1266. {
  1267. public:
  1268. cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg,
  1269. cmTarget& target,
  1270. cmSourceFile const& sf,
  1271. std::vector<std::string>* configs,
  1272. std::string const& dir_max);
  1273. std::map<cmStdString, cmLVS7GFileConfig> FileConfigMap;
  1274. };
  1275. cmLocalVisualStudio7GeneratorFCInfo
  1276. ::cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg,
  1277. cmTarget& target,
  1278. cmSourceFile const& sf,
  1279. std::vector<std::string>* configs,
  1280. std::string const& dir_max)
  1281. {
  1282. std::string objectName;
  1283. if(lg->NeedObjectName.find(&sf) != lg->NeedObjectName.end())
  1284. {
  1285. objectName = lg->GetObjectFileNameWithoutTarget(sf, dir_max);
  1286. }
  1287. // Compute per-source, per-config information.
  1288. for(std::vector<std::string>::iterator i = configs->begin();
  1289. i != configs->end(); ++i)
  1290. {
  1291. std::string configUpper = cmSystemTools::UpperCase(*i);
  1292. cmLVS7GFileConfig fc;
  1293. bool needfc = false;
  1294. if(!objectName.empty())
  1295. {
  1296. fc.ObjectName = objectName;
  1297. needfc = true;
  1298. }
  1299. if(const char* cflags = sf.GetProperty("COMPILE_FLAGS"))
  1300. {
  1301. fc.CompileFlags = cflags;
  1302. needfc = true;
  1303. }
  1304. if(lg->FortranProject)
  1305. {
  1306. switch(lg->GetFortranFormat(sf.GetProperty("Fortran_FORMAT")))
  1307. {
  1308. case cmLocalGenerator::FortranFormatFixed:
  1309. fc.CompileFlags = "-fixed " + fc.CompileFlags;
  1310. needfc = true;
  1311. break;
  1312. case cmLocalGenerator::FortranFormatFree:
  1313. fc.CompileFlags = "-free " + fc.CompileFlags;
  1314. needfc = true;
  1315. break;
  1316. default: break;
  1317. }
  1318. }
  1319. if(const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS"))
  1320. {
  1321. fc.CompileDefs = cdefs;
  1322. needfc = true;
  1323. }
  1324. std::string defPropName = "COMPILE_DEFINITIONS_";
  1325. defPropName += configUpper;
  1326. if(const char* ccdefs = sf.GetProperty(defPropName.c_str()))
  1327. {
  1328. fc.CompileDefsConfig = ccdefs;
  1329. needfc = true;
  1330. }
  1331. // Check for extra object-file dependencies.
  1332. if(const char* deps = sf.GetProperty("OBJECT_DEPENDS"))
  1333. {
  1334. std::vector<std::string> depends;
  1335. cmSystemTools::ExpandListArgument(deps, depends);
  1336. const char* sep = "";
  1337. for(std::vector<std::string>::iterator j = depends.begin();
  1338. j != depends.end(); ++j)
  1339. {
  1340. fc.AdditionalDeps += sep;
  1341. fc.AdditionalDeps += lg->ConvertToXMLOutputPath(j->c_str());
  1342. sep = ";";
  1343. needfc = true;
  1344. }
  1345. }
  1346. const char* lang =
  1347. lg->GlobalGenerator->GetLanguageFromExtension
  1348. (sf.GetExtension().c_str());
  1349. const char* sourceLang = lg->GetSourceFileLanguage(sf);
  1350. const char* linkLanguage = target.GetLinkerLanguage(i->c_str());
  1351. bool needForceLang = false;
  1352. // source file does not match its extension language
  1353. if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
  1354. {
  1355. needForceLang = true;
  1356. lang = sourceLang;
  1357. }
  1358. // If HEADER_FILE_ONLY is set, we must suppress this generation in
  1359. // the project file
  1360. fc.ExcludedFromBuild =
  1361. (sf.GetPropertyAsBool("HEADER_FILE_ONLY"));
  1362. if(fc.ExcludedFromBuild)
  1363. {
  1364. needfc = true;
  1365. }
  1366. // if the source file does not match the linker language
  1367. // then force c or c++
  1368. if(needForceLang || (linkLanguage && lang
  1369. && strcmp(lang, linkLanguage) != 0))
  1370. {
  1371. if(strcmp(lang, "CXX") == 0)
  1372. {
  1373. // force a C++ file type
  1374. fc.CompileFlags += " /TP ";
  1375. needfc = true;
  1376. }
  1377. else if(strcmp(lang, "C") == 0)
  1378. {
  1379. // force to c
  1380. fc.CompileFlags += " /TC ";
  1381. needfc = true;
  1382. }
  1383. }
  1384. if(needfc)
  1385. {
  1386. this->FileConfigMap[*i] = fc;
  1387. }
  1388. }
  1389. }
  1390. void cmLocalVisualStudio7Generator
  1391. ::ComputeMaxDirectoryLength(std::string& maxdir,
  1392. cmTarget& target)
  1393. {
  1394. std::vector<std::string> *configs =
  1395. static_cast<cmGlobalVisualStudio7Generator *>
  1396. (this->GlobalGenerator)->GetConfigurations();
  1397. // Compute the maximum length configuration name.
  1398. std::string config_max;
  1399. for(std::vector<std::string>::iterator i = configs->begin();
  1400. i != configs->end(); ++i)
  1401. {
  1402. if(i->size() > config_max.size())
  1403. {
  1404. config_max = *i;
  1405. }
  1406. }
  1407. // Compute the maximum length full path to the intermediate
  1408. // files directory for any configuration. This is used to construct
  1409. // object file names that do not produce paths that are too long.
  1410. std::string dir_max;
  1411. dir_max += this->Makefile->GetCurrentOutputDirectory();
  1412. dir_max += "/";
  1413. dir_max += this->GetTargetDirectory(target);
  1414. dir_max += "/";
  1415. dir_max += config_max;
  1416. dir_max += "/";
  1417. maxdir = dir_max;
  1418. }
  1419. void cmLocalVisualStudio7Generator
  1420. ::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
  1421. std::ostream &fout, const char *libName,
  1422. std::vector<std::string> *configs)
  1423. {
  1424. const std::vector<const cmSourceFile *> &sourceFiles =
  1425. sg->GetSourceFiles();
  1426. // If the group is empty, don't write it at all.
  1427. if(sourceFiles.empty() && sg->GetGroupChildren().empty())
  1428. {
  1429. return;
  1430. }
  1431. // If the group has a name, write the header.
  1432. std::string name = sg->GetName();
  1433. if(name != "")
  1434. {
  1435. this->WriteVCProjBeginGroup(fout, name.c_str(), "");
  1436. }
  1437. // Compute the maximum length full path to the intermediate
  1438. // files directory for any configuration. This is used to construct
  1439. // object file names that do not produce paths that are too long.
  1440. std::string dir_max;
  1441. this->ComputeMaxDirectoryLength(dir_max, target);
  1442. // Loop through each source in the source group.
  1443. std::string objectName;
  1444. for(std::vector<const cmSourceFile *>::const_iterator sf =
  1445. sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
  1446. {
  1447. std::string source = (*sf)->GetFullPath();
  1448. FCInfo fcinfo(this, target, *(*sf), configs, dir_max);
  1449. if (source != libName || target.GetType() == cmTarget::UTILITY ||
  1450. target.GetType() == cmTarget::GLOBAL_TARGET )
  1451. {
  1452. fout << "\t\t\t<File\n";
  1453. std::string d = this->ConvertToXMLOutputPathSingle(source.c_str());
  1454. // Tell MS-Dev what the source is. If the compiler knows how to
  1455. // build it, then it will.
  1456. fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
  1457. if(cmCustomCommand const* command = (*sf)->GetCustomCommand())
  1458. {
  1459. this->WriteCustomRule(fout, source.c_str(), *command, fcinfo);
  1460. }
  1461. else if(!fcinfo.FileConfigMap.empty())
  1462. {
  1463. const char* aCompilerTool = "VCCLCompilerTool";
  1464. const char* lang = "CXX";
  1465. if(this->FortranProject)
  1466. {
  1467. aCompilerTool = "VFFortranCompilerTool";
  1468. }
  1469. std::string ext = (*sf)->GetExtension();
  1470. ext = cmSystemTools::LowerCase(ext);
  1471. if(ext == "idl")
  1472. {
  1473. aCompilerTool = "VCMIDLTool";
  1474. if(this->FortranProject)
  1475. {
  1476. aCompilerTool = "VFMIDLTool";
  1477. }
  1478. }
  1479. if(ext == "rc")
  1480. {
  1481. aCompilerTool = "VCResourceCompilerTool";
  1482. lang = "RC";
  1483. if(this->FortranProject)
  1484. {
  1485. aCompilerTool = "VFResourceCompilerTool";
  1486. }
  1487. }
  1488. if(ext == "def")
  1489. {
  1490. aCompilerTool = "VCCustomBuildTool";
  1491. if(this->FortranProject)
  1492. {
  1493. aCompilerTool = "VFCustomBuildTool";
  1494. }
  1495. }
  1496. for(std::map<cmStdString, cmLVS7GFileConfig>::const_iterator
  1497. fci = fcinfo.FileConfigMap.begin();
  1498. fci != fcinfo.FileConfigMap.end(); ++fci)
  1499. {
  1500. cmLVS7GFileConfig const& fc = fci->second;
  1501. fout << "\t\t\t\t<FileConfiguration\n"
  1502. << "\t\t\t\t\tName=\"" << fci->first
  1503. << "|" << this->PlatformName << "\"";
  1504. if(fc.ExcludedFromBuild)
  1505. {
  1506. fout << " ExcludedFromBuild=\"true\"";
  1507. }
  1508. fout << ">\n";
  1509. fout << "\t\t\t\t\t<Tool\n"
  1510. << "\t\t\t\t\tName=\"" << aCompilerTool << "\"\n";
  1511. if(!fc.CompileFlags.empty() ||
  1512. !fc.CompileDefs.empty() ||
  1513. !fc.CompileDefsConfig.empty())
  1514. {
  1515. Options::Tool tool = Options::Compiler;
  1516. cmVS7FlagTable const* table =
  1517. cmLocalVisualStudio7GeneratorFlagTable;
  1518. if(this->FortranProject)
  1519. {
  1520. tool = Options::FortranCompiler;
  1521. table = cmLocalVisualStudio7GeneratorFortranFlagTable;
  1522. }
  1523. Options fileOptions(this, tool, table,
  1524. this->ExtraFlagTable);
  1525. fileOptions.Parse(fc.CompileFlags.c_str());
  1526. fileOptions.AddDefines(fc.CompileDefs.c_str());
  1527. fileOptions.AddDefines(fc.CompileDefsConfig.c_str());
  1528. fileOptions.OutputAdditionalOptions(fout, "\t\t\t\t\t", "\n");
  1529. fileOptions.OutputFlagMap(fout, "\t\t\t\t\t");
  1530. fileOptions.OutputPreprocessorDefinitions(fout,
  1531. "\t\t\t\t\t", "\n",
  1532. lang);
  1533. }
  1534. if(!fc.AdditionalDeps.empty())
  1535. {
  1536. fout << "\t\t\t\t\tAdditionalDependencies=\""
  1537. << fc.AdditionalDeps.c_str() << "\"\n";
  1538. }
  1539. if(!fc.ObjectName.empty())
  1540. {
  1541. fout << "\t\t\t\t\tObjectFile=\"$(IntDir)/"
  1542. << fc.ObjectName.c_str() << "\"\n";
  1543. }
  1544. fout << "\t\t\t\t\t/>\n"
  1545. << "\t\t\t\t</FileConfiguration>\n";
  1546. }
  1547. }
  1548. fout << "\t\t\t</File>\n";
  1549. }
  1550. }
  1551. std::vector<cmSourceGroup> const& children = sg->GetGroupChildren();
  1552. for(unsigned int i=0;i<children.size();++i)
  1553. {
  1554. this->WriteGroup(&children[i], target, fout, libName, configs);
  1555. }
  1556. // If the group has a name, write the footer.
  1557. if(name != "")
  1558. {
  1559. this->WriteVCProjEndGroup(fout);
  1560. }
  1561. }
  1562. void cmLocalVisualStudio7Generator::
  1563. WriteCustomRule(std::ostream& fout,
  1564. const char* source,
  1565. const cmCustomCommand& command,
  1566. FCInfo& fcinfo)
  1567. {
  1568. std::string comment = this->ConstructComment(command);
  1569. // Write the rule for each configuration.
  1570. std::vector<std::string>::iterator i;
  1571. std::vector<std::string> *configs =
  1572. static_cast<cmGlobalVisualStudio7Generator *>
  1573. (this->GlobalGenerator)->GetConfigurations();
  1574. const char* compileTool = "VCCLCompilerTool";
  1575. if(this->FortranProject)
  1576. {
  1577. compileTool = "VFCLCompilerTool";
  1578. }
  1579. const char* customTool = "VCCustomBuildTool";
  1580. if(this->FortranProject)
  1581. {
  1582. customTool = "VFCustomBuildTool";
  1583. }
  1584. for(i = configs->begin(); i != configs->end(); ++i)
  1585. {
  1586. cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i];
  1587. fout << "\t\t\t\t<FileConfiguration\n";
  1588. fout << "\t\t\t\t\tName=\"" << *i << "|" << this->PlatformName << "\">\n";
  1589. if(!fc.CompileFlags.empty())
  1590. {
  1591. fout << "\t\t\t\t\t<Tool\n"
  1592. << "\t\t\t\t\tName=\"" << compileTool << "\"\n"
  1593. << "\t\t\t\t\tAdditionalOptions=\""
  1594. << this->EscapeForXML(fc.CompileFlags.c_str()) << "\"/>\n";
  1595. }
  1596. std::string script = this->ConstructScript(command, i->c_str());
  1597. if(this->FortranProject)
  1598. {
  1599. cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str());
  1600. }
  1601. fout << "\t\t\t\t\t<Tool\n"
  1602. << "\t\t\t\t\tName=\"" << customTool << "\"\n"
  1603. << "\t\t\t\t\tDescription=\""
  1604. << this->EscapeForXML(comment.c_str()) << "\"\n"
  1605. << "\t\t\t\t\tCommandLine=\""
  1606. << this->EscapeForXML(script.c_str()) << "\"\n"
  1607. << "\t\t\t\t\tAdditionalDependencies=\"";
  1608. if(command.GetDepends().empty())
  1609. {
  1610. // There are no real dependencies. Produce an artificial one to
  1611. // make sure the rule runs reliably.
  1612. if(!cmSystemTools::FileExists(source))
  1613. {
  1614. std::ofstream depout(source);
  1615. depout << "Artificial dependency for a custom command.\n";
  1616. }
  1617. fout << this->ConvertToXMLOutputPath(source);
  1618. }
  1619. else
  1620. {
  1621. // Write out the dependencies for the rule.
  1622. for(std::vector<std::string>::const_iterator d =
  1623. command.GetDepends().begin();
  1624. d != command.GetDepends().end();
  1625. ++d)
  1626. {
  1627. // Get the real name of the dependency in case it is a CMake target.
  1628. std::string dep;
  1629. if(this->GetRealDependency(d->c_str(), i->c_str(), dep))
  1630. {
  1631. fout << this->ConvertToXMLOutputPath(dep.c_str())
  1632. << ";";
  1633. }
  1634. }
  1635. }
  1636. fout << "\"\n";
  1637. fout << "\t\t\t\t\tOutputs=\"";
  1638. if(command.GetOutputs().empty())
  1639. {
  1640. fout << source << "_force";
  1641. }
  1642. else
  1643. {
  1644. // Write a rule for the output generated by this command.
  1645. const char* sep = "";
  1646. for(std::vector<std::string>::const_iterator o =
  1647. command.GetOutputs().begin();
  1648. o != command.GetOutputs().end();
  1649. ++o)
  1650. {
  1651. fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str());
  1652. sep = ";";
  1653. }
  1654. }
  1655. fout << "\"/>\n";
  1656. fout << "\t\t\t\t</FileConfiguration>\n";
  1657. }
  1658. }
  1659. void cmLocalVisualStudio7Generator::WriteVCProjBeginGroup(std::ostream& fout,
  1660. const char* group,
  1661. const char* )
  1662. {
  1663. fout << "\t\t<Filter\n"
  1664. << "\t\t\tName=\"" << group << "\"\n"
  1665. << "\t\t\tFilter=\"\">\n";
  1666. }
  1667. void cmLocalVisualStudio7Generator::WriteVCProjEndGroup(std::ostream& fout)
  1668. {
  1669. fout << "\t\t</Filter>\n";
  1670. }
  1671. // look for custom rules on a target and collect them together
  1672. void cmLocalVisualStudio7Generator
  1673. ::OutputTargetRules(std::ostream& fout,
  1674. const char* configName,
  1675. cmTarget &target,
  1676. const char * /*libName*/)
  1677. {
  1678. if (target.GetType() > cmTarget::GLOBAL_TARGET)
  1679. {
  1680. return;
  1681. }
  1682. EventWriter event(this, configName, fout);
  1683. // Add pre-build event.
  1684. const char* tool =
  1685. this->FortranProject? "VFPreBuildEventTool":"VCPreBuildEventTool";
  1686. event.Start(tool);
  1687. event.Write(target.GetPreBuildCommands());
  1688. event.Finish();
  1689. // Add pre-link event.
  1690. tool = this->FortranProject? "VFPreLinkEventTool":"VCPreLinkEventTool";
  1691. event.Start(tool);
  1692. event.Write(target.GetPreLinkCommands());
  1693. cmsys::auto_ptr<cmCustomCommand> pcc(
  1694. this->MaybeCreateImplibDir(target, configName, this->FortranProject));
  1695. if(pcc.get())
  1696. {
  1697. event.Write(*pcc);
  1698. }
  1699. event.Finish();
  1700. // Add post-build event.
  1701. tool = this->FortranProject? "VFPostBuildEventTool":"VCPostBuildEventTool";
  1702. event.Start(tool);
  1703. event.Write(target.GetPostBuildCommands());
  1704. event.Finish();
  1705. }
  1706. void cmLocalVisualStudio7Generator::WriteProjectSCC(std::ostream& fout,
  1707. cmTarget& target)
  1708. {
  1709. // if we have all the required Source code control tags
  1710. // then add that to the project
  1711. const char* vsProjectname = target.GetProperty("VS_SCC_PROJECTNAME");
  1712. const char* vsLocalpath = target.GetProperty("VS_SCC_LOCALPATH");
  1713. const char* vsProvider = target.GetProperty("VS_SCC_PROVIDER");
  1714. if(vsProvider && vsLocalpath && vsProjectname)
  1715. {
  1716. fout << "\tSccProjectName=\"" << vsProjectname << "\"\n"
  1717. << "\tSccLocalPath=\"" << vsLocalpath << "\"\n"
  1718. << "\tSccProvider=\"" << vsProvider << "\"\n";
  1719. const char* vsAuxPath = target.GetProperty("VS_SCC_AUXPATH");
  1720. if(vsAuxPath)
  1721. {
  1722. fout << "\tSccAuxPath=\"" << vsAuxPath << "\"\n";
  1723. }
  1724. }
  1725. }
  1726. void
  1727. cmLocalVisualStudio7Generator
  1728. ::WriteProjectStartFortran(std::ostream& fout,
  1729. const char *libName,
  1730. cmTarget & target)
  1731. {
  1732. cmGlobalVisualStudio7Generator* gg =
  1733. static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
  1734. // Compute the version of the Intel plugin to the VS IDE.
  1735. // If the key does not exist then use a default guess.
  1736. std::string intelVersion = "9.10";
  1737. std::string vskey = gg->GetRegistryBase();
  1738. vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion";
  1739. cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion,
  1740. cmSystemTools::KeyWOW64_32);
  1741. if (intelVersion.find("12") == 0 || (intelVersion.find("11") == 0))
  1742. {
  1743. // Version 11.x and 12.x actually use 11.0 in project files!
  1744. intelVersion = "11.0" ;
  1745. }
  1746. else if(intelVersion.find("10") == 0)
  1747. {
  1748. // Version 10.x actually uses 9.10 in project files!
  1749. intelVersion = "9.10";
  1750. }
  1751. fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
  1752. << "<VisualStudioProject\n"
  1753. << "\tProjectCreator=\"Intel Fortran\"\n"
  1754. << "\tVersion=\"" << intelVersion << "\"\n";
  1755. const char* keyword = target.GetProperty("VS_KEYWORD");
  1756. if(!keyword)
  1757. {
  1758. keyword = "Console Application";
  1759. }
  1760. const char* projectType = 0;
  1761. switch(target.GetType())
  1762. {
  1763. case cmTarget::STATIC_LIBRARY:
  1764. projectType = "typeStaticLibrary";
  1765. if(keyword)
  1766. {
  1767. keyword = "Static Library";
  1768. }
  1769. break;
  1770. case cmTarget::SHARED_LIBRARY:
  1771. case cmTarget::MODULE_LIBRARY:
  1772. projectType = "typeDynamicLibrary";
  1773. if(!keyword)
  1774. {
  1775. keyword = "Dll";
  1776. }
  1777. break;
  1778. case cmTarget::EXECUTABLE:
  1779. if(!keyword)
  1780. {
  1781. keyword = "Console Application";
  1782. }
  1783. projectType = 0;
  1784. break;
  1785. case cmTarget::UTILITY:
  1786. case cmTarget::GLOBAL_TARGET:
  1787. default:
  1788. break;
  1789. }
  1790. if(projectType)
  1791. {
  1792. fout << "\tProjectType=\"" << projectType << "\"\n";
  1793. }
  1794. this->WriteProjectSCC(fout, target);
  1795. fout<< "\tKeyword=\"" << keyword << "\">\n"
  1796. << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\">\n"
  1797. << "\t<Platforms>\n"
  1798. << "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n"
  1799. << "\t</Platforms>\n";
  1800. }
  1801. void
  1802. cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
  1803. const char *libName,
  1804. cmTarget & target,
  1805. std::vector<cmSourceGroup> &)
  1806. {
  1807. if(this->FortranProject)
  1808. {
  1809. this->WriteProjectStartFortran(fout, libName, target);
  1810. return;
  1811. }
  1812. fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
  1813. << "<VisualStudioProject\n"
  1814. << "\tProjectType=\"Visual C++\"\n";
  1815. if(this->Version == VS71)
  1816. {
  1817. fout << "\tVersion=\"7.10\"\n";
  1818. }
  1819. else
  1820. {
  1821. fout << "\tVersion=\"" << (this->Version/10) << ".00\"\n";
  1822. }
  1823. const char* projLabel = target.GetProperty("PROJECT_LABEL");
  1824. if(!projLabel)
  1825. {
  1826. projLabel = libName;
  1827. }
  1828. const char* keyword = target.GetProperty("VS_KEYWORD");
  1829. if(!keyword)
  1830. {
  1831. keyword = "Win32Proj";
  1832. }
  1833. cmGlobalVisualStudio7Generator* gg =
  1834. static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
  1835. fout << "\tName=\"" << projLabel << "\"\n";
  1836. if(this->Version >= VS8)
  1837. {
  1838. fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n";
  1839. }
  1840. this->WriteProjectSCC(fout, target);
  1841. fout << "\tKeyword=\"" << keyword << "\">\n"
  1842. << "\t<Platforms>\n"
  1843. << "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n"
  1844. << "\t</Platforms>\n";
  1845. }
  1846. void cmLocalVisualStudio7Generator::WriteVCProjFooter(std::ostream& fout,
  1847. cmTarget &target)
  1848. {
  1849. fout << "\t<Globals>\n";
  1850. cmPropertyMap const& props = target.GetProperties();
  1851. for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i)
  1852. {
  1853. if(i->first.find("VS_GLOBAL_") == 0)
  1854. {
  1855. std::string name = i->first.substr(10);
  1856. if(name != "")
  1857. {
  1858. fout << "\t\t<Global\n"
  1859. << "\t\t\tName=\"" << name << "\"\n"
  1860. << "\t\t\tValue=\"" << i->second.GetValue() << "\"\n"
  1861. << "\t\t/>\n";
  1862. }
  1863. }
  1864. }
  1865. fout << "\t</Globals>\n"
  1866. << "</VisualStudioProject>\n";
  1867. }
  1868. std::string cmLocalVisualStudio7GeneratorEscapeForXML(const char* s)
  1869. {
  1870. std::string ret = s;
  1871. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1872. cmSystemTools::ReplaceString(ret, "\"", "&quot;");
  1873. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1874. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1875. cmSystemTools::ReplaceString(ret, "\n", "&#x0D;&#x0A;");
  1876. return ret;
  1877. }
  1878. std::string cmLocalVisualStudio7Generator::EscapeForXML(const char* s)
  1879. {
  1880. return cmLocalVisualStudio7GeneratorEscapeForXML(s);
  1881. }
  1882. std::string cmLocalVisualStudio7Generator
  1883. ::ConvertToXMLOutputPath(const char* path)
  1884. {
  1885. std::string ret = this->ConvertToOptionallyRelativeOutputPath(path);
  1886. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1887. cmSystemTools::ReplaceString(ret, "\"", "&quot;");
  1888. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1889. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1890. return ret;
  1891. }
  1892. std::string cmLocalVisualStudio7Generator
  1893. ::ConvertToXMLOutputPathSingle(const char* path)
  1894. {
  1895. std::string ret = this->ConvertToOptionallyRelativeOutputPath(path);
  1896. cmSystemTools::ReplaceString(ret, "\"", "");
  1897. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1898. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1899. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1900. return ret;
  1901. }
  1902. // This class is used to parse an existing vs 7 project
  1903. // and extract the GUID
  1904. class cmVS7XMLParser : public cmXMLParser
  1905. {
  1906. public:
  1907. virtual void EndElement(const char* /* name */)
  1908. {
  1909. }
  1910. virtual void StartElement(const char* name, const char** atts)
  1911. {
  1912. // once the GUID is found do nothing
  1913. if(this->GUID.size())
  1914. {
  1915. return;
  1916. }
  1917. int i =0;
  1918. if(strcmp("VisualStudioProject", name) == 0)
  1919. {
  1920. while(atts[i])
  1921. {
  1922. if(strcmp(atts[i], "ProjectGUID") == 0)
  1923. {
  1924. if(atts[i+1])
  1925. {
  1926. this->GUID = atts[i+1];
  1927. this->GUID = this->GUID.substr(1, this->GUID.size()-2);
  1928. }
  1929. else
  1930. {
  1931. this->GUID = "";
  1932. }
  1933. return;
  1934. }
  1935. ++i;
  1936. }
  1937. }
  1938. }
  1939. int InitializeParser()
  1940. {
  1941. int ret = cmXMLParser::InitializeParser();
  1942. if(ret == 0)
  1943. {
  1944. return ret;
  1945. }
  1946. // visual studio projects have a strange encoding, but it is
  1947. // really utf-8
  1948. XML_SetEncoding(static_cast<XML_Parser>(this->Parser), "utf-8");
  1949. return 1;
  1950. }
  1951. std::string GUID;
  1952. };
  1953. void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID(
  1954. const char* name,
  1955. const char* path)
  1956. {
  1957. cmVS7XMLParser parser;
  1958. parser.ParseFile(path);
  1959. // if we can not find a GUID then create one
  1960. if(parser.GUID.size() == 0)
  1961. {
  1962. cmGlobalVisualStudio7Generator* gg =
  1963. static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
  1964. gg->CreateGUID(name);
  1965. return;
  1966. }
  1967. std::string guidStoreName = name;
  1968. guidStoreName += "_GUID_CMAKE";
  1969. // save the GUID in the cache
  1970. this->GlobalGenerator->GetCMakeInstance()->
  1971. AddCacheEntry(guidStoreName.c_str(),
  1972. parser.GUID.c_str(),
  1973. "Stored GUID",
  1974. cmCacheManager::INTERNAL);
  1975. }
  1976. //----------------------------------------------------------------------------
  1977. std::string cmLocalVisualStudio7Generator
  1978. ::GetTargetDirectory(cmTarget const& target) const
  1979. {
  1980. std::string dir;
  1981. dir += target.GetName();
  1982. dir += ".dir";
  1983. return dir;
  1984. }
  1985. //----------------------------------------------------------------------------
  1986. #include <windows.h>
  1987. static bool cmLVS6G_IsFAT(const char* dir)
  1988. {
  1989. if(dir[0] && dir[1] == ':')
  1990. {
  1991. char volRoot[4] = "_:/";
  1992. volRoot[0] = dir[0];
  1993. char fsName[16];
  1994. if(GetVolumeInformation(volRoot, 0, 0, 0, 0, 0, fsName, 16) &&
  1995. strstr(fsName, "FAT") != 0)
  1996. {
  1997. return true;
  1998. }
  1999. }
  2000. return false;
  2001. }