cmLocalVisualStudio6Generator.cxx 57 KB

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