cmLocalVisualStudio7Generator.cxx 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmGlobalVisualStudio7Generator.h"
  14. #include "cmLocalVisualStudio7Generator.h"
  15. #include "cmMakefile.h"
  16. #include "cmSystemTools.h"
  17. #include "cmSourceFile.h"
  18. #include "cmCacheManager.h"
  19. #include "cmake.h"
  20. #include <ctype.h> // for isspace
  21. cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator()
  22. {
  23. this->Version = 7;
  24. this->PlatformName = "Win32";
  25. }
  26. cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator()
  27. {
  28. }
  29. void cmLocalVisualStudio7Generator::Generate()
  30. {
  31. std::set<cmStdString> lang;
  32. lang.insert("C");
  33. lang.insert("CXX");
  34. lang.insert("RC");
  35. lang.insert("IDL");
  36. lang.insert("DEF");
  37. this->CreateCustomTargetsAndCommands(lang);
  38. this->FixGlobalTargets();
  39. this->OutputVCProjFile();
  40. }
  41. void cmLocalVisualStudio7Generator::FixGlobalTargets()
  42. {
  43. // Visual Studio .NET 2003 Service Pack 1 will not run post-build
  44. // commands for targets in which no sources are built. Add dummy
  45. // rules to force these targets to build.
  46. cmTargets &tgts = this->Makefile->GetTargets();
  47. for(cmTargets::iterator l = tgts.begin();
  48. l != tgts.end(); l++)
  49. {
  50. cmTarget& tgt = l->second;
  51. if(tgt.GetType() == cmTarget::GLOBAL_TARGET)
  52. {
  53. std::vector<std::string> no_depends;
  54. cmCustomCommandLine force_command;
  55. force_command.push_back(";");
  56. cmCustomCommandLines force_commands;
  57. force_commands.push_back(force_command);
  58. const char* no_main_dependency = 0;
  59. std::string force = this->Makefile->GetStartOutputDirectory();
  60. force += cmake::GetCMakeFilesDirectory();
  61. force += "/";
  62. force += tgt.GetName();
  63. force += "_force";
  64. this->Makefile->AddCustomCommandToOutput(force.c_str(), no_depends,
  65. no_main_dependency,
  66. force_commands, " ", 0, true);
  67. if(cmSourceFile* file =
  68. this->Makefile->GetSourceFileWithOutput(force.c_str()))
  69. {
  70. tgt.GetSourceFiles().push_back(file);
  71. }
  72. }
  73. }
  74. }
  75. // TODO
  76. // for CommandLine= need to repleace quotes with &quot
  77. // write out configurations
  78. void cmLocalVisualStudio7Generator::OutputVCProjFile()
  79. {
  80. // If not an in source build, then create the output directory
  81. if(strcmp(this->Makefile->GetStartOutputDirectory(),
  82. this->Makefile->GetHomeDirectory()) != 0)
  83. {
  84. if(!cmSystemTools::MakeDirectory
  85. (this->Makefile->GetStartOutputDirectory()))
  86. {
  87. cmSystemTools::Error("Error creating directory ",
  88. this->Makefile->GetStartOutputDirectory());
  89. }
  90. }
  91. this->LibraryOutputPath = "";
  92. if (this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
  93. {
  94. this->LibraryOutputPath =
  95. this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
  96. }
  97. if(this->LibraryOutputPath.size())
  98. {
  99. // make sure there is a trailing slash
  100. if(this->LibraryOutputPath[this->LibraryOutputPath.size()-1] != '/')
  101. {
  102. this->LibraryOutputPath += "/";
  103. }
  104. }
  105. this->ExecutableOutputPath = "";
  106. if (this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
  107. {
  108. this->ExecutableOutputPath =
  109. this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
  110. }
  111. if(this->ExecutableOutputPath.size())
  112. {
  113. // make sure there is a trailing slash
  114. if(this->ExecutableOutputPath[this->ExecutableOutputPath.size()-1] != '/')
  115. {
  116. this->ExecutableOutputPath += "/";
  117. }
  118. }
  119. // Create the VCProj or set of VCProj's for libraries and executables
  120. // clear project names
  121. this->CreatedProjectNames.clear();
  122. // Call TraceVSDependencies on all targets
  123. cmTargets &tgts = this->Makefile->GetTargets();
  124. for(cmTargets::iterator l = tgts.begin();
  125. l != tgts.end(); l++)
  126. {
  127. // Add a rule to regenerate the build system when the target
  128. // specification source changes.
  129. const char* suppRegenRule =
  130. this->Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION");
  131. if (!cmSystemTools::IsOn(suppRegenRule) &&
  132. (strcmp(l->first.c_str(), CMAKE_CHECK_BUILD_SYSTEM_TARGET) != 0))
  133. {
  134. this->AddVCProjBuildRule(l->second);
  135. }
  136. // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
  137. // so don't build a projectfile for it
  138. if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  139. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)
  140. && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0))
  141. {
  142. cmTarget& target = l->second;
  143. target.TraceVSDependencies(target.GetName(), this->Makefile);
  144. }
  145. }
  146. for(cmTargets::iterator l = tgts.begin();
  147. l != tgts.end(); l++)
  148. {
  149. // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
  150. // so don't build a projectfile for it
  151. if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  152. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)
  153. && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0))
  154. {
  155. this->CreateSingleVCProj(l->first.c_str(),l->second);
  156. }
  157. }
  158. }
  159. void cmLocalVisualStudio7Generator
  160. ::CreateSingleVCProj(const char *lname, cmTarget &target)
  161. {
  162. // add to the list of projects
  163. std::string pname = lname;
  164. this->CreatedProjectNames.push_back(pname);
  165. // create the dsp.cmake file
  166. std::string fname;
  167. fname = this->Makefile->GetStartOutputDirectory();
  168. fname += "/";
  169. fname += lname;
  170. fname += ".vcproj";
  171. // save the name of the real dsp file
  172. std::string realVCProj = fname;
  173. fname += ".cmake";
  174. std::ofstream fout(fname.c_str());
  175. if(!fout)
  176. {
  177. cmSystemTools::Error("Error Writing ", fname.c_str());
  178. }
  179. this->WriteVCProjFile(fout,lname,target);
  180. fout.close();
  181. // if the dsp file has changed, then write it.
  182. cmSystemTools::CopyFileIfDifferent(fname.c_str(), realVCProj.c_str());
  183. }
  184. void cmLocalVisualStudio7Generator::AddVCProjBuildRule(cmTarget& tgt)
  185. {
  186. std::string dspname = tgt.GetName();
  187. dspname += ".vcproj.cmake";
  188. const char* dsprule =
  189. this->Makefile->GetRequiredDefinition("CMAKE_COMMAND");
  190. cmCustomCommandLine commandLine;
  191. commandLine.push_back(dsprule);
  192. std::string makefileIn = this->Makefile->GetStartDirectory();
  193. makefileIn += "/";
  194. makefileIn += "CMakeLists.txt";
  195. makefileIn = cmSystemTools::CollapseFullPath(makefileIn.c_str());
  196. std::string comment = "Building Custom Rule ";
  197. comment += makefileIn;
  198. std::string args;
  199. args = "-H";
  200. args += this->Convert(this->Makefile->GetHomeDirectory(),
  201. START_OUTPUT, UNCHANGED, true);
  202. commandLine.push_back(args);
  203. args = "-B";
  204. args +=
  205. this->Convert(this->Makefile->GetHomeOutputDirectory(),
  206. START_OUTPUT, UNCHANGED, true);
  207. commandLine.push_back(args);
  208. std::string configFile =
  209. this->Makefile->GetRequiredDefinition("CMAKE_ROOT");
  210. configFile += "/Templates/CMakeWindowsSystemConfig.cmake";
  211. std::vector<std::string> listFiles = this->Makefile->GetListFiles();
  212. bool found = false;
  213. for(std::vector<std::string>::iterator i = listFiles.begin();
  214. i != listFiles.end(); ++i)
  215. {
  216. if(*i == configFile)
  217. {
  218. found = true;
  219. }
  220. }
  221. if(!found)
  222. {
  223. listFiles.push_back(configFile);
  224. }
  225. cmCustomCommandLines commandLines;
  226. commandLines.push_back(commandLine);
  227. const char* no_working_directory = 0;
  228. this->Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles,
  229. makefileIn.c_str(), commandLines,
  230. comment.c_str(),
  231. no_working_directory, true);
  232. if(cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str()))
  233. {
  234. tgt.GetSourceFiles().push_back(file);
  235. }
  236. else
  237. {
  238. cmSystemTools::Error("Error adding rule for ", makefileIn.c_str());
  239. }
  240. }
  241. void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout,
  242. const char *libName,
  243. cmTarget &target)
  244. {
  245. std::vector<std::string> *configs =
  246. static_cast<cmGlobalVisualStudio7Generator *>
  247. (this->GlobalGenerator)->GetConfigurations();
  248. fout << "\t<Configurations>\n";
  249. for( std::vector<std::string>::iterator i = configs->begin();
  250. i != configs->end(); ++i)
  251. {
  252. this->WriteConfiguration(fout, i->c_str(), libName, target);
  253. }
  254. fout << "\t</Configurations>\n";
  255. }
  256. // This is a table mapping XML tag IDE names to command line options
  257. struct cmVS7FlagTable
  258. {
  259. const char* IDEName; // name used in the IDE xml file
  260. const char* commandFlag; // command line flag
  261. const char* comment; // comment
  262. const char* value; // string value
  263. };
  264. // fill the table here currently the comment field is not used for
  265. // anything other than documentation NOTE: Make sure the longer
  266. // commandFlag comes FIRST!
  267. cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] =
  268. {
  269. // option flags (some flags map to the same option)
  270. {"BasicRuntimeChecks", "GZ", "Stack frame checks", "1"},
  271. {"BasicRuntimeChecks", "RTCsu", "Both stack and uninitialized checks", "3"},
  272. {"BasicRuntimeChecks", "RTCs", "Stack frame checks", "1"},
  273. {"BasicRuntimeChecks", "RTCu", "Uninitialized Variables ", "2"},
  274. {"BasicRuntimeChecks", "RTC1", "Both stack and uninitialized checks ", "3"},
  275. {"DebugInformationFormat", "Z7", "debug format", "1"},
  276. {"DebugInformationFormat", "Zd", "debug format", "2"},
  277. {"DebugInformationFormat", "Zi", "debug format", "3"},
  278. {"DebugInformationFormat", "ZI", "debug format", "4"},
  279. {"EnableEnhancedInstructionSet", "arch:SSE2", "Use sse2 instructions", "2"},
  280. {"EnableEnhancedInstructionSet", "arch:SSE", "Use sse instructions", "1"},
  281. {"FavorSizeOrSpeed", "Ot", "Favor fast code", "1"},
  282. {"FavorSizeOrSpeed", "Os", "Favor small code", "2"},
  283. {"CompileAs", "TC", "Compile as c code", "1"},
  284. {"CompileAs", "TP", "Compile as c++ code", "2"},
  285. {"Optimization", "Od", "Non Debug", "0"},
  286. {"Optimization", "O1", "Min Size", "1"},
  287. {"Optimization", "O2", "Max Speed", "2"},
  288. {"Optimization", "Ox", "Max Optimization", "3"},
  289. {"OptimizeForProcessor", "GB", "Blended processor mode", "0"},
  290. {"OptimizeForProcessor", "G5", "Pentium", "1"},
  291. {"OptimizeForProcessor", "G6", "PPro PII PIII", "2"},
  292. {"OptimizeForProcessor", "G7", "Pentium 4 or Athlon", "3"},
  293. {"InlineFunctionExpansion", "Ob0", "no inlines", "0"},
  294. {"InlineFunctionExpansion", "Ob1", "when inline keyword", "1"},
  295. {"InlineFunctionExpansion", "Ob2", "any time you can inline", "2"},
  296. {"RuntimeLibrary", "MTd", "Multithreded debug", "1"},
  297. {"RuntimeLibrary", "MT", "Multithreded", "0"},
  298. {"RuntimeLibrary", "MDd", "Multithreded dll debug", "3"},
  299. {"RuntimeLibrary", "MD", "Multithreded dll", "2"},
  300. {"RuntimeLibrary", "MLd", "Sinble Thread debug", "5"},
  301. {"RuntimeLibrary", "ML", "Sinble Thread", "4"},
  302. {"StructMemberAlignment", "Zp16", "struct align 16 byte ", "5"},
  303. {"StructMemberAlignment", "Zp1", "struct align 1 byte ", "1"},
  304. {"StructMemberAlignment", "Zp2", "struct align 2 byte ", "2"},
  305. {"StructMemberAlignment", "Zp4", "struct align 4 byte ", "3"},
  306. {"StructMemberAlignment", "Zp8", "struct align 8 byte ", "4"},
  307. {"WarningLevel", "W1", "Warning level", "1"},
  308. {"WarningLevel", "W2", "Warning level", "2"},
  309. {"WarningLevel", "W3", "Warning level", "3"},
  310. {"WarningLevel", "W4", "Warning level", "4"},
  311. // boolean flags
  312. {"BufferSecurityCheck", "GS", "Buffer security check", "TRUE"},
  313. {"EnableFibreSafeOptimization", "GT", "OmitFramePointers", "TRUE"},
  314. {"EnableFunctionLevelLinking", "Gy", "EnableFunctionLevelLinking", "TRUE"},
  315. {"EnableIntrinsicFunctions", "Oi", "EnableIntrinsicFunctions", "TRUE"},
  316. {"ExceptionHandling", "EHsc", "enable c++ exceptions", "TRUE"},
  317. {"ExceptionHandling", "EHa", "enable c++ exceptions", "2"},
  318. {"ExceptionHandling", "GX", "enable c++ exceptions", "TRUE"},
  319. {"GlobalOptimizations", "Og", "Global Optimize", "TRUE"},
  320. {"ImproveFloatingPointConsistency", "Op",
  321. "ImproveFloatingPointConsistency", "TRUE"},
  322. {"MinimalRebuild", "Gm", "minimal rebuild", "TRUE"},
  323. {"OmitFramePointers", "Oy", "OmitFramePointers", "TRUE"},
  324. {"OptimizeForWindowsApplication", "GA", "Optimize for windows", "TRUE"},
  325. {"RuntimeTypeInfo", "GR",
  326. "Turn on Run time type information for c++", "TRUE"},
  327. {"SmallerTypeCheck", "RTCc", "smaller type check", "TRUE"},
  328. {"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "TRUE"},
  329. {"WarnAsError", "WX", "Treat warnings as errors", "TRUE"},
  330. {0,0,0,0 }
  331. };
  332. cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] =
  333. {
  334. // option flags (some flags map to the same option)
  335. {"GenerateManifest", "MANIFEST:NO", "disable manifest generation", "FALSE"},
  336. {"GenerateManifest", "MANIFEST", "enable manifest generation", "TRUE"},
  337. {"LinkIncremental", "INCREMENTAL:NO", "link incremental", "1"},
  338. {"LinkIncremental", "INCREMENTAL:YES", "link incremental", "2"},
  339. {"IgnoreDefaultLibraryNames", "NODEFAULTLIB:", "USER_VALUE", ""},
  340. {0,0,0,0 }
  341. };
  342. void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
  343. const char* configName,
  344. const char *libName,
  345. cmTarget &target)
  346. {
  347. // create a map of xml tags to the values they should have in the output
  348. // for example, "BufferSecurityCheck" = "TRUE"
  349. // first fill this table with the values for the configuration
  350. // Debug, Release, etc,
  351. // Then parse the command line flags specified in CMAKE_CXX_FLAGS
  352. // and CMAKE_C_FLAGS
  353. // and overwrite or add new values to this map
  354. std::map<cmStdString, cmStdString> flagMap;
  355. // since the default is on for this, but if /EHsc is found
  356. // in the flags it will be turned on and we have /EHSC on by
  357. // default in the CXX flags, then this is the only way to turn this off
  358. flagMap["ExceptionHandling"] = "FALSE";
  359. const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG");
  360. if(!mfcFlag)
  361. {
  362. mfcFlag = "0";
  363. }
  364. fout << "\t\t<Configuration\n"
  365. << "\t\t\tName=\"" << configName << "|" << this->PlatformName << "\"\n"
  366. << "\t\t\tOutputDirectory=\"" << configName << "\"\n";
  367. // This is an internal type to Visual Studio, it seems that:
  368. // 4 == static library
  369. // 2 == dll
  370. // 1 == executable
  371. // 10 == utility
  372. const char* configType = "10";
  373. switch(target.GetType())
  374. {
  375. case cmTarget::STATIC_LIBRARY:
  376. configType = "4";
  377. break;
  378. case cmTarget::SHARED_LIBRARY:
  379. case cmTarget::MODULE_LIBRARY:
  380. configType = "2";
  381. break;
  382. case cmTarget::EXECUTABLE:
  383. configType = "1";
  384. break;
  385. case cmTarget::UTILITY:
  386. case cmTarget::GLOBAL_TARGET:
  387. configType = "10";
  388. default:
  389. break;
  390. }
  391. std::string flags;
  392. if(strcmp(configType, "10") != 0)
  393. {
  394. const char* linkLanguage =
  395. target.GetLinkerLanguage(this->GetGlobalGenerator());
  396. if(!linkLanguage)
  397. {
  398. cmSystemTools::Error
  399. ("CMake can not determine linker language for target:",
  400. target.GetName());
  401. return;
  402. }
  403. if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0)
  404. {
  405. std::string baseFlagVar = "CMAKE_";
  406. baseFlagVar += linkLanguage;
  407. baseFlagVar += "_FLAGS";
  408. flags = this->Makefile->GetRequiredDefinition(baseFlagVar.c_str());
  409. std::string flagVar = baseFlagVar + std::string("_") +
  410. cmSystemTools::UpperCase(configName);
  411. flags += " ";
  412. flags += this->Makefile->GetRequiredDefinition(flagVar.c_str());
  413. }
  414. // set the correct language
  415. if(strcmp(linkLanguage, "C") == 0)
  416. {
  417. flags += " /TC ";
  418. }
  419. if(strcmp(linkLanguage, "CXX") == 0)
  420. {
  421. flags += " /TP ";
  422. }
  423. }
  424. // Add the target-specific flags.
  425. if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
  426. {
  427. flags += " ";
  428. flags += targetFlags;
  429. }
  430. // The intermediate directory name consists of a directory for the
  431. // target and a subdirectory for the configuration name.
  432. std::string intermediateDir = this->GetTargetDirectory(target);
  433. intermediateDir += "/";
  434. intermediateDir += configName;
  435. fout << "\t\t\tIntermediateDirectory=\""
  436. << this->ConvertToXMLOutputPath(intermediateDir.c_str())
  437. << "\"\n"
  438. << "\t\t\tConfigurationType=\"" << configType << "\"\n"
  439. << "\t\t\tUseOfMFC=\"" << mfcFlag << "\"\n"
  440. << "\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n";
  441. // if -D_UNICODE or /D_UNICODE is found in the flags
  442. // change the character set to unicode, if not then
  443. // default to MBCS
  444. std::string defs = this->Makefile->GetDefineFlags();
  445. if(flags.find("D_UNICODE") != flags.npos ||
  446. defs.find("D_UNICODE") != flags.npos)
  447. {
  448. fout << "\t\t\tCharacterSet=\"1\">\n";
  449. }
  450. else
  451. {
  452. fout << "\t\t\tCharacterSet=\"2\">\n";
  453. }
  454. fout << "\t\t\t<Tool\n"
  455. << "\t\t\t\tName=\"VCCLCompilerTool\"\n"
  456. << "\t\t\t\tAdditionalOptions=\"";
  457. // now fill the flagMap from the command line flags, and
  458. // if a flag is used, it will be removed from the flags string by
  459. // this function call
  460. this->FillFlagMapFromCommandFlags
  461. (flagMap, &cmLocalVisualStudio7GeneratorFlagTable[0], flags);
  462. std::string defineFlags = this->Makefile->GetDefineFlags();
  463. // now check the define flags for flags other than -D and
  464. // put them in the map, the -D flags will be left in the defineFlags
  465. // variable as -D is not in the flagMap
  466. this->FillFlagMapFromCommandFlags
  467. (flagMap, &cmLocalVisualStudio7GeneratorFlagTable[0], defineFlags);
  468. // output remaining flags that were not mapped to anything
  469. fout << this->EscapeForXML(flags.c_str()).c_str();
  470. fout << " -DCMAKE_INTDIR=\\&quot;" << configName << "\\&quot;"
  471. << "\"\n";
  472. fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
  473. std::vector<std::string> includes;
  474. this->GetIncludeDirectories(includes);
  475. std::vector<std::string>::iterator i = includes.begin();
  476. for(;i != includes.end(); ++i)
  477. {
  478. std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
  479. fout << ipath << ";";
  480. }
  481. fout << "\"\n";
  482. // set a few cmake specific flags
  483. if(this->Makefile->IsOn("CMAKE_CXX_USE_RTTI"))
  484. {
  485. flagMap["RuntimeTypeInfo"] = "TRUE";
  486. }
  487. if ( this->Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL") )
  488. {
  489. flagMap["WarningLevel"] =
  490. this->Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL");
  491. }
  492. // Now copy the flag map into the xml for the file
  493. for(std::map<cmStdString, cmStdString>::iterator m = flagMap.begin();
  494. m != flagMap.end(); ++m)
  495. {
  496. fout << "\t\t\t\t" << m->first << "=\"" << m->second << "\"\n";
  497. }
  498. fout << "\t\t\t\tPreprocessorDefinitions=\"";
  499. if(target.GetType() == cmTarget::SHARED_LIBRARY
  500. || target.GetType() == cmTarget::MODULE_LIBRARY)
  501. {
  502. std::string exportSymbol;
  503. if (const char* custom_export_name =
  504. target.GetProperty("DEFINE_SYMBOL"))
  505. {
  506. exportSymbol = custom_export_name;
  507. }
  508. else
  509. {
  510. std::string id = libName;
  511. id += "_EXPORTS";
  512. exportSymbol = cmSystemTools::MakeCindentifier(id.c_str());
  513. }
  514. fout << "," << exportSymbol;
  515. }
  516. this->OutputDefineFlags(defineFlags.c_str(), fout);
  517. fout << "\"\n";
  518. fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n";
  519. fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
  520. std::map<cmStdString, cmStdString>::iterator mi =
  521. flagMap.find("DebugInformationFormat");
  522. if(mi != flagMap.end() && mi->second != "1")
  523. {
  524. fout << "\t\t\t\tProgramDataBaseFileName=\""
  525. << this->LibraryOutputPath
  526. << "$(OutDir)/" << libName << ".pdb\"\n";
  527. }
  528. fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
  529. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n";
  530. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n"
  531. << "\t\t\t\tAdditionalIncludeDirectories=\"";
  532. for(i = includes.begin();i != includes.end(); ++i)
  533. {
  534. std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
  535. fout << ipath << ";";
  536. }
  537. // add the -D flags to the RC tool
  538. fout << "\"\n"
  539. << "\t\t\t\tPreprocessorDefinitions=\"";
  540. this->OutputDefineFlags(defineFlags.c_str(), fout);
  541. fout << "\" />\n";
  542. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n";
  543. fout << "\t\t\t\tPreprocessorDefinitions=\"";
  544. this->OutputDefineFlags(defineFlags.c_str(), fout);
  545. fout << "\"\n";
  546. fout << "\t\t\t\tMkTypLibCompatible=\"FALSE\"\n";
  547. if( this->PlatformName == "x64" )
  548. {
  549. fout << "\t\t\t\tTargetEnvironment=\"3\"\n";
  550. }
  551. else if( this->PlatformName == "ia64" )
  552. {
  553. fout << "\t\t\t\tTargetEnvironment=\"2\"\n";
  554. }
  555. else
  556. {
  557. fout << "\t\t\t\tTargetEnvironment=\"1\"\n";
  558. }
  559. fout << "\t\t\t\tGenerateStublessProxies=\"TRUE\"\n";
  560. fout << "\t\t\t\tTypeLibraryName=\"$(InputName).tlb\"\n";
  561. fout << "\t\t\t\tOutputDirectory=\"$(IntDir)\"\n";
  562. fout << "\t\t\t\tHeaderFileName=\"$(InputName).h\"\n";
  563. fout << "\t\t\t\tDLLDataFileName=\"\"\n";
  564. fout << "\t\t\t\tInterfaceIdentifierFileName=\"$(InputName)_i.c\"\n";
  565. fout << "\t\t\t\tProxyFileName=\"$(InputName)_p.c\"/>\n";
  566. // end of <Tool Name=VCMIDLTool
  567. // If we are building a version 8 project file, add a flag telling the
  568. // manifest tool to use a workaround for FAT32 file systems, which can cause
  569. // an empty manifest to be embedded into the resulting executable.
  570. // See CMake bug #2617.
  571. if ( this->Version == 8 )
  572. {
  573. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCManifestTool\"\n"
  574. << "\t\t\t\tUseFAT32Workaround=\"true\"\n"
  575. << "\t\t\t/>\n";
  576. }
  577. this->OutputTargetRules(fout, target, libName);
  578. this->OutputBuildTool(fout, configName, libName, target);
  579. fout << "\t\t</Configuration>\n";
  580. }
  581. void cmLocalVisualStudio7Generator::ReplaceFlagSetMap(std::string& flags,
  582. cmVS7FlagTable*
  583. flagTable,
  584. std::map<cmStdString,
  585. cmStdString>& flagMap,
  586. std::string& option,
  587. std::string::size_type
  588. pos)
  589. {
  590. std::string value = flagTable->value;
  591. if(strcmp(flagTable->comment, "USER_VALUE") == 0)
  592. {
  593. std::string::size_type len = flags.find(" ", pos);
  594. if(len != flags.npos)
  595. {
  596. len -= option.size();
  597. }
  598. value = flags.substr(pos+option.size(), len);
  599. std::string fullflag = option;
  600. fullflag += value;
  601. // remove everything
  602. cmSystemTools::ReplaceString(flags, fullflag.c_str(), "");
  603. }
  604. else
  605. {
  606. cmSystemTools::ReplaceString(flags, option.c_str(), "");
  607. }
  608. // now put value into flag map
  609. flagMap[flagTable->IDEName] = value;
  610. }
  611. void cmLocalVisualStudio7Generator::FillFlagMapFromCommandFlags(
  612. std::map<cmStdString, cmStdString>& flagMap,
  613. cmVS7FlagTable* flagTable,
  614. std::string& flags)
  615. {
  616. std::string replace;
  617. std::string option;
  618. while(flagTable->IDEName)
  619. {
  620. option.reserve(strlen(flagTable->commandFlag)+2);
  621. // first do the - version
  622. option = "-";
  623. option += flagTable->commandFlag;
  624. std::string::size_type pos = flags.find(option);
  625. while(pos != flags.npos)
  626. {
  627. this->ReplaceFlagSetMap(flags, flagTable, flagMap,
  628. option, pos);
  629. pos = flags.find(option);
  630. }
  631. // now do the / version
  632. option[0] = '/';
  633. pos = flags.find(option);
  634. while(pos != flags.npos)
  635. {
  636. this->ReplaceFlagSetMap(flags, flagTable, flagMap,
  637. option, pos);
  638. pos = flags.find(option);
  639. }
  640. // move to next flag
  641. flagTable++;
  642. }
  643. // If verbose makefiles have been requested and the /nologo option
  644. // was not given explicitly in the flags we want to add an attribute
  645. // to the generated project to disable logo suppression. Otherwise
  646. // the GUI default is to enable suppression.
  647. if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"))
  648. {
  649. if(flagMap.find("SuppressStartupBanner") == flagMap.end())
  650. {
  651. flagMap["SuppressStartupBanner"] = "FALSE";
  652. }
  653. }
  654. }
  655. //----------------------------------------------------------------------------
  656. std::string
  657. cmLocalVisualStudio7Generator
  658. ::GetBuildTypeLinkerFlags(std::string rootLinkerFlags, const char* configName)
  659. {
  660. std::string configTypeUpper = cmSystemTools::UpperCase(configName);
  661. std::string extraLinkOptionsBuildTypeDef =
  662. rootLinkerFlags + "_" + configTypeUpper;
  663. std::string extraLinkOptionsBuildType =
  664. this->Makefile->GetRequiredDefinition
  665. (extraLinkOptionsBuildTypeDef.c_str());
  666. return extraLinkOptionsBuildType;
  667. }
  668. void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
  669. const char* configName,
  670. const char *libName,
  671. cmTarget &target)
  672. {
  673. std::string targetFullName = target.GetFullName(configName);
  674. std::string temp;
  675. std::string extraLinkOptions;
  676. if(target.GetType() == cmTarget::EXECUTABLE)
  677. {
  678. extraLinkOptions =
  679. this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS")
  680. + std::string(" ")
  681. + GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName);
  682. }
  683. if(target.GetType() == cmTarget::SHARED_LIBRARY)
  684. {
  685. extraLinkOptions =
  686. this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS")
  687. + std::string(" ")
  688. + GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName);
  689. }
  690. if(target.GetType() == cmTarget::MODULE_LIBRARY)
  691. {
  692. extraLinkOptions =
  693. this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS")
  694. + std::string(" ")
  695. + GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName);
  696. }
  697. const char* targetLinkFlags = target.GetProperty("LINK_FLAGS");
  698. if(targetLinkFlags)
  699. {
  700. extraLinkOptions += " ";
  701. extraLinkOptions += targetLinkFlags;
  702. }
  703. std::string configTypeUpper = cmSystemTools::UpperCase(configName);
  704. std::string linkFlagsConfig = "LINK_FLAGS_";
  705. linkFlagsConfig += configTypeUpper;
  706. targetLinkFlags = target.GetProperty(linkFlagsConfig.c_str());
  707. if(targetLinkFlags)
  708. {
  709. extraLinkOptions += " ";
  710. extraLinkOptions += targetLinkFlags;
  711. }
  712. std::map<cmStdString, cmStdString> flagMap;
  713. this->FillFlagMapFromCommandFlags
  714. (flagMap, &cmLocalVisualStudio7GeneratorLinkFlagTable[0],
  715. extraLinkOptions);
  716. switch(target.GetType())
  717. {
  718. case cmTarget::STATIC_LIBRARY:
  719. {
  720. std::string libpath = this->LibraryOutputPath +
  721. "$(OutDir)/" + targetFullName;
  722. fout << "\t\t\t<Tool\n"
  723. << "\t\t\t\tName=\"VCLibrarianTool\"\n";
  724. if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
  725. {
  726. fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
  727. }
  728. fout << "\t\t\t\tOutputFile=\""
  729. << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << "\"/>\n";
  730. break;
  731. }
  732. case cmTarget::SHARED_LIBRARY:
  733. case cmTarget::MODULE_LIBRARY:
  734. {
  735. // Compute the link library and directory information.
  736. std::vector<cmStdString> linkLibs;
  737. std::vector<cmStdString> linkDirs;
  738. this->ComputeLinkInformation(target, configName, linkLibs, linkDirs);
  739. // Get the language to use for linking.
  740. const char* linkLanguage =
  741. target.GetLinkerLanguage(this->GetGlobalGenerator());
  742. if(!linkLanguage)
  743. {
  744. cmSystemTools::Error
  745. ("CMake can not determine linker language for target:",
  746. target.GetName());
  747. return;
  748. }
  749. // Compute the variable name to lookup standard libraries for this
  750. // language.
  751. std::string standardLibsVar = "CMAKE_";
  752. standardLibsVar += linkLanguage;
  753. standardLibsVar += "_STANDARD_LIBRARIES";
  754. fout << "\t\t\t<Tool\n"
  755. << "\t\t\t\tName=\"VCLinkerTool\"\n"
  756. << "\t\t\t\tAdditionalOptions=\"/MACHINE:I386";
  757. if(extraLinkOptions.size())
  758. {
  759. fout << " " << cmLocalVisualStudio7Generator::EscapeForXML(
  760. extraLinkOptions.c_str()).c_str();
  761. }
  762. // Use the NOINHERIT macro to avoid getting VS project default
  763. // libraries which may be set by the user to something bad.
  764. fout << "\"\n"
  765. << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
  766. << this->Makefile->GetSafeDefinition(standardLibsVar.c_str())
  767. << " ";
  768. this->OutputLibraries(fout, linkLibs);
  769. fout << "\"\n";
  770. temp = this->LibraryOutputPath;
  771. temp += configName;
  772. temp += "/";
  773. temp += targetFullName;
  774. fout << "\t\t\t\tOutputFile=\""
  775. << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  776. this->WriteTargetVersionAttribute(fout, target);
  777. for(std::map<cmStdString, cmStdString>::iterator i = flagMap.begin();
  778. i != flagMap.end(); ++i)
  779. {
  780. fout << "\t\t\t\t" << i->first << "=\"" << i->second << "\"\n";
  781. }
  782. fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
  783. this->OutputLibraryDirectories(fout, linkDirs);
  784. fout << "\"\n";
  785. this->OutputModuleDefinitionFile(fout, target);
  786. temp = this->LibraryOutputPath;
  787. temp += "$(OutDir)/";
  788. temp += libName;
  789. temp += ".pdb";
  790. fout << "\t\t\t\tProgramDataBaseFile=\"" <<
  791. this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  792. if(strcmp(configName, "Debug") == 0
  793. || strcmp(configName, "RelWithDebInfo") == 0)
  794. {
  795. fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
  796. }
  797. std::string stackVar = "CMAKE_";
  798. stackVar += linkLanguage;
  799. stackVar += "_STACK_SIZE";
  800. const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
  801. if(stackVal)
  802. {
  803. fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n";
  804. }
  805. temp = this->LibraryOutputPath;
  806. temp += configName;
  807. temp += "/";
  808. temp +=
  809. cmSystemTools::GetFilenameWithoutLastExtension(targetFullName.c_str());
  810. temp += ".lib";
  811. fout << "\t\t\t\tImportLibrary=\""
  812. << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n";
  813. }
  814. break;
  815. case cmTarget::EXECUTABLE:
  816. {
  817. // Compute the link library and directory information.
  818. std::vector<cmStdString> linkLibs;
  819. std::vector<cmStdString> linkDirs;
  820. this->ComputeLinkInformation(target, configName, linkLibs, linkDirs);
  821. // Get the language to use for linking.
  822. const char* linkLanguage =
  823. target.GetLinkerLanguage(this->GetGlobalGenerator());
  824. if(!linkLanguage)
  825. {
  826. cmSystemTools::Error
  827. ("CMake can not determine linker language for target:",
  828. target.GetName());
  829. return;
  830. }
  831. // Compute the variable name to lookup standard libraries for this
  832. // language.
  833. std::string standardLibsVar = "CMAKE_";
  834. standardLibsVar += linkLanguage;
  835. standardLibsVar += "_STANDARD_LIBRARIES";
  836. fout << "\t\t\t<Tool\n"
  837. << "\t\t\t\tName=\"VCLinkerTool\"\n"
  838. << "\t\t\t\tAdditionalOptions=\"";
  839. if(extraLinkOptions.size())
  840. {
  841. fout << " " << cmLocalVisualStudio7Generator::EscapeForXML(
  842. extraLinkOptions.c_str()).c_str();
  843. }
  844. // Use the NOINHERIT macro to avoid getting VS project default
  845. // libraries which may be set by the user to something bad.
  846. fout << "\"\n"
  847. << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
  848. << this->Makefile->GetSafeDefinition(standardLibsVar.c_str())
  849. << " ";
  850. this->OutputLibraries(fout, linkLibs);
  851. fout << "\"\n";
  852. temp = this->ExecutableOutputPath;
  853. temp += configName;
  854. temp += "/";
  855. temp += targetFullName;
  856. fout << "\t\t\t\tOutputFile=\""
  857. << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
  858. this->WriteTargetVersionAttribute(fout, target);
  859. for(std::map<cmStdString, cmStdString>::iterator i = flagMap.begin();
  860. i != flagMap.end(); ++i)
  861. {
  862. fout << "\t\t\t\t" << i->first << "=\"" << i->second << "\"\n";
  863. }
  864. fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
  865. this->OutputLibraryDirectories(fout, linkDirs);
  866. fout << "\"\n";
  867. fout << "\t\t\t\tProgramDataBaseFile=\"" << this->LibraryOutputPath
  868. << "$(OutDir)\\" << libName << ".pdb\"\n";
  869. if(strcmp(configName, "Debug") == 0
  870. || strcmp(configName, "RelWithDebInfo") == 0)
  871. {
  872. fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
  873. }
  874. if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") )
  875. {
  876. fout << "\t\t\t\tSubSystem=\"2\"\n";
  877. }
  878. else
  879. {
  880. fout << "\t\t\t\tSubSystem=\"1\"\n";
  881. }
  882. std::string stackVar = "CMAKE_";
  883. stackVar += linkLanguage;
  884. stackVar += "_STACK_SIZE";
  885. const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
  886. if(stackVal)
  887. {
  888. fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"";
  889. }
  890. fout << "/>\n";
  891. break;
  892. }
  893. case cmTarget::UTILITY:
  894. case cmTarget::GLOBAL_TARGET:
  895. break;
  896. }
  897. }
  898. //----------------------------------------------------------------------------
  899. void
  900. cmLocalVisualStudio7Generator
  901. ::WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target)
  902. {
  903. int major;
  904. int minor;
  905. target.GetTargetVersion(major, minor);
  906. fout << "\t\t\t\tVersion=\"" << major << "." << minor << "\"\n";
  907. }
  908. void cmLocalVisualStudio7Generator
  909. ::OutputModuleDefinitionFile(std::ostream& fout,
  910. cmTarget &target)
  911. {
  912. std::vector<cmSourceFile*> const& classes = target.GetSourceFiles();
  913. for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
  914. i != classes.end(); i++)
  915. {
  916. if(cmSystemTools::UpperCase((*i)->GetSourceExtension()) == "DEF")
  917. {
  918. fout << "\t\t\t\tModuleDefinitionFile=\""
  919. << this->ConvertToXMLOutputPath((*i)->GetFullPath().c_str())
  920. << "\"\n";
  921. return;
  922. }
  923. }
  924. }
  925. //----------------------------------------------------------------------------
  926. void
  927. cmLocalVisualStudio7Generator
  928. ::OutputLibraries(std::ostream& fout,
  929. std::vector<cmStdString> const& libs)
  930. {
  931. for(std::vector<cmStdString>::const_iterator l = libs.begin();
  932. l != libs.end(); ++l)
  933. {
  934. fout << this->ConvertToXMLOutputPath(l->c_str()) << " ";
  935. }
  936. }
  937. //----------------------------------------------------------------------------
  938. void
  939. cmLocalVisualStudio7Generator
  940. ::OutputLibraryDirectories(std::ostream& fout,
  941. std::vector<cmStdString> const& dirs)
  942. {
  943. const char* comma = "";
  944. for(std::vector<cmStdString>::const_iterator d = dirs.begin();
  945. d != dirs.end(); ++d)
  946. {
  947. // Remove any trailing slash and skip empty paths.
  948. std::string dir = *d;
  949. if(dir[dir.size()-1] == '/')
  950. {
  951. dir = dir.substr(0, dir.size()-1);
  952. }
  953. if(dir.empty())
  954. {
  955. continue;
  956. }
  957. // Switch to a relative path specification if it is shorter.
  958. if(cmSystemTools::FileIsFullPath(dir.c_str()))
  959. {
  960. std::string rel = this->Convert(dir.c_str(), START_OUTPUT, UNCHANGED);
  961. if(rel.size() < dir.size())
  962. {
  963. dir = rel;
  964. }
  965. }
  966. // First search a configuration-specific subdirectory and then the
  967. // original directory.
  968. fout << comma << this->ConvertToXMLOutputPath((dir+"/$(OutDir)").c_str())
  969. << "," << this->ConvertToXMLOutputPath(dir.c_str());
  970. comma = ",";
  971. }
  972. }
  973. //----------------------------------------------------------------------------
  974. void cmLocalVisualStudio7Generator::OutputDefineFlags(const char* flags,
  975. std::ostream& fout)
  976. {
  977. std::string defs = flags;
  978. cmSystemTools::ReplaceString(defs, "/D","-D");
  979. std::string::size_type pos = defs.find("-D");
  980. bool done = pos == std::string::npos;
  981. if(!done)
  982. {
  983. fout << ",";
  984. }
  985. while(!done)
  986. {
  987. std::string::size_type nextpos = defs.find("-D", pos+2);
  988. std::string define;
  989. if(nextpos != std::string::npos)
  990. {
  991. define = defs.substr(pos+2, nextpos - pos -3);
  992. }
  993. else
  994. {
  995. define = defs.substr(pos+2);
  996. done = true;
  997. }
  998. // Remove trailing whitespace from the definition.
  999. while(!define.empty() && isspace(define[define.size()-1]))
  1000. {
  1001. define = define.substr(0, define.size()-1);
  1002. }
  1003. // Double-quotes in the value of the definition must be escaped
  1004. // with a backslash. The entire definition should be quoted in
  1005. // the generated xml attribute to avoid confusing the VS parser.
  1006. define = this->EscapeForXML(define.c_str());
  1007. // if the define has something in it that is not a letter or a number
  1008. // then quote it
  1009. if(define.
  1010. find_first_not_of(
  1011. "-_abcdefghigklmnopqrstuvwxyz1234567890ABCDEFGHIGKLMNOPQRSTUVWXYZ")
  1012. != define.npos)
  1013. {
  1014. fout << "&quot;" << define << "&quot;,";
  1015. }
  1016. else
  1017. {
  1018. fout << define << ",";
  1019. }
  1020. if(!done)
  1021. {
  1022. pos = defs.find("-D", nextpos);
  1023. }
  1024. }
  1025. }
  1026. void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
  1027. const char *libName,
  1028. cmTarget &target)
  1029. {
  1030. // get the configurations
  1031. std::vector<std::string> *configs =
  1032. static_cast<cmGlobalVisualStudio7Generator *>
  1033. (this->GlobalGenerator)->GetConfigurations();
  1034. // trace the visual studio dependencies
  1035. std::string name = libName;
  1036. name += ".vcproj.cmake";
  1037. // We may be modifying the source groups temporarily, so make a copy.
  1038. std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
  1039. // get the classes from the source lists then add them to the groups
  1040. std::vector<cmSourceFile*> & classes = target.GetSourceFiles();
  1041. for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
  1042. i != classes.end(); i++)
  1043. {
  1044. // Add the file to the list of sources.
  1045. std::string source = (*i)->GetFullPath();
  1046. if(cmSystemTools::UpperCase((*i)->GetSourceExtension()) == "DEF")
  1047. {
  1048. this->ModuleDefinitionFile = (*i)->GetFullPath();
  1049. }
  1050. cmSourceGroup& sourceGroup =
  1051. this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
  1052. sourceGroup.AssignSource(*i);
  1053. }
  1054. // Compute which sources need unique object computation.
  1055. this->ComputeObjectNameRequirements(sourceGroups);
  1056. // open the project
  1057. this->WriteProjectStart(fout, libName, target, sourceGroups);
  1058. // write the configuration information
  1059. this->WriteConfigurations(fout, libName, target);
  1060. fout << "\t<Files>\n";
  1061. // Loop through every source group.
  1062. for(unsigned int i = 0; i < sourceGroups.size(); ++i)
  1063. {
  1064. cmSourceGroup sg = sourceGroups[i];
  1065. this->WriteGroup(&sg, target, fout, libName, configs);
  1066. }
  1067. //}
  1068. fout << "\t</Files>\n";
  1069. // Write the VCProj file's footer.
  1070. this->WriteVCProjFooter(fout);
  1071. }
  1072. void cmLocalVisualStudio7Generator
  1073. ::WriteGroup(const cmSourceGroup *sg, cmTarget target,
  1074. std::ostream &fout, const char *libName,
  1075. std::vector<std::string> *configs)
  1076. {
  1077. const std::vector<const cmSourceFile *> &sourceFiles =
  1078. sg->GetSourceFiles();
  1079. // If the group is empty, don't write it at all.
  1080. if(sourceFiles.empty() && sg->GetGroupChildren().empty())
  1081. {
  1082. return;
  1083. }
  1084. // If the group has a name, write the header.
  1085. std::string name = sg->GetName();
  1086. if(name != "")
  1087. {
  1088. this->WriteVCProjBeginGroup(fout, name.c_str(), "");
  1089. }
  1090. // Loop through each source in the source group.
  1091. std::string objectName;
  1092. for(std::vector<const cmSourceFile *>::const_iterator sf =
  1093. sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
  1094. {
  1095. std::string source = (*sf)->GetFullPath();
  1096. const cmCustomCommand *command = (*sf)->GetCustomCommand();
  1097. std::string compileFlags;
  1098. std::string additionalDeps;
  1099. if(this->NeedObjectName.find(*sf) != this->NeedObjectName.end())
  1100. {
  1101. objectName = this->GetObjectFileNameWithoutTarget(*(*sf));
  1102. }
  1103. else
  1104. {
  1105. objectName = "";
  1106. }
  1107. // Add per-source flags.
  1108. const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS");
  1109. if(cflags)
  1110. {
  1111. compileFlags += " ";
  1112. compileFlags += cflags;
  1113. }
  1114. const char* lang = this->GlobalGenerator->GetLanguageFromExtension
  1115. ((*sf)->GetSourceExtension().c_str());
  1116. const char* linkLanguage = target.GetLinkerLanguage
  1117. (this->GetGlobalGenerator());
  1118. // If lang is set, the compiler will generate code automatically.
  1119. // If HEADER_FILE_ONLY is set, we must suppress this generation in
  1120. // the project file
  1121. bool excludedFromBuild =
  1122. (lang && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY"));
  1123. // if the source file does not match the linker language
  1124. // then force c or c++
  1125. if(linkLanguage && lang && strcmp(lang, linkLanguage) != 0)
  1126. {
  1127. if(strcmp(lang, "CXX") == 0)
  1128. {
  1129. // force a C++ file type
  1130. compileFlags += " /TP ";
  1131. }
  1132. else if(strcmp(lang, "C") == 0)
  1133. {
  1134. // force to c
  1135. compileFlags += " /TC ";
  1136. }
  1137. }
  1138. // Check for extra object-file dependencies.
  1139. const char* deps = (*sf)->GetProperty("OBJECT_DEPENDS");
  1140. if(deps)
  1141. {
  1142. std::vector<std::string> depends;
  1143. cmSystemTools::ExpandListArgument(deps, depends);
  1144. if(!depends.empty())
  1145. {
  1146. std::vector<std::string>::iterator i = depends.begin();
  1147. additionalDeps = this->ConvertToXMLOutputPath(i->c_str());
  1148. for(++i;i != depends.end(); ++i)
  1149. {
  1150. additionalDeps += ";";
  1151. additionalDeps += this->ConvertToXMLOutputPath(i->c_str());
  1152. }
  1153. }
  1154. }
  1155. if (source != libName || target.GetType() == cmTarget::UTILITY ||
  1156. target.GetType() == cmTarget::GLOBAL_TARGET )
  1157. {
  1158. fout << "\t\t\t<File\n";
  1159. std::string d = this->ConvertToXMLOutputPathSingle(source.c_str());
  1160. // Tell MS-Dev what the source is. If the compiler knows how to
  1161. // build it, then it will.
  1162. fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
  1163. if (command)
  1164. {
  1165. // Construct the entire set of commands in one string.
  1166. std::string script =
  1167. this->ConstructScript(command->GetCommandLines(),
  1168. command->GetWorkingDirectory(),
  1169. command->GetEscapeOldStyle(),
  1170. command->GetEscapeAllowMakeVars());
  1171. std::string comment = this->ConstructComment(*command);
  1172. const char* flags = compileFlags.size() ? compileFlags.c_str(): 0;
  1173. this->WriteCustomRule(fout, source.c_str(), script.c_str(),
  1174. comment.c_str(), command->GetDepends(),
  1175. command->GetOutputs(), flags);
  1176. }
  1177. else if(compileFlags.size() || additionalDeps.length()
  1178. || objectName.size() || excludedFromBuild)
  1179. {
  1180. const char* aCompilerTool = "VCCLCompilerTool";
  1181. std::string ext = (*sf)->GetSourceExtension();
  1182. ext = cmSystemTools::LowerCase(ext);
  1183. if(ext == "idl")
  1184. {
  1185. aCompilerTool = "VCMIDLTool";
  1186. }
  1187. if(ext == "rc")
  1188. {
  1189. aCompilerTool = "VCResourceCompilerTool";
  1190. }
  1191. if(ext == "def")
  1192. {
  1193. aCompilerTool = "VCCustomBuildTool";
  1194. }
  1195. for(std::vector<std::string>::iterator i = configs->begin();
  1196. i != configs->end(); ++i)
  1197. {
  1198. fout << "\t\t\t\t<FileConfiguration\n"
  1199. << "\t\t\t\t\tName=\"" << *i
  1200. << "|" << this->PlatformName << "\"";
  1201. if(excludedFromBuild)
  1202. {
  1203. fout << " ExcludedFromBuild=\"true\"";
  1204. }
  1205. fout << ">\n";
  1206. fout << "\t\t\t\t\t<Tool\n"
  1207. << "\t\t\t\t\tName=\"" << aCompilerTool << "\"\n";
  1208. if(compileFlags.size())
  1209. {
  1210. std::string compileFlagsCopy = compileFlags;
  1211. std::map<cmStdString, cmStdString> fileFlagMap;
  1212. this->FillFlagMapFromCommandFlags
  1213. (fileFlagMap,
  1214. &cmLocalVisualStudio7GeneratorFlagTable[0],
  1215. compileFlagsCopy);
  1216. if(compileFlagsCopy.size() &&
  1217. compileFlagsCopy.find_first_not_of(" ")
  1218. != compileFlagsCopy.npos)
  1219. {
  1220. fout << "\t\t\t\t\tAdditionalOptions=\""
  1221. << this->EscapeForXML(compileFlagsCopy.c_str()) << "\"\n";
  1222. }
  1223. for(std::map<cmStdString,
  1224. cmStdString>::iterator m = fileFlagMap.begin();
  1225. m != fileFlagMap.end(); ++m)
  1226. {
  1227. fout << "\t\t\t\t\t" << m->first << "=\""
  1228. << m->second << "\"\n";
  1229. }
  1230. }
  1231. if(additionalDeps.length())
  1232. {
  1233. fout << "\t\t\t\t\tAdditionalDependencies=\""
  1234. << additionalDeps.c_str() << "\"\n";
  1235. }
  1236. if(objectName.size())
  1237. {
  1238. fout << "\t\t\t\t\tObjectFile=\"$(IntDir)/"
  1239. << objectName.c_str() << "\"\n";
  1240. }
  1241. fout << "\t\t\t\t\t/>\n"
  1242. << "\t\t\t\t</FileConfiguration>\n";
  1243. }
  1244. }
  1245. fout << "\t\t\t</File>\n";
  1246. }
  1247. }
  1248. std::vector<cmSourceGroup> children = sg->GetGroupChildren();
  1249. for(unsigned int i=0;i<children.size();++i)
  1250. {
  1251. this->WriteGroup(&children[i], target, fout, libName, configs);
  1252. }
  1253. // If the group has a name, write the footer.
  1254. if(name != "")
  1255. {
  1256. this->WriteVCProjEndGroup(fout);
  1257. }
  1258. }
  1259. void cmLocalVisualStudio7Generator::
  1260. WriteCustomRule(std::ostream& fout,
  1261. const char* source,
  1262. const char* command,
  1263. const char* comment,
  1264. const std::vector<std::string>& depends,
  1265. const std::vector<std::string>& outputs,
  1266. const char* compileFlags)
  1267. {
  1268. // Write the rule for each configuration.
  1269. std::vector<std::string>::iterator i;
  1270. std::vector<std::string> *configs =
  1271. static_cast<cmGlobalVisualStudio7Generator *>
  1272. (this->GlobalGenerator)->GetConfigurations();
  1273. for(i = configs->begin(); i != configs->end(); ++i)
  1274. {
  1275. fout << "\t\t\t\t<FileConfiguration\n";
  1276. fout << "\t\t\t\t\tName=\"" << *i << "|" << this->PlatformName << "\">\n";
  1277. if(compileFlags)
  1278. {
  1279. fout << "\t\t\t\t\t<Tool\n"
  1280. << "\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
  1281. << "\t\t\t\t\tAdditionalOptions=\""
  1282. << this->EscapeForXML(compileFlags) << "\"/>\n";
  1283. }
  1284. fout << "\t\t\t\t\t<Tool\n"
  1285. << "\t\t\t\t\tName=\"VCCustomBuildTool\"\n"
  1286. << "\t\t\t\t\tDescription=\""
  1287. << this->EscapeForXML(comment) << "\"\n"
  1288. << "\t\t\t\t\tCommandLine=\""
  1289. << this->EscapeForXML(command) << "\"\n"
  1290. << "\t\t\t\t\tAdditionalDependencies=\"";
  1291. if(depends.empty())
  1292. {
  1293. // There are no real dependencies. Produce an artificial one to
  1294. // make sure the rule runs reliably.
  1295. if(!cmSystemTools::FileExists(source))
  1296. {
  1297. std::ofstream depout(source);
  1298. depout << "Artificial dependency for a custom command.\n";
  1299. }
  1300. fout << this->ConvertToXMLOutputPath(source);
  1301. }
  1302. else
  1303. {
  1304. // Write out the dependencies for the rule.
  1305. std::string temp;
  1306. for(std::vector<std::string>::const_iterator d = depends.begin();
  1307. d != depends.end(); ++d)
  1308. {
  1309. // Get the real name of the dependency in case it is a CMake target.
  1310. std::string dep = this->GetRealDependency(d->c_str(), i->c_str());
  1311. fout << this->ConvertToXMLOutputPath(dep.c_str())
  1312. << ";";
  1313. }
  1314. }
  1315. fout << "\"\n";
  1316. fout << "\t\t\t\t\tOutputs=\"";
  1317. if(outputs.empty())
  1318. {
  1319. fout << source << "_force";
  1320. }
  1321. else
  1322. {
  1323. // Write a rule for the output generated by this command.
  1324. const char* sep = "";
  1325. for(std::vector<std::string>::const_iterator o = outputs.begin();
  1326. o != outputs.end(); ++o)
  1327. {
  1328. fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str());
  1329. sep = ";";
  1330. }
  1331. }
  1332. fout << "\"/>\n";
  1333. fout << "\t\t\t\t</FileConfiguration>\n";
  1334. }
  1335. }
  1336. void cmLocalVisualStudio7Generator::WriteVCProjBeginGroup(std::ostream& fout,
  1337. const char* group,
  1338. const char* )
  1339. {
  1340. fout << "\t\t<Filter\n"
  1341. << "\t\t\tName=\"" << group << "\"\n"
  1342. << "\t\t\tFilter=\"\">\n";
  1343. }
  1344. void cmLocalVisualStudio7Generator::WriteVCProjEndGroup(std::ostream& fout)
  1345. {
  1346. fout << "\t\t</Filter>\n";
  1347. }
  1348. // look for custom rules on a target and collect them together
  1349. void cmLocalVisualStudio7Generator
  1350. ::OutputTargetRules(std::ostream& fout,
  1351. cmTarget &target,
  1352. const char * /*libName*/)
  1353. {
  1354. if (target.GetType() > cmTarget::GLOBAL_TARGET)
  1355. {
  1356. return;
  1357. }
  1358. // add the pre build rules
  1359. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"";
  1360. bool init = false;
  1361. for (std::vector<cmCustomCommand>::const_iterator cr =
  1362. target.GetPreBuildCommands().begin();
  1363. cr != target.GetPreBuildCommands().end(); ++cr)
  1364. {
  1365. if(!init)
  1366. {
  1367. fout << "\nCommandLine=\"";
  1368. init = true;
  1369. }
  1370. else
  1371. {
  1372. fout << this->EscapeForXML("\n");
  1373. }
  1374. std::string script =
  1375. this->ConstructScript(cr->GetCommandLines(),
  1376. cr->GetWorkingDirectory(),
  1377. cr->GetEscapeOldStyle(),
  1378. cr->GetEscapeAllowMakeVars());
  1379. fout << this->EscapeForXML(script.c_str()).c_str();
  1380. }
  1381. if (init)
  1382. {
  1383. fout << "\"";
  1384. }
  1385. fout << "/>\n";
  1386. // add the pre Link rules
  1387. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"";
  1388. init = false;
  1389. for (std::vector<cmCustomCommand>::const_iterator cr =
  1390. target.GetPreLinkCommands().begin();
  1391. cr != target.GetPreLinkCommands().end(); ++cr)
  1392. {
  1393. if(!init)
  1394. {
  1395. fout << "\nCommandLine=\"";
  1396. init = true;
  1397. }
  1398. else
  1399. {
  1400. fout << this->EscapeForXML("\n");
  1401. }
  1402. std::string script =
  1403. this->ConstructScript(cr->GetCommandLines(),
  1404. cr->GetWorkingDirectory(),
  1405. cr->GetEscapeOldStyle(),
  1406. cr->GetEscapeAllowMakeVars());
  1407. fout << this->EscapeForXML(script.c_str()).c_str();
  1408. }
  1409. if (init)
  1410. {
  1411. fout << "\"";
  1412. }
  1413. fout << "/>\n";
  1414. // add the PostBuild rules
  1415. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"";
  1416. init = false;
  1417. for (std::vector<cmCustomCommand>::const_iterator cr =
  1418. target.GetPostBuildCommands().begin();
  1419. cr != target.GetPostBuildCommands().end(); ++cr)
  1420. {
  1421. if(!init)
  1422. {
  1423. fout << "\nCommandLine=\"";
  1424. init = true;
  1425. }
  1426. else
  1427. {
  1428. fout << this->EscapeForXML("\n");
  1429. }
  1430. std::string script =
  1431. this->ConstructScript(cr->GetCommandLines(),
  1432. cr->GetWorkingDirectory(),
  1433. cr->GetEscapeOldStyle(),
  1434. cr->GetEscapeAllowMakeVars());
  1435. fout << this->EscapeForXML(script.c_str()).c_str();
  1436. }
  1437. if (init)
  1438. {
  1439. fout << "\"";
  1440. }
  1441. fout << "/>\n";
  1442. }
  1443. void
  1444. cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
  1445. const char *libName,
  1446. cmTarget & target,
  1447. std::vector<cmSourceGroup> &)
  1448. {
  1449. fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
  1450. << "<VisualStudioProject\n"
  1451. << "\tProjectType=\"Visual C++\"\n";
  1452. if(this->Version == 71)
  1453. {
  1454. fout << "\tVersion=\"7.10\"\n";
  1455. }
  1456. else
  1457. {
  1458. if (this->Version == 8)
  1459. {
  1460. fout << "\tVersion=\"8.00\"\n";
  1461. }
  1462. else
  1463. {
  1464. fout << "\tVersion=\"7.00\"\n";
  1465. }
  1466. }
  1467. const char* projLabel = target.GetProperty("PROJECT_LABEL");
  1468. if(!projLabel)
  1469. {
  1470. projLabel = libName;
  1471. }
  1472. const char* keyword = target.GetProperty("VS_KEYWORD");
  1473. if(!keyword)
  1474. {
  1475. keyword = "Win32Proj";
  1476. }
  1477. cmGlobalVisualStudio7Generator* gg =
  1478. static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
  1479. fout << "\tName=\"" << projLabel << "\"\n";
  1480. if(this->Version == 8)
  1481. {
  1482. fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n";
  1483. }
  1484. fout << "\tSccProjectName=\"\"\n"
  1485. << "\tSccLocalPath=\"\"\n"
  1486. << "\tKeyword=\"" << keyword << "\">\n"
  1487. << "\t<Platforms>\n"
  1488. << "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n"
  1489. << "\t</Platforms>\n";
  1490. }
  1491. void cmLocalVisualStudio7Generator::WriteVCProjFooter(std::ostream& fout)
  1492. {
  1493. fout << "\t<Globals>\n"
  1494. << "\t</Globals>\n"
  1495. << "</VisualStudioProject>\n";
  1496. }
  1497. std::string cmLocalVisualStudio7Generator::EscapeForXML(const char* s)
  1498. {
  1499. std::string ret = s;
  1500. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1501. cmSystemTools::ReplaceString(ret, "\"", "&quot;");
  1502. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1503. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1504. cmSystemTools::ReplaceString(ret, "\n", "&#x0D;&#x0A;");
  1505. return ret;
  1506. }
  1507. std::string cmLocalVisualStudio7Generator
  1508. ::ConvertToXMLOutputPath(const char* path)
  1509. {
  1510. std::string ret = this->ConvertToOptionallyRelativeOutputPath(path);
  1511. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1512. cmSystemTools::ReplaceString(ret, "\"", "&quot;");
  1513. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1514. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1515. return ret;
  1516. }
  1517. std::string cmLocalVisualStudio7Generator
  1518. ::ConvertToXMLOutputPathSingle(const char* path)
  1519. {
  1520. std::string ret = this->ConvertToOptionallyRelativeOutputPath(path);
  1521. cmSystemTools::ReplaceString(ret, "\"", "");
  1522. cmSystemTools::ReplaceString(ret, "&", "&amp;");
  1523. cmSystemTools::ReplaceString(ret, "<", "&lt;");
  1524. cmSystemTools::ReplaceString(ret, ">", "&gt;");
  1525. return ret;
  1526. }
  1527. void cmLocalVisualStudio7Generator::ConfigureFinalPass()
  1528. {
  1529. cmLocalGenerator::ConfigureFinalPass();
  1530. cmTargets &tgts = this->Makefile->GetTargets();
  1531. cmGlobalVisualStudio7Generator* gg =
  1532. static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
  1533. for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
  1534. {
  1535. if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
  1536. {
  1537. cmCustomCommand cc = l->second.GetPostBuildCommands()[0];
  1538. const cmCustomCommandLines& cmds = cc.GetCommandLines();
  1539. std::string project_name = cmds[0][0];
  1540. gg->CreateGUID(project_name.c_str());
  1541. }
  1542. else
  1543. {
  1544. gg->CreateGUID(l->first.c_str());
  1545. }
  1546. }
  1547. }
  1548. //----------------------------------------------------------------------------
  1549. std::string cmLocalVisualStudio7Generator
  1550. ::GetTargetDirectory(cmTarget& target)
  1551. {
  1552. std::string dir;
  1553. dir += target.GetName();
  1554. dir += ".dir";
  1555. return dir;
  1556. }