cmLocalVisualStudio7Generator.cxx 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146
  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, &target);
  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. void cmLocalVisualStudio7Generator::
  1986. GetTargetObjectFileDirectories(cmTarget* target,
  1987. std::vector<std::string>&
  1988. dirs)
  1989. {
  1990. std::string dir = this->Makefile->GetCurrentOutputDirectory();
  1991. dir += "/";
  1992. dir += this->GetTargetDirectory(*target);
  1993. dir += "/";
  1994. dir += this->GetGlobalGenerator()->GetCMakeCFGInitDirectory();
  1995. dirs.push_back(dir);
  1996. }
  1997. //----------------------------------------------------------------------------
  1998. #include <windows.h>
  1999. static bool cmLVS6G_IsFAT(const char* dir)
  2000. {
  2001. if(dir[0] && dir[1] == ':')
  2002. {
  2003. char volRoot[4] = "_:/";
  2004. volRoot[0] = dir[0];
  2005. char fsName[16];
  2006. if(GetVolumeInformation(volRoot, 0, 0, 0, 0, 0, fsName, 16) &&
  2007. strstr(fsName, "FAT") != 0)
  2008. {
  2009. return true;
  2010. }
  2011. }
  2012. return false;
  2013. }