cmLocalVisualStudio6Generator.cxx 57 KB

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