cmLocalVisualStudio6Generator.cxx 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716
  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 "cmGlobalGenerator.h"
  11. #include "cmLocalVisualStudio6Generator.h"
  12. #include "cmMakefile.h"
  13. #include "cmSystemTools.h"
  14. #include "cmSourceFile.h"
  15. #include "cmCacheManager.h"
  16. #include "cmake.h"
  17. #include "cmComputeLinkInformation.h"
  18. #include <cmsys/RegularExpression.hxx>
  19. cmLocalVisualStudio6Generator::cmLocalVisualStudio6Generator()
  20. {
  21. }
  22. cmLocalVisualStudio6Generator::~cmLocalVisualStudio6Generator()
  23. {
  24. }
  25. //----------------------------------------------------------------------------
  26. // Helper class to write build events.
  27. class cmLocalVisualStudio6Generator::EventWriter
  28. {
  29. public:
  30. EventWriter(cmLocalVisualStudio6Generator* lg,
  31. const char* config, std::string& code):
  32. LG(lg), Config(config), Code(code), First(true) {}
  33. void Start(const char* event)
  34. {
  35. this->First = true;
  36. this->Event = event;
  37. }
  38. void Finish()
  39. {
  40. this->Code += (this->First? "" : "\n");
  41. }
  42. void Write(std::vector<cmCustomCommand> const& ccs)
  43. {
  44. for(std::vector<cmCustomCommand>::const_iterator ci = ccs.begin();
  45. ci != ccs.end(); ++ci)
  46. {
  47. this->Write(*ci);
  48. }
  49. }
  50. void Write(cmCustomCommand const& cc)
  51. {
  52. if(this->First)
  53. {
  54. this->Code += this->Event + "_Cmds=";
  55. this->First = false;
  56. }
  57. else
  58. {
  59. this->Code += "\\\n\t";
  60. }
  61. this->Code +=
  62. this->LG->ConstructScript(cc.GetCommandLines(),
  63. cc.GetWorkingDirectory(),
  64. this->Config,
  65. cc.GetEscapeOldStyle(),
  66. cc.GetEscapeAllowMakeVars(),
  67. "\\\n\t");
  68. }
  69. private:
  70. cmLocalVisualStudio6Generator* LG;
  71. const char* Config;
  72. std::string& Code;
  73. bool First;
  74. std::string Event;
  75. };
  76. void cmLocalVisualStudio6Generator::AddHelperCommands()
  77. {
  78. std::set<cmStdString> lang;
  79. lang.insert("C");
  80. lang.insert("CXX");
  81. this->CreateCustomTargetsAndCommands(lang);
  82. }
  83. void cmLocalVisualStudio6Generator::Generate()
  84. {
  85. this->OutputDSPFile();
  86. }
  87. void cmLocalVisualStudio6Generator::OutputDSPFile()
  88. {
  89. // If not an in source build, then create the output directory
  90. if(strcmp(this->Makefile->GetStartOutputDirectory(),
  91. this->Makefile->GetHomeDirectory()) != 0)
  92. {
  93. if(!cmSystemTools::MakeDirectory
  94. (this->Makefile->GetStartOutputDirectory()))
  95. {
  96. cmSystemTools::Error("Error creating directory ",
  97. this->Makefile->GetStartOutputDirectory());
  98. }
  99. }
  100. // Setup /I and /LIBPATH options for the resulting DSP file. VS 6
  101. // truncates long include paths so make it as short as possible if
  102. // the length threatens this problem.
  103. unsigned int maxIncludeLength = 3000;
  104. bool useShortPath = false;
  105. for(int j=0; j < 2; ++j)
  106. {
  107. std::vector<std::string> includes;
  108. this->GetIncludeDirectories(includes);
  109. std::vector<std::string>::iterator i;
  110. for(i = includes.begin(); i != includes.end(); ++i)
  111. {
  112. std::string tmp =
  113. this->ConvertToOptionallyRelativeOutputPath(i->c_str());
  114. if(useShortPath)
  115. {
  116. cmSystemTools::GetShortPath(tmp.c_str(), tmp);
  117. }
  118. this->IncludeOptions += " /I ";
  119. // quote if not already quoted
  120. if (tmp[0] != '"')
  121. {
  122. this->IncludeOptions += "\"";
  123. this->IncludeOptions += tmp;
  124. this->IncludeOptions += "\"";
  125. }
  126. else
  127. {
  128. this->IncludeOptions += tmp;
  129. }
  130. }
  131. if(j == 0 && this->IncludeOptions.size() > maxIncludeLength)
  132. {
  133. this->IncludeOptions = "";
  134. useShortPath = true;
  135. }
  136. else
  137. {
  138. break;
  139. }
  140. }
  141. // Create the DSP or set of DSP's for libraries and executables
  142. // clear project names
  143. this->CreatedProjectNames.clear();
  144. cmTargets &tgts = this->Makefile->GetTargets();
  145. for(cmTargets::iterator l = tgts.begin();
  146. l != tgts.end(); l++)
  147. {
  148. // Add a rule to regenerate the build system when the target
  149. // specification source changes.
  150. const char* suppRegenRule =
  151. this->Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION");
  152. if (!cmSystemTools::IsOn(suppRegenRule))
  153. {
  154. this->AddDSPBuildRule(l->second);
  155. }
  156. }
  157. // build any targets
  158. for(cmTargets::iterator l = tgts.begin();
  159. l != tgts.end(); l++)
  160. {
  161. switch(l->second.GetType())
  162. {
  163. case cmTarget::STATIC_LIBRARY:
  164. this->SetBuildType(STATIC_LIBRARY, l->first.c_str(), l->second);
  165. break;
  166. case cmTarget::SHARED_LIBRARY:
  167. case cmTarget::MODULE_LIBRARY:
  168. this->SetBuildType(DLL, l->first.c_str(), l->second);
  169. break;
  170. case cmTarget::EXECUTABLE:
  171. this->SetBuildType(EXECUTABLE,l->first.c_str(), l->second);
  172. break;
  173. case cmTarget::UTILITY:
  174. case cmTarget::GLOBAL_TARGET:
  175. this->SetBuildType(UTILITY, l->first.c_str(), l->second);
  176. break;
  177. default:
  178. cmSystemTools::Error("Bad target type", l->first.c_str());
  179. break;
  180. }
  181. // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
  182. // so don't build a projectfile for it
  183. const char* path =
  184. l->second.GetProperty("EXTERNAL_MSPROJECT");
  185. if(!path)
  186. {
  187. // check to see if the dsp is going into a sub-directory
  188. std::string::size_type pos = l->first.rfind('/');
  189. if(pos != std::string::npos)
  190. {
  191. std::string dir = this->Makefile->GetStartOutputDirectory();
  192. dir += "/";
  193. dir += l->first.substr(0, pos);
  194. if(!cmSystemTools::MakeDirectory(dir.c_str()))
  195. {
  196. cmSystemTools::Error("Error creating directory ", dir.c_str());
  197. }
  198. }
  199. this->CreateSingleDSP(l->first.c_str(),l->second);
  200. }
  201. }
  202. }
  203. // Utility function to make a valid VS6 *.dsp filename out
  204. // of a CMake target name:
  205. //
  206. extern std::string GetVS6TargetName(const std::string& targetName);
  207. void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname,
  208. cmTarget &target)
  209. {
  210. // add to the list of projects
  211. std::string pname = GetVS6TargetName(lname);
  212. this->CreatedProjectNames.push_back(pname);
  213. // create the dsp.cmake file
  214. std::string fname;
  215. fname = this->Makefile->GetStartOutputDirectory();
  216. fname += "/";
  217. fname += pname;
  218. fname += ".dsp";
  219. // save the name of the real dsp file
  220. std::string realDSP = fname;
  221. fname += ".cmake";
  222. std::ofstream fout(fname.c_str());
  223. if(!fout)
  224. {
  225. cmSystemTools::Error("Error Writing ", fname.c_str());
  226. cmSystemTools::ReportLastSystemError("");
  227. }
  228. this->WriteDSPFile(fout,pname.c_str(),target);
  229. fout.close();
  230. // if the dsp file has changed, then write it.
  231. cmSystemTools::CopyFileIfDifferent(fname.c_str(), realDSP.c_str());
  232. }
  233. void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt)
  234. {
  235. std::string dspname = GetVS6TargetName(tgt.GetName());
  236. dspname += ".dsp.cmake";
  237. const char* dsprule =
  238. this->Makefile->GetRequiredDefinition("CMAKE_COMMAND");
  239. cmCustomCommandLine commandLine;
  240. commandLine.push_back(dsprule);
  241. std::string makefileIn = this->Makefile->GetStartDirectory();
  242. makefileIn += "/";
  243. makefileIn += "CMakeLists.txt";
  244. if(!cmSystemTools::FileExists(makefileIn.c_str()))
  245. {
  246. return;
  247. }
  248. std::string comment = "Building Custom Rule ";
  249. comment += makefileIn;
  250. std::string args;
  251. args = "-H";
  252. args += this->Convert(this->Makefile->GetHomeDirectory(),
  253. START_OUTPUT, UNCHANGED, true);
  254. commandLine.push_back(args);
  255. args = "-B";
  256. args +=
  257. this->Convert(this->Makefile->GetHomeOutputDirectory(),
  258. START_OUTPUT, UNCHANGED, true);
  259. commandLine.push_back(args);
  260. std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();
  261. cmCustomCommandLines commandLines;
  262. commandLines.push_back(commandLine);
  263. const char* no_working_directory = 0;
  264. this->Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles,
  265. makefileIn.c_str(), commandLines,
  266. comment.c_str(),
  267. no_working_directory, true);
  268. if(cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str()))
  269. {
  270. tgt.AddSourceFile(file);
  271. }
  272. else
  273. {
  274. cmSystemTools::Error("Error adding rule for ", makefileIn.c_str());
  275. }
  276. }
  277. void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
  278. const char *libName,
  279. cmTarget &target)
  280. {
  281. // For utility targets need custom command since pre- and post-
  282. // build does not do anything in Visual Studio 6. In order for the
  283. // rules to run in the correct order as custom commands, we need
  284. // special care for dependencies. The first rule must depend on all
  285. // the dependencies of all the rules. The later rules must each
  286. // depend only on the previous rule.
  287. if ((target.GetType() == cmTarget::UTILITY ||
  288. target.GetType() == cmTarget::GLOBAL_TARGET) &&
  289. (!target.GetPreBuildCommands().empty() ||
  290. !target.GetPostBuildCommands().empty()))
  291. {
  292. // Accumulate the dependencies of all the commands.
  293. std::vector<std::string> depends;
  294. for (std::vector<cmCustomCommand>::const_iterator cr =
  295. target.GetPreBuildCommands().begin();
  296. cr != target.GetPreBuildCommands().end(); ++cr)
  297. {
  298. depends.insert(depends.end(),
  299. cr->GetDepends().begin(), cr->GetDepends().end());
  300. }
  301. for (std::vector<cmCustomCommand>::const_iterator cr =
  302. target.GetPostBuildCommands().begin();
  303. cr != target.GetPostBuildCommands().end(); ++cr)
  304. {
  305. depends.insert(depends.end(),
  306. cr->GetDepends().begin(), cr->GetDepends().end());
  307. }
  308. // Add the pre- and post-build commands in order.
  309. int count = 1;
  310. for (std::vector<cmCustomCommand>::const_iterator cr =
  311. target.GetPreBuildCommands().begin();
  312. cr != target.GetPreBuildCommands().end(); ++cr)
  313. {
  314. this->AddUtilityCommandHack(target, count++, depends, *cr);
  315. }
  316. for (std::vector<cmCustomCommand>::const_iterator cr =
  317. target.GetPostBuildCommands().begin();
  318. cr != target.GetPostBuildCommands().end(); ++cr)
  319. {
  320. this->AddUtilityCommandHack(target, count++, depends, *cr);
  321. }
  322. }
  323. // We may be modifying the source groups temporarily, so make a copy.
  324. std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
  325. // get the classes from the source lists then add them to the groups
  326. std::vector<cmSourceFile*> const & classes = target.GetSourceFiles();
  327. // now all of the source files have been properly assigned to the target
  328. // now stick them into source groups using the reg expressions
  329. for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
  330. i != classes.end(); i++)
  331. {
  332. // Add the file to the list of sources.
  333. std::string source = (*i)->GetFullPath();
  334. cmSourceGroup& sourceGroup =
  335. this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
  336. sourceGroup.AssignSource(*i);
  337. // while we are at it, if it is a .rule file then for visual studio 6 we
  338. // must generate it
  339. if ((*i)->GetExtension() == "rule")
  340. {
  341. if(!cmSystemTools::FileExists(source.c_str()))
  342. {
  343. cmSystemTools::ReplaceString(source, "$(IntDir)/", "");
  344. #if defined(_WIN32) || defined(__CYGWIN__)
  345. std::ofstream fout(source.c_str(),
  346. std::ios::binary | std::ios::out
  347. | std::ios::trunc);
  348. #else
  349. std::ofstream fout(source.c_str(),
  350. std::ios::out | std::ios::trunc);
  351. #endif
  352. if(fout)
  353. {
  354. fout.write("# generated from CMake",22);
  355. fout.flush();
  356. fout.close();
  357. }
  358. }
  359. }
  360. }
  361. // Compute which sources need unique object computation.
  362. this->ComputeObjectNameRequirements(sourceGroups);
  363. // Write the DSP file's header.
  364. this->WriteDSPHeader(fout, libName, target, sourceGroups);
  365. // Loop through every source group.
  366. for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin();
  367. sg != sourceGroups.end(); ++sg)
  368. {
  369. this->WriteGroup(&(*sg), target, fout, libName);
  370. }
  371. // Write the DSP file's footer.
  372. this->WriteDSPFooter(fout);
  373. }
  374. void cmLocalVisualStudio6Generator
  375. ::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
  376. std::ostream &fout, const char *libName)
  377. {
  378. const std::vector<const cmSourceFile *> &sourceFiles =
  379. sg->GetSourceFiles();
  380. // If the group is empty, don't write it at all.
  381. if(sourceFiles.empty() && sg->GetGroupChildren().empty())
  382. {
  383. return;
  384. }
  385. // If the group has a name, write the header.
  386. std::string name = sg->GetName();
  387. if(name != "")
  388. {
  389. this->WriteDSPBeginGroup(fout, name.c_str(), "");
  390. }
  391. // Compute the maximum length configuration name.
  392. std::string config_max;
  393. for(std::vector<std::string>::iterator i = this->Configurations.begin();
  394. i != this->Configurations.end(); ++i)
  395. {
  396. // Strip the subdirectory name out of the configuration name.
  397. std::string config = this->GetConfigName(*i);
  398. if(config.size() > config_max.size())
  399. {
  400. config_max = config;
  401. }
  402. }
  403. // Compute the maximum length full path to the intermediate
  404. // files directory for any configuration. This is used to construct
  405. // object file names that do not produce paths that are too long.
  406. std::string dir_max;
  407. dir_max += this->Makefile->GetCurrentOutputDirectory();
  408. dir_max += "/";
  409. dir_max += config_max;
  410. dir_max += "/";
  411. // Loop through each source in the source group.
  412. for(std::vector<const cmSourceFile *>::const_iterator sf =
  413. sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
  414. {
  415. std::string source = (*sf)->GetFullPath();
  416. const cmCustomCommand *command =
  417. (*sf)->GetCustomCommand();
  418. std::string compileFlags;
  419. std::vector<std::string> depends;
  420. std::string objectNameDir;
  421. if(this->NeedObjectName.find(*sf) != this->NeedObjectName.end())
  422. {
  423. objectNameDir =
  424. cmSystemTools::GetFilenamePath(
  425. this->GetObjectFileNameWithoutTarget(*(*sf), dir_max));
  426. }
  427. // Add per-source file flags.
  428. if(const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS"))
  429. {
  430. compileFlags += cflags;
  431. }
  432. const char* lang = this->GetSourceFileLanguage(*(*sf));
  433. if(lang)
  434. {
  435. if(strcmp(lang, "CXX") == 0)
  436. {
  437. // force a C++ file type
  438. compileFlags += " /TP ";
  439. }
  440. else if(strcmp(lang, "C") == 0)
  441. {
  442. // force to c file type
  443. compileFlags += " /TC ";
  444. }
  445. }
  446. // Add per-source and per-configuration preprocessor definitions.
  447. std::map<cmStdString, cmStdString> cdmap;
  448. this->AppendDefines(compileFlags,
  449. (*sf)->GetProperty("COMPILE_DEFINITIONS"), lang);
  450. if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_DEBUG"))
  451. {
  452. this->AppendDefines(cdmap["DEBUG"], cdefs, lang);
  453. }
  454. if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_RELEASE"))
  455. {
  456. this->AppendDefines(cdmap["RELEASE"], cdefs, lang);
  457. }
  458. if(const char* cdefs =
  459. (*sf)->GetProperty("COMPILE_DEFINITIONS_MINSIZEREL"))
  460. {
  461. this->AppendDefines(cdmap["MINSIZEREL"], cdefs, lang);
  462. }
  463. if(const char* cdefs =
  464. (*sf)->GetProperty("COMPILE_DEFINITIONS_RELWITHDEBINFO"))
  465. {
  466. this->AppendDefines(cdmap["RELWITHDEBINFO"], cdefs, lang);
  467. }
  468. bool excludedFromBuild =
  469. (lang && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY"));
  470. // Check for extra object-file dependencies.
  471. const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS");
  472. if(dependsValue)
  473. {
  474. cmSystemTools::ExpandListArgument(dependsValue, depends);
  475. }
  476. if (GetVS6TargetName(source) != libName ||
  477. target.GetType() == cmTarget::UTILITY ||
  478. target.GetType() == cmTarget::GLOBAL_TARGET)
  479. {
  480. fout << "# Begin Source File\n\n";
  481. // Tell MS-Dev what the source is. If the compiler knows how to
  482. // build it, then it will.
  483. fout << "SOURCE=" <<
  484. this->ConvertToOptionallyRelativeOutputPath(source.c_str()) << "\n\n";
  485. if(!depends.empty())
  486. {
  487. // Write out the dependencies for the rule.
  488. fout << "USERDEP__HACK=";
  489. for(std::vector<std::string>::const_iterator d = depends.begin();
  490. d != depends.end(); ++d)
  491. {
  492. fout << "\\\n\t" <<
  493. this->ConvertToOptionallyRelativeOutputPath(d->c_str());
  494. }
  495. fout << "\n";
  496. }
  497. if (command)
  498. {
  499. const char* flags = compileFlags.size() ? compileFlags.c_str(): 0;
  500. this->WriteCustomRule(fout, source.c_str(), *command, flags);
  501. }
  502. else if(!compileFlags.empty() || !objectNameDir.empty() ||
  503. excludedFromBuild || !cdmap.empty())
  504. {
  505. for(std::vector<std::string>::iterator i
  506. = this->Configurations.begin();
  507. i != this->Configurations.end(); ++i)
  508. {
  509. // Strip the subdirectory name out of the configuration name.
  510. std::string config = this->GetConfigName(*i);
  511. if (i == this->Configurations.begin())
  512. {
  513. fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl;
  514. }
  515. else
  516. {
  517. fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl;
  518. }
  519. if(excludedFromBuild)
  520. {
  521. fout << "# PROP Exclude_From_Build 1\n";
  522. }
  523. if(!compileFlags.empty())
  524. {
  525. fout << "\n# ADD CPP " << compileFlags << "\n\n";
  526. }
  527. std::map<cmStdString, cmStdString>::iterator cdi =
  528. cdmap.find(cmSystemTools::UpperCase(config));
  529. if(cdi != cdmap.end() && !cdi->second.empty())
  530. {
  531. fout << "\n# ADD CPP " << cdi->second << "\n\n";
  532. }
  533. if(!objectNameDir.empty())
  534. {
  535. // Setup an alternate object file directory.
  536. fout << "\n# PROP Intermediate_Dir \""
  537. << config << "/" << objectNameDir << "\"\n\n";
  538. }
  539. }
  540. fout << "!ENDIF\n\n";
  541. }
  542. fout << "# End Source File\n";
  543. }
  544. }
  545. std::vector<cmSourceGroup> const& children = sg->GetGroupChildren();
  546. for(unsigned int i=0;i<children.size();++i)
  547. {
  548. this->WriteGroup(&children[i], target, fout, libName);
  549. }
  550. // If the group has a name, write the footer.
  551. if(name != "")
  552. {
  553. this->WriteDSPEndGroup(fout);
  554. }
  555. }
  556. void
  557. cmLocalVisualStudio6Generator
  558. ::AddUtilityCommandHack(cmTarget& target, int count,
  559. std::vector<std::string>& depends,
  560. const cmCustomCommand& origCommand)
  561. {
  562. // Create a fake output that forces the rule to run.
  563. char* output = new char[(strlen(this->Makefile->GetStartOutputDirectory()) +
  564. strlen(target.GetName()) + 30)];
  565. sprintf(output,"%s/%s_force_%i", this->Makefile->GetStartOutputDirectory(),
  566. target.GetName(), count);
  567. std::string comment = this->ConstructComment(origCommand, "<hack>");
  568. // Add the rule with the given dependencies and commands.
  569. const char* no_main_dependency = 0;
  570. this->Makefile->AddCustomCommandToOutput(output,
  571. depends,
  572. no_main_dependency,
  573. origCommand.GetCommandLines(),
  574. comment.c_str(),
  575. origCommand.GetWorkingDirectory());
  576. // Replace the dependencies with the output of this rule so that the
  577. // next rule added will run after this one.
  578. depends.clear();
  579. depends.push_back(output);
  580. // Add a source file representing this output to the project.
  581. cmSourceFile* outsf = this->Makefile->GetSourceFileWithOutput(output);
  582. target.AddSourceFile(outsf);
  583. // Free the fake output name.
  584. delete [] output;
  585. }
  586. void
  587. cmLocalVisualStudio6Generator
  588. ::WriteCustomRule(std::ostream& fout,
  589. const char* source,
  590. const cmCustomCommand& command,
  591. const char* flags)
  592. {
  593. std::string comment =
  594. this->ConstructComment(command, "Building Custom Rule $(InputPath)");
  595. if(comment == "<hack>")
  596. {
  597. comment = "";
  598. }
  599. // Write the rule for each configuration.
  600. std::vector<std::string>::iterator i;
  601. for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i)
  602. {
  603. std::string config = this->GetConfigName(*i);
  604. std::string script =
  605. this->ConstructScript(command.GetCommandLines(),
  606. command.GetWorkingDirectory(),
  607. config.c_str(),
  608. command.GetEscapeOldStyle(),
  609. command.GetEscapeAllowMakeVars(),
  610. "\\\n\t");
  611. if (i == this->Configurations.begin())
  612. {
  613. fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl;
  614. }
  615. else
  616. {
  617. fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl;
  618. }
  619. if(flags)
  620. {
  621. fout << "\n# ADD CPP " << flags << "\n\n";
  622. }
  623. // Write out the dependencies for the rule.
  624. fout << "USERDEP__HACK=";
  625. for(std::vector<std::string>::const_iterator d =
  626. command.GetDepends().begin();
  627. d != command.GetDepends().end();
  628. ++d)
  629. {
  630. // Lookup the real name of the dependency in case it is a CMake target.
  631. std::string dep = this->GetRealDependency(d->c_str(),
  632. config.c_str());
  633. fout << "\\\n\t" <<
  634. this->ConvertToOptionallyRelativeOutputPath(dep.c_str());
  635. }
  636. fout << "\n";
  637. fout << "# PROP Ignore_Default_Tool 1\n";
  638. fout << "# Begin Custom Build -";
  639. if(!comment.empty())
  640. {
  641. fout << " " << comment.c_str();
  642. }
  643. fout << "\n\n";
  644. if(command.GetOutputs().empty())
  645. {
  646. fout << source
  647. << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t";
  648. fout << script.c_str() << "\n\n";
  649. }
  650. else
  651. {
  652. for(std::vector<std::string>::const_iterator o =
  653. command.GetOutputs().begin();
  654. o != command.GetOutputs().end();
  655. ++o)
  656. {
  657. // Write a rule for every output generated by this command.
  658. fout << this->ConvertToOptionallyRelativeOutputPath(o->c_str())
  659. << " : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t";
  660. fout << script.c_str() << "\n\n";
  661. }
  662. }
  663. fout << "# End Custom Build\n\n";
  664. }
  665. fout << "!ENDIF\n\n";
  666. }
  667. void cmLocalVisualStudio6Generator::WriteDSPBeginGroup(std::ostream& fout,
  668. const char* group,
  669. const char* filter)
  670. {
  671. fout << "# Begin Group \"" << group << "\"\n"
  672. "# PROP Default_Filter \"" << filter << "\"\n";
  673. }
  674. void cmLocalVisualStudio6Generator::WriteDSPEndGroup(std::ostream& fout)
  675. {
  676. fout << "# End Group\n";
  677. }
  678. void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
  679. const char* libName,
  680. cmTarget& target)
  681. {
  682. std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT");
  683. const char *def=
  684. this->Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY");
  685. if( def)
  686. {
  687. root = def;
  688. }
  689. else
  690. {
  691. root += "/Templates";
  692. }
  693. switch(b)
  694. {
  695. case STATIC_LIBRARY:
  696. this->DSPHeaderTemplate = root;
  697. this->DSPHeaderTemplate += "/staticLibHeader.dsptemplate";
  698. this->DSPFooterTemplate = root;
  699. this->DSPFooterTemplate += "/staticLibFooter.dsptemplate";
  700. break;
  701. case DLL:
  702. this->DSPHeaderTemplate = root;
  703. this->DSPHeaderTemplate += "/DLLHeader.dsptemplate";
  704. this->DSPFooterTemplate = root;
  705. this->DSPFooterTemplate += "/DLLFooter.dsptemplate";
  706. break;
  707. case EXECUTABLE:
  708. if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") )
  709. {
  710. this->DSPHeaderTemplate = root;
  711. this->DSPHeaderTemplate += "/EXEWinHeader.dsptemplate";
  712. this->DSPFooterTemplate = root;
  713. this->DSPFooterTemplate += "/EXEFooter.dsptemplate";
  714. }
  715. else
  716. {
  717. this->DSPHeaderTemplate = root;
  718. this->DSPHeaderTemplate += "/EXEHeader.dsptemplate";
  719. this->DSPFooterTemplate = root;
  720. this->DSPFooterTemplate += "/EXEFooter.dsptemplate";
  721. }
  722. break;
  723. case UTILITY:
  724. this->DSPHeaderTemplate = root;
  725. this->DSPHeaderTemplate += "/UtilityHeader.dsptemplate";
  726. this->DSPFooterTemplate = root;
  727. this->DSPFooterTemplate += "/UtilityFooter.dsptemplate";
  728. break;
  729. }
  730. // once the build type is set, determine what configurations are
  731. // possible
  732. std::ifstream fin(this->DSPHeaderTemplate.c_str());
  733. cmsys::RegularExpression reg("# Name ");
  734. if(!fin)
  735. {
  736. cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str());
  737. }
  738. // reset this->Configurations
  739. this->Configurations.erase(this->Configurations.begin(),
  740. this->Configurations.end());
  741. // now add all the configurations possible
  742. std::string vs6name = GetVS6TargetName(libName);
  743. std::string line;
  744. while(cmSystemTools::GetLineFromStream(fin, line))
  745. {
  746. cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME", vs6name.c_str());
  747. if (reg.find(line))
  748. {
  749. this->Configurations.push_back(line.substr(reg.end()));
  750. }
  751. }
  752. }
  753. // look for custom rules on a target and collect them together
  754. std::string
  755. cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target,
  756. const char* configName,
  757. const char * /* libName */)
  758. {
  759. if (target.GetType() >= cmTarget::UTILITY )
  760. {
  761. return "";
  762. }
  763. std::string customRuleCode = "# Begin Special Build Tool\n";
  764. EventWriter event(this, configName, customRuleCode);
  765. // Write the pre-build and pre-link together (VS6 does not support both).
  766. event.Start("PreLink");
  767. event.Write(target.GetPreBuildCommands());
  768. event.Write(target.GetPreLinkCommands());
  769. cmsys::auto_ptr<cmCustomCommand> pcc(
  770. this->MaybeCreateImplibDir(target, configName));
  771. if(pcc.get())
  772. {
  773. event.Write(*pcc);
  774. }
  775. event.Finish();
  776. // Write the post-build rules.
  777. event.Start("PostBuild");
  778. event.Write(target.GetPostBuildCommands());
  779. event.Finish();
  780. customRuleCode += "# End Special Build Tool\n";
  781. return customRuleCode;
  782. }
  783. inline std::string removeQuotes(const std::string& s)
  784. {
  785. if(s[0] == '\"' && s[s.size()-1] == '\"')
  786. {
  787. return s.substr(1, s.size()-2);
  788. }
  789. return s;
  790. }
  791. // Code in blocks surrounded by a test for this definition is needed
  792. // only for compatibility with user project's replacement DSP
  793. // templates. The CMake templates no longer use them.
  794. #define CM_USE_OLD_VS6
  795. void cmLocalVisualStudio6Generator
  796. ::WriteDSPHeader(std::ostream& fout,
  797. const char *libName, cmTarget &target,
  798. std::vector<cmSourceGroup> &)
  799. {
  800. bool targetBuilds = (target.GetType() >= cmTarget::EXECUTABLE &&
  801. target.GetType() <= cmTarget::MODULE_LIBRARY);
  802. #ifdef CM_USE_OLD_VS6
  803. // Lookup the library and executable output directories.
  804. std::string libPath;
  805. if(this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
  806. {
  807. libPath = this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
  808. }
  809. std::string exePath;
  810. if(this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
  811. {
  812. exePath = this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
  813. }
  814. // Make sure there are trailing slashes.
  815. if(!libPath.empty())
  816. {
  817. if(libPath[libPath.size()-1] != '/')
  818. {
  819. libPath += "/";
  820. }
  821. }
  822. if(!exePath.empty())
  823. {
  824. if(exePath[exePath.size()-1] != '/')
  825. {
  826. exePath += "/";
  827. }
  828. }
  829. std::set<std::string> pathEmitted;
  830. // determine the link directories
  831. std::string libOptions;
  832. std::string libDebugOptions;
  833. std::string libOptimizedOptions;
  834. std::string libMultiLineOptions;
  835. std::string libMultiLineOptionsForDebug;
  836. std::string libMultiLineDebugOptions;
  837. std::string libMultiLineOptimizedOptions;
  838. if(libPath.size())
  839. {
  840. std::string lpath =
  841. this->ConvertToOptionallyRelativeOutputPath(libPath.c_str());
  842. if(lpath.size() == 0)
  843. {
  844. lpath = ".";
  845. }
  846. std::string lpathIntDir = libPath + "$(INTDIR)";
  847. lpathIntDir =
  848. this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str());
  849. if(pathEmitted.insert(lpath).second)
  850. {
  851. libOptions += " /LIBPATH:";
  852. libOptions += lpathIntDir;
  853. libOptions += " ";
  854. libOptions += " /LIBPATH:";
  855. libOptions += lpath;
  856. libOptions += " ";
  857. libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
  858. libMultiLineOptions += lpathIntDir;
  859. libMultiLineOptions += " ";
  860. libMultiLineOptions += " /LIBPATH:";
  861. libMultiLineOptions += lpath;
  862. libMultiLineOptions += " \n";
  863. libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
  864. libMultiLineOptionsForDebug += lpathIntDir;
  865. libMultiLineOptionsForDebug += " ";
  866. libMultiLineOptionsForDebug += " /LIBPATH:";
  867. libMultiLineOptionsForDebug += lpath;
  868. libMultiLineOptionsForDebug += " \n";
  869. }
  870. }
  871. if(exePath.size())
  872. {
  873. std::string lpath =
  874. this->ConvertToOptionallyRelativeOutputPath(exePath.c_str());
  875. if(lpath.size() == 0)
  876. {
  877. lpath = ".";
  878. }
  879. std::string lpathIntDir = exePath + "$(INTDIR)";
  880. lpathIntDir =
  881. this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str());
  882. if(pathEmitted.insert(lpath).second)
  883. {
  884. libOptions += " /LIBPATH:";
  885. libOptions += lpathIntDir;
  886. libOptions += " ";
  887. libOptions += " /LIBPATH:";
  888. libOptions += lpath;
  889. libOptions += " ";
  890. libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
  891. libMultiLineOptions += lpathIntDir;
  892. libMultiLineOptions += " ";
  893. libMultiLineOptions += " /LIBPATH:";
  894. libMultiLineOptions += lpath;
  895. libMultiLineOptions += " \n";
  896. libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
  897. libMultiLineOptionsForDebug += lpathIntDir;
  898. libMultiLineOptionsForDebug += " ";
  899. libMultiLineOptionsForDebug += " /LIBPATH:";
  900. libMultiLineOptionsForDebug += lpath;
  901. libMultiLineOptionsForDebug += " \n";
  902. }
  903. }
  904. std::vector<std::string>::const_iterator i;
  905. const std::vector<std::string>& libdirs = target.GetLinkDirectories();
  906. for(i = libdirs.begin(); i != libdirs.end(); ++i)
  907. {
  908. std::string path = *i;
  909. if(path[path.size()-1] != '/')
  910. {
  911. path += "/";
  912. }
  913. std::string lpath =
  914. this->ConvertToOptionallyRelativeOutputPath(path.c_str());
  915. if(lpath.size() == 0)
  916. {
  917. lpath = ".";
  918. }
  919. std::string lpathIntDir = path + "$(INTDIR)";
  920. lpathIntDir =
  921. this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str());
  922. if(pathEmitted.insert(lpath).second)
  923. {
  924. libOptions += " /LIBPATH:";
  925. libOptions += lpathIntDir;
  926. libOptions += " ";
  927. libOptions += " /LIBPATH:";
  928. libOptions += lpath;
  929. libOptions += " ";
  930. libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
  931. libMultiLineOptions += lpathIntDir;
  932. libMultiLineOptions += " ";
  933. libMultiLineOptions += " /LIBPATH:";
  934. libMultiLineOptions += lpath;
  935. libMultiLineOptions += " \n";
  936. libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
  937. libMultiLineOptionsForDebug += lpathIntDir;
  938. libMultiLineOptionsForDebug += " ";
  939. libMultiLineOptionsForDebug += " /LIBPATH:";
  940. libMultiLineOptionsForDebug += lpath;
  941. libMultiLineOptionsForDebug += " \n";
  942. }
  943. }
  944. // find link libraries
  945. const cmTarget::LinkLibraryVectorType& libs = target.GetLinkLibraries();
  946. cmTarget::LinkLibraryVectorType::const_iterator j;
  947. for(j = libs.begin(); j != libs.end(); ++j)
  948. {
  949. // add libraries to executables and dlls (but never include
  950. // a library in a library, bad recursion)
  951. // NEVER LINK STATIC LIBRARIES TO OTHER STATIC LIBRARIES
  952. if ((target.GetType() != cmTarget::SHARED_LIBRARY
  953. && target.GetType() != cmTarget::STATIC_LIBRARY
  954. && target.GetType() != cmTarget::MODULE_LIBRARY) ||
  955. (target.GetType()==cmTarget::SHARED_LIBRARY
  956. && libName != GetVS6TargetName(j->first)) ||
  957. (target.GetType()==cmTarget::MODULE_LIBRARY
  958. && libName != GetVS6TargetName(j->first)))
  959. {
  960. // Compute the proper name to use to link this library.
  961. std::string lib;
  962. std::string libDebug;
  963. cmTarget* tgt = this->GlobalGenerator->FindTarget(0, j->first.c_str());
  964. if(tgt)
  965. {
  966. lib = cmSystemTools::GetFilenameWithoutExtension
  967. (tgt->GetFullName().c_str());
  968. libDebug = cmSystemTools::GetFilenameWithoutExtension
  969. (tgt->GetFullName("Debug").c_str());
  970. lib += ".lib";
  971. libDebug += ".lib";
  972. }
  973. else
  974. {
  975. lib = j->first.c_str();
  976. libDebug = j->first.c_str();
  977. if(j->first.find(".lib") == std::string::npos)
  978. {
  979. lib += ".lib";
  980. libDebug += ".lib";
  981. }
  982. }
  983. lib = this->ConvertToOptionallyRelativeOutputPath(lib.c_str());
  984. libDebug =
  985. this->ConvertToOptionallyRelativeOutputPath(libDebug.c_str());
  986. if (j->second == cmTarget::GENERAL)
  987. {
  988. libOptions += " ";
  989. libOptions += lib;
  990. libMultiLineOptions += "# ADD LINK32 ";
  991. libMultiLineOptions += lib;
  992. libMultiLineOptions += "\n";
  993. libMultiLineOptionsForDebug += "# ADD LINK32 ";
  994. libMultiLineOptionsForDebug += libDebug;
  995. libMultiLineOptionsForDebug += "\n";
  996. }
  997. if (j->second == cmTarget::DEBUG)
  998. {
  999. libDebugOptions += " ";
  1000. libDebugOptions += lib;
  1001. libMultiLineDebugOptions += "# ADD LINK32 ";
  1002. libMultiLineDebugOptions += libDebug;
  1003. libMultiLineDebugOptions += "\n";
  1004. }
  1005. if (j->second == cmTarget::OPTIMIZED)
  1006. {
  1007. libOptimizedOptions += " ";
  1008. libOptimizedOptions += lib;
  1009. libMultiLineOptimizedOptions += "# ADD LINK32 ";
  1010. libMultiLineOptimizedOptions += lib;
  1011. libMultiLineOptimizedOptions += "\n";
  1012. }
  1013. }
  1014. }
  1015. #endif
  1016. // Get extra linker options for this target type.
  1017. std::string extraLinkOptions;
  1018. if(target.GetType() == cmTarget::EXECUTABLE)
  1019. {
  1020. extraLinkOptions =
  1021. this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS");
  1022. }
  1023. if(target.GetType() == cmTarget::SHARED_LIBRARY)
  1024. {
  1025. extraLinkOptions =
  1026. this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS");
  1027. }
  1028. if(target.GetType() == cmTarget::MODULE_LIBRARY)
  1029. {
  1030. extraLinkOptions =
  1031. this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS");
  1032. }
  1033. // Get extra linker options for this target.
  1034. if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"))
  1035. {
  1036. extraLinkOptions += " ";
  1037. extraLinkOptions += targetLinkFlags;
  1038. }
  1039. // Get standard libraries for this language.
  1040. if(targetBuilds)
  1041. {
  1042. // Get the language to use for linking.
  1043. const char* linkLanguage = target.GetLinkerLanguage();
  1044. if(!linkLanguage)
  1045. {
  1046. cmSystemTools::Error
  1047. ("CMake can not determine linker language for target:",
  1048. target.GetName());
  1049. return;
  1050. }
  1051. // Compute the variable name to lookup standard libraries for this
  1052. // language.
  1053. std::string standardLibsVar = "CMAKE_";
  1054. standardLibsVar += linkLanguage;
  1055. standardLibsVar += "_STANDARD_LIBRARIES";
  1056. // Add standard libraries.
  1057. if(const char* stdLibs =
  1058. this->Makefile->GetDefinition(standardLibsVar.c_str()))
  1059. {
  1060. extraLinkOptions += " ";
  1061. extraLinkOptions += stdLibs;
  1062. }
  1063. }
  1064. // Compute version number information.
  1065. std::string targetVersionFlag;
  1066. if(target.GetType() == cmTarget::EXECUTABLE ||
  1067. target.GetType() == cmTarget::SHARED_LIBRARY ||
  1068. target.GetType() == cmTarget::MODULE_LIBRARY)
  1069. {
  1070. int major;
  1071. int minor;
  1072. target.GetTargetVersion(major, minor);
  1073. cmOStringStream targetVersionStream;
  1074. targetVersionStream << "/version:" << major << "." << minor;
  1075. targetVersionFlag = targetVersionStream.str();
  1076. }
  1077. // Compute the real name of the target.
  1078. std::string outputName =
  1079. "(OUTPUT_NAME is for libraries and executables only)";
  1080. std::string outputNameDebug = outputName;
  1081. std::string outputNameRelease = outputName;
  1082. std::string outputNameMinSizeRel = outputName;
  1083. std::string outputNameRelWithDebInfo = outputName;
  1084. if(target.GetType() == cmTarget::EXECUTABLE ||
  1085. target.GetType() == cmTarget::STATIC_LIBRARY ||
  1086. target.GetType() == cmTarget::SHARED_LIBRARY ||
  1087. target.GetType() == cmTarget::MODULE_LIBRARY)
  1088. {
  1089. outputName = target.GetFullName();
  1090. outputNameDebug = target.GetFullName("Debug");
  1091. outputNameRelease = target.GetFullName("Release");
  1092. outputNameMinSizeRel = target.GetFullName("MinSizeRel");
  1093. outputNameRelWithDebInfo = target.GetFullName("RelWithDebInfo");
  1094. }
  1095. // Compute the proper link information for the target.
  1096. std::string optionsDebug;
  1097. std::string optionsRelease;
  1098. std::string optionsMinSizeRel;
  1099. std::string optionsRelWithDebInfo;
  1100. if(target.GetType() == cmTarget::EXECUTABLE ||
  1101. target.GetType() == cmTarget::SHARED_LIBRARY ||
  1102. target.GetType() == cmTarget::MODULE_LIBRARY)
  1103. {
  1104. this->ComputeLinkOptions(target, "Debug", extraLinkOptions,
  1105. optionsDebug);
  1106. this->ComputeLinkOptions(target, "Release", extraLinkOptions,
  1107. optionsRelease);
  1108. this->ComputeLinkOptions(target, "MinSizeRel", extraLinkOptions,
  1109. optionsMinSizeRel);
  1110. this->ComputeLinkOptions(target, "RelWithDebInfo", extraLinkOptions,
  1111. optionsRelWithDebInfo);
  1112. }
  1113. // Compute the path of the import library.
  1114. std::string targetImplibFlagDebug;
  1115. std::string targetImplibFlagRelease;
  1116. std::string targetImplibFlagMinSizeRel;
  1117. std::string targetImplibFlagRelWithDebInfo;
  1118. if(target.GetType() == cmTarget::SHARED_LIBRARY ||
  1119. target.GetType() == cmTarget::MODULE_LIBRARY ||
  1120. target.GetType() == cmTarget::EXECUTABLE)
  1121. {
  1122. std::string fullPathImpDebug = target.GetDirectory("Debug", true);
  1123. std::string fullPathImpRelease = target.GetDirectory("Release", true);
  1124. std::string fullPathImpMinSizeRel =
  1125. target.GetDirectory("MinSizeRel", true);
  1126. std::string fullPathImpRelWithDebInfo =
  1127. target.GetDirectory("RelWithDebInfo", true);
  1128. fullPathImpDebug += "/";
  1129. fullPathImpRelease += "/";
  1130. fullPathImpMinSizeRel += "/";
  1131. fullPathImpRelWithDebInfo += "/";
  1132. fullPathImpDebug += target.GetFullName("Debug", true);
  1133. fullPathImpRelease += target.GetFullName("Release", true);
  1134. fullPathImpMinSizeRel += target.GetFullName("MinSizeRel", true);
  1135. fullPathImpRelWithDebInfo += target.GetFullName("RelWithDebInfo", true);
  1136. targetImplibFlagDebug = "/implib:";
  1137. targetImplibFlagRelease = "/implib:";
  1138. targetImplibFlagMinSizeRel = "/implib:";
  1139. targetImplibFlagRelWithDebInfo = "/implib:";
  1140. targetImplibFlagDebug +=
  1141. this->ConvertToOptionallyRelativeOutputPath(fullPathImpDebug.c_str());
  1142. targetImplibFlagRelease +=
  1143. this->ConvertToOptionallyRelativeOutputPath(fullPathImpRelease.c_str());
  1144. targetImplibFlagMinSizeRel +=
  1145. this->ConvertToOptionallyRelativeOutputPath(
  1146. fullPathImpMinSizeRel.c_str());
  1147. targetImplibFlagRelWithDebInfo +=
  1148. this->ConvertToOptionallyRelativeOutputPath(
  1149. fullPathImpRelWithDebInfo.c_str());
  1150. }
  1151. #ifdef CM_USE_OLD_VS6
  1152. // Compute link information for the target.
  1153. if(extraLinkOptions.size())
  1154. {
  1155. libOptions += " ";
  1156. libOptions += extraLinkOptions;
  1157. libOptions += " ";
  1158. libMultiLineOptions += "# ADD LINK32 ";
  1159. libMultiLineOptions += extraLinkOptions;
  1160. libMultiLineOptions += " \n";
  1161. libMultiLineOptionsForDebug += "# ADD LINK32 ";
  1162. libMultiLineOptionsForDebug += extraLinkOptions;
  1163. libMultiLineOptionsForDebug += " \n";
  1164. }
  1165. #endif
  1166. // are there any custom rules on the target itself
  1167. // only if the target is a lib or exe
  1168. std::string customRuleCodeRelease
  1169. = this->CreateTargetRules(target, "RELEASE", libName);
  1170. std::string customRuleCodeDebug
  1171. = this->CreateTargetRules(target, "DEBUG", libName);
  1172. std::string customRuleCodeMinSizeRel
  1173. = this->CreateTargetRules(target, "MINSIZEREL", libName);
  1174. std::string customRuleCodeRelWithDebInfo
  1175. = this->CreateTargetRules(target, "RELWITHDEBINFO", libName);
  1176. std::ifstream fin(this->DSPHeaderTemplate.c_str());
  1177. if(!fin)
  1178. {
  1179. cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str());
  1180. }
  1181. std::string staticLibOptions;
  1182. if(target.GetType() == cmTarget::STATIC_LIBRARY )
  1183. {
  1184. if(const char* libflags = target.GetProperty("STATIC_LIBRARY_FLAGS"))
  1185. {
  1186. staticLibOptions = libflags;
  1187. }
  1188. }
  1189. // Add the export symbol definition for shared library objects.
  1190. std::string exportSymbol;
  1191. if(const char* exportMacro = target.GetExportMacro())
  1192. {
  1193. exportSymbol = exportMacro;
  1194. }
  1195. std::string line;
  1196. std::string libnameExports;
  1197. if(exportSymbol.size())
  1198. {
  1199. libnameExports = "/D \"";
  1200. libnameExports += exportSymbol;
  1201. libnameExports += "\"";
  1202. }
  1203. while(cmSystemTools::GetLineFromStream(fin, line))
  1204. {
  1205. const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG");
  1206. if(!mfcFlag)
  1207. {
  1208. mfcFlag = "0";
  1209. }
  1210. cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME_EXPORTS",
  1211. libnameExports.c_str());
  1212. cmSystemTools::ReplaceString(line, "CMAKE_MFC_FLAG",
  1213. mfcFlag);
  1214. if(target.GetType() == cmTarget::STATIC_LIBRARY )
  1215. {
  1216. cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS",
  1217. staticLibOptions.c_str());
  1218. }
  1219. if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"))
  1220. {
  1221. cmSystemTools::ReplaceString(line, "/nologo", "");
  1222. }
  1223. #ifdef CM_USE_OLD_VS6
  1224. cmSystemTools::ReplaceString(line, "CM_LIBRARIES",
  1225. libOptions.c_str());
  1226. cmSystemTools::ReplaceString(line, "CM_DEBUG_LIBRARIES",
  1227. libDebugOptions.c_str());
  1228. cmSystemTools::ReplaceString(line, "CM_OPTIMIZED_LIBRARIES",
  1229. libOptimizedOptions.c_str());
  1230. cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES_FOR_DEBUG",
  1231. libMultiLineOptionsForDebug.c_str());
  1232. cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES",
  1233. libMultiLineOptions.c_str());
  1234. cmSystemTools::ReplaceString(line, "CM_MULTILINE_DEBUG_LIBRARIES",
  1235. libMultiLineDebugOptions.c_str());
  1236. cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIMIZED_LIBRARIES",
  1237. libMultiLineOptimizedOptions.c_str());
  1238. #endif
  1239. // Substitute the rules for custom command. When specifying just the
  1240. // target name for the command the command can be different for
  1241. // different configs
  1242. cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_RELEASE",
  1243. customRuleCodeRelease.c_str());
  1244. cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_DEBUG",
  1245. customRuleCodeDebug.c_str());
  1246. cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_MINSIZEREL",
  1247. customRuleCodeMinSizeRel.c_str());
  1248. cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO",
  1249. customRuleCodeRelWithDebInfo.c_str());
  1250. // Substitute the real output name into the template.
  1251. cmSystemTools::ReplaceString(line, "OUTPUT_NAME_DEBUG",
  1252. outputNameDebug.c_str());
  1253. cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELEASE",
  1254. outputNameRelease.c_str());
  1255. cmSystemTools::ReplaceString(line, "OUTPUT_NAME_MINSIZEREL",
  1256. outputNameMinSizeRel.c_str());
  1257. cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELWITHDEBINFO",
  1258. outputNameRelWithDebInfo.c_str());
  1259. cmSystemTools::ReplaceString(line, "OUTPUT_NAME", outputName.c_str());
  1260. // Substitute the proper link information into the template.
  1261. cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_DEBUG",
  1262. optionsDebug.c_str());
  1263. cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELEASE",
  1264. optionsRelease.c_str());
  1265. cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_MINSIZEREL",
  1266. optionsMinSizeRel.c_str());
  1267. cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELWITHDEBINFO",
  1268. optionsRelWithDebInfo.c_str());
  1269. cmSystemTools::ReplaceString(line, "BUILD_INCLUDES",
  1270. this->IncludeOptions.c_str());
  1271. cmSystemTools::ReplaceString(line, "TARGET_VERSION_FLAG",
  1272. targetVersionFlag.c_str());
  1273. cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_DEBUG",
  1274. targetImplibFlagDebug.c_str());
  1275. cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_RELEASE",
  1276. targetImplibFlagRelease.c_str());
  1277. cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_MINSIZEREL",
  1278. targetImplibFlagMinSizeRel.c_str());
  1279. cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_RELWITHDEBINFO",
  1280. targetImplibFlagRelWithDebInfo.c_str());
  1281. std::string vs6name = GetVS6TargetName(libName);
  1282. cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME", vs6name.c_str());
  1283. #ifdef CM_USE_OLD_VS6
  1284. // because LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH
  1285. // are already quoted in the template file,
  1286. // we need to remove the quotes here, we still need
  1287. // to convert to output path for unix to win32 conversion
  1288. cmSystemTools::ReplaceString
  1289. (line, "LIBRARY_OUTPUT_PATH",
  1290. removeQuotes(this->ConvertToOptionallyRelativeOutputPath
  1291. (libPath.c_str())).c_str());
  1292. cmSystemTools::ReplaceString
  1293. (line, "EXECUTABLE_OUTPUT_PATH",
  1294. removeQuotes(this->ConvertToOptionallyRelativeOutputPath
  1295. (exePath.c_str())).c_str());
  1296. #endif
  1297. if(targetBuilds)
  1298. {
  1299. std::string outPath = target.GetDirectory();
  1300. cmSystemTools::ReplaceString
  1301. (line, "OUTPUT_DIRECTORY",
  1302. removeQuotes(this->ConvertToOptionallyRelativeOutputPath
  1303. (outPath.c_str())).c_str());
  1304. }
  1305. cmSystemTools::ReplaceString(line,
  1306. "EXTRA_DEFINES",
  1307. this->Makefile->GetDefineFlags());
  1308. const char* debugPostfix
  1309. = this->Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
  1310. cmSystemTools::ReplaceString(line, "DEBUG_POSTFIX",
  1311. debugPostfix?debugPostfix:"");
  1312. // store flags for each configuration
  1313. std::string flags = " ";
  1314. std::string flagsRelease = " ";
  1315. std::string flagsMinSize = " ";
  1316. std::string flagsDebug = " ";
  1317. std::string flagsDebugRel = " ";
  1318. if(target.GetType() >= cmTarget::EXECUTABLE &&
  1319. target.GetType() <= cmTarget::MODULE_LIBRARY)
  1320. {
  1321. const char* linkLanguage = target.GetLinkerLanguage();
  1322. if(!linkLanguage)
  1323. {
  1324. cmSystemTools::Error
  1325. ("CMake can not determine linker language for target:",
  1326. target.GetName());
  1327. return;
  1328. }
  1329. // if CXX is on and the target contains cxx code then add the cxx flags
  1330. std::string baseFlagVar = "CMAKE_";
  1331. baseFlagVar += linkLanguage;
  1332. baseFlagVar += "_FLAGS";
  1333. flags = this->Makefile->GetSafeDefinition(baseFlagVar.c_str());
  1334. std::string flagVar = baseFlagVar + "_RELEASE";
  1335. flagsRelease = this->Makefile->GetSafeDefinition(flagVar.c_str());
  1336. flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
  1337. if(const char* targetLinkFlags =
  1338. target.GetProperty("LINK_FLAGS_RELEASE"))
  1339. {
  1340. flagsRelease += targetLinkFlags;
  1341. flagsRelease += " ";
  1342. }
  1343. flagVar = baseFlagVar + "_MINSIZEREL";
  1344. flagsMinSize = this->Makefile->GetSafeDefinition(flagVar.c_str());
  1345. flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
  1346. if(const char* targetLinkFlags =
  1347. target.GetProperty("LINK_FLAGS_MINSIZEREL"))
  1348. {
  1349. flagsMinSize += targetLinkFlags;
  1350. flagsMinSize += " ";
  1351. }
  1352. flagVar = baseFlagVar + "_DEBUG";
  1353. flagsDebug = this->Makefile->GetSafeDefinition(flagVar.c_str());
  1354. flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
  1355. if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_DEBUG"))
  1356. {
  1357. flagsDebug += targetLinkFlags;
  1358. flagsDebug += " ";
  1359. }
  1360. flagVar = baseFlagVar + "_RELWITHDEBINFO";
  1361. flagsDebugRel = this->Makefile->GetSafeDefinition(flagVar.c_str());
  1362. flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
  1363. if(const char* targetLinkFlags =
  1364. target.GetProperty("LINK_FLAGS_RELWITHDEBINFO"))
  1365. {
  1366. flagsDebugRel += targetLinkFlags;
  1367. flagsDebugRel += " ";
  1368. }
  1369. }
  1370. // if unicode is not found, then add -D_MBCS
  1371. std::string defs = this->Makefile->GetDefineFlags();
  1372. if(flags.find("D_UNICODE") == flags.npos &&
  1373. defs.find("D_UNICODE") == flags.npos)
  1374. {
  1375. flags += " /D \"_MBCS\"";
  1376. }
  1377. // Add per-target flags.
  1378. if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
  1379. {
  1380. flags += " ";
  1381. flags += targetFlags;
  1382. }
  1383. // Add per-target and per-configuration preprocessor definitions.
  1384. std::string defines = " ";
  1385. std::string debugDefines = " ";
  1386. std::string releaseDefines = " ";
  1387. std::string minsizeDefines = " ";
  1388. std::string debugrelDefines = " ";
  1389. this->AppendDefines(
  1390. defines,
  1391. this->Makefile->GetProperty("COMPILE_DEFINITIONS"), 0);
  1392. this->AppendDefines(
  1393. debugDefines,
  1394. this->Makefile->GetProperty("COMPILE_DEFINITIONS_DEBUG"),0);
  1395. this->AppendDefines(
  1396. releaseDefines,
  1397. this->Makefile->GetProperty("COMPILE_DEFINITIONS_RELEASE"), 0);
  1398. this->AppendDefines(
  1399. minsizeDefines,
  1400. this->Makefile->GetProperty("COMPILE_DEFINITIONS_MINSIZEREL"), 0);
  1401. this->AppendDefines(
  1402. debugrelDefines,
  1403. this->Makefile->GetProperty("COMPILE_DEFINITIONS_RELWITHDEBINFO"), 0);
  1404. this->AppendDefines(
  1405. defines,
  1406. target.GetProperty("COMPILE_DEFINITIONS"), 0);
  1407. this->AppendDefines(
  1408. debugDefines,
  1409. target.GetProperty("COMPILE_DEFINITIONS_DEBUG"), 0);
  1410. this->AppendDefines(
  1411. releaseDefines,
  1412. target.GetProperty("COMPILE_DEFINITIONS_RELEASE"), 0);
  1413. this->AppendDefines(
  1414. minsizeDefines,
  1415. target.GetProperty("COMPILE_DEFINITIONS_MINSIZEREL"), 0);
  1416. this->AppendDefines(
  1417. debugrelDefines,
  1418. target.GetProperty("COMPILE_DEFINITIONS_RELWITHDEBINFO"), 0);
  1419. flags += defines;
  1420. flagsDebug += debugDefines;
  1421. flagsRelease += releaseDefines;
  1422. flagsMinSize += minsizeDefines;
  1423. flagsDebugRel += debugrelDefines;
  1424. // The template files have CXX FLAGS in them, that need to be replaced.
  1425. // There are not separate CXX and C template files, so we use the same
  1426. // variable names. The previous code sets up flags* variables to contain
  1427. // the correct C or CXX flags
  1428. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL",
  1429. flagsMinSize.c_str());
  1430. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG",
  1431. flagsDebug.c_str());
  1432. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELWITHDEBINFO",
  1433. flagsDebugRel.c_str());
  1434. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE",
  1435. flagsRelease.c_str());
  1436. cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS", flags.c_str());
  1437. cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_MINSIZE",
  1438. minsizeDefines.c_str());
  1439. cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_DEBUG",
  1440. debugDefines.c_str());
  1441. cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_RELWITHDEBINFO",
  1442. debugrelDefines.c_str());
  1443. cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_RELEASE",
  1444. releaseDefines.c_str());
  1445. cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS", defines.c_str());
  1446. fout << line.c_str() << std::endl;
  1447. }
  1448. }
  1449. void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout)
  1450. {
  1451. std::ifstream fin(this->DSPFooterTemplate.c_str());
  1452. if(!fin)
  1453. {
  1454. cmSystemTools::Error("Error Reading ",
  1455. this->DSPFooterTemplate.c_str());
  1456. }
  1457. std::string line;
  1458. while(cmSystemTools::GetLineFromStream(fin, line))
  1459. {
  1460. fout << line << std::endl;
  1461. }
  1462. }
  1463. //----------------------------------------------------------------------------
  1464. void cmLocalVisualStudio6Generator
  1465. ::ComputeLinkOptions(cmTarget& target,
  1466. const char* configName,
  1467. const std::string extraOptions,
  1468. std::string& options)
  1469. {
  1470. // Compute the link information for this configuration.
  1471. cmComputeLinkInformation* pcli = target.GetLinkInformation(configName);
  1472. if(!pcli)
  1473. {
  1474. return;
  1475. }
  1476. cmComputeLinkInformation& cli = *pcli;
  1477. typedef cmComputeLinkInformation::ItemVector ItemVector;
  1478. ItemVector const& linkLibs = cli.GetItems();
  1479. std::vector<std::string> const& linkDirs = cli.GetDirectories();
  1480. // Build the link options code.
  1481. for(std::vector<std::string>::const_iterator d = linkDirs.begin();
  1482. d != linkDirs.end(); ++d)
  1483. {
  1484. std::string dir = *d;
  1485. if(!dir.empty())
  1486. {
  1487. if(dir[dir.size()-1] != '/')
  1488. {
  1489. dir += "/";
  1490. }
  1491. dir += "$(IntDir)";
  1492. options += "# ADD LINK32 /LIBPATH:";
  1493. options += this->ConvertToOptionallyRelativeOutputPath(dir.c_str());
  1494. options += " /LIBPATH:";
  1495. options += this->ConvertToOptionallyRelativeOutputPath(d->c_str());
  1496. options += "\n";
  1497. }
  1498. }
  1499. for(ItemVector::const_iterator l = linkLibs.begin();
  1500. l != linkLibs.end(); ++l)
  1501. {
  1502. options += "# ADD LINK32 ";
  1503. if(l->IsPath)
  1504. {
  1505. options +=
  1506. this->ConvertToOptionallyRelativeOutputPath(l->Value.c_str());
  1507. }
  1508. else
  1509. {
  1510. options += l->Value;
  1511. }
  1512. options += "\n";
  1513. }
  1514. // Add extra options if any.
  1515. if(!extraOptions.empty())
  1516. {
  1517. options += "# ADD LINK32 ";
  1518. options += extraOptions;
  1519. options += "\n";
  1520. }
  1521. }
  1522. std::string
  1523. cmLocalVisualStudio6Generator
  1524. ::GetTargetDirectory(cmTarget const&) const
  1525. {
  1526. // No per-target directory for this generator (yet).
  1527. return "";
  1528. }
  1529. void cmLocalVisualStudio6Generator
  1530. ::GetTargetObjectFileDirectories(cmTarget* ,
  1531. std::vector<std::string>&
  1532. dirs)
  1533. {
  1534. std::string dir = this->Makefile->GetCurrentOutputDirectory();
  1535. dir += "/";
  1536. dir += this->GetGlobalGenerator()->GetCMakeCFGInitDirectory();
  1537. dirs.push_back(dir);
  1538. }
  1539. std::string
  1540. cmLocalVisualStudio6Generator
  1541. ::GetConfigName(std::string const& configuration) const
  1542. {
  1543. // Strip the subdirectory name out of the configuration name.
  1544. std::string config = configuration;
  1545. std::string::size_type pos = config.find_last_of(" ");
  1546. config = config.substr(pos+1, std::string::npos);
  1547. config = config.substr(0, config.size()-1);
  1548. return config;
  1549. }
  1550. //----------------------------------------------------------------------------
  1551. bool
  1552. cmLocalVisualStudio6Generator
  1553. ::CheckDefinition(std::string const& define) const
  1554. {
  1555. // Perform the standard check first.
  1556. if(!this->cmLocalGenerator::CheckDefinition(define))
  1557. {
  1558. return false;
  1559. }
  1560. // Now do the VS6-specific check.
  1561. if(define.find_first_of(" ") != define.npos &&
  1562. define.find_first_of("\"$;") != define.npos)
  1563. {
  1564. cmOStringStream e;
  1565. e << "WARNING: The VS6 IDE does not support preprocessor definition "
  1566. << "values with spaces and '\"', '$', or ';'.\n"
  1567. << "CMake is dropping a preprocessor definition: " << define << "\n"
  1568. << "Consider defining the macro in a (configured) header file.\n";
  1569. cmSystemTools::Message(e.str().c_str());
  1570. return false;
  1571. }
  1572. // Assume it is supported.
  1573. return true;
  1574. }