cmLocalVisualStudio7Generator.cxx 72 KB

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