cmExportFileGenerator.cxx 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmExportFileGenerator.h"
  11. #include "cmExportSet.h"
  12. #include "cmGeneratedFileStream.h"
  13. #include "cmGlobalGenerator.h"
  14. #include "cmInstallExportGenerator.h"
  15. #include "cmLocalGenerator.h"
  16. #include "cmMakefile.h"
  17. #include "cmSystemTools.h"
  18. #include "cmTarget.h"
  19. #include "cmTargetExport.h"
  20. #include "cmVersion.h"
  21. #include "cmComputeLinkInformation.h"
  22. #include "cmAlgorithms.h"
  23. #include "cmOutputConverter.h"
  24. #include <cmsys/auto_ptr.hxx>
  25. #include <cmsys/FStream.hxx>
  26. #include <assert.h>
  27. //----------------------------------------------------------------------------
  28. static std::string cmExportFileGeneratorEscape(std::string const& str)
  29. {
  30. // Escape a property value for writing into a .cmake file.
  31. std::string result = cmOutputConverter::EscapeForCMake(str);
  32. // Un-escape variable references generated by our own export code.
  33. cmSystemTools::ReplaceString(result,
  34. "\\${_IMPORT_PREFIX}",
  35. "${_IMPORT_PREFIX}");
  36. cmSystemTools::ReplaceString(result,
  37. "\\${CMAKE_IMPORT_LIBRARY_SUFFIX}",
  38. "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
  39. return result;
  40. }
  41. //----------------------------------------------------------------------------
  42. cmExportFileGenerator::cmExportFileGenerator()
  43. {
  44. this->AppendMode = false;
  45. this->ExportOld = false;
  46. }
  47. //----------------------------------------------------------------------------
  48. void cmExportFileGenerator::AddConfiguration(const std::string& config)
  49. {
  50. this->Configurations.push_back(config);
  51. }
  52. //----------------------------------------------------------------------------
  53. void cmExportFileGenerator::SetExportFile(const char* mainFile)
  54. {
  55. this->MainImportFile = mainFile;
  56. this->FileDir =
  57. cmSystemTools::GetFilenamePath(this->MainImportFile);
  58. this->FileBase =
  59. cmSystemTools::GetFilenameWithoutLastExtension(this->MainImportFile);
  60. this->FileExt =
  61. cmSystemTools::GetFilenameLastExtension(this->MainImportFile);
  62. }
  63. //----------------------------------------------------------------------------
  64. const char* cmExportFileGenerator::GetMainExportFileName() const
  65. {
  66. return this->MainImportFile.c_str();
  67. }
  68. //----------------------------------------------------------------------------
  69. bool cmExportFileGenerator::GenerateImportFile()
  70. {
  71. // Open the output file to generate it.
  72. cmsys::auto_ptr<cmsys::ofstream> foutPtr;
  73. if(this->AppendMode)
  74. {
  75. // Open for append.
  76. cmsys::auto_ptr<cmsys::ofstream>
  77. ap(new cmsys::ofstream(this->MainImportFile.c_str(), std::ios::app));
  78. foutPtr = ap;
  79. }
  80. else
  81. {
  82. // Generate atomically and with copy-if-different.
  83. cmsys::auto_ptr<cmGeneratedFileStream>
  84. ap(new cmGeneratedFileStream(this->MainImportFile.c_str(), true));
  85. ap->SetCopyIfDifferent(true);
  86. foutPtr = ap;
  87. }
  88. if(!foutPtr.get() || !*foutPtr)
  89. {
  90. std::string se = cmSystemTools::GetLastSystemError();
  91. std::ostringstream e;
  92. e << "cannot write to file \"" << this->MainImportFile
  93. << "\": " << se;
  94. cmSystemTools::Error(e.str().c_str());
  95. return false;
  96. }
  97. std::ostream& os = *foutPtr;
  98. // Protect that file against use with older CMake versions.
  99. os << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n";
  100. os << "if(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n"
  101. << " message(FATAL_ERROR \"CMake >= 2.6.0 required\")\n"
  102. << "endif()\n";
  103. // Isolate the file policy level.
  104. // We use 2.6 here instead of the current version because newer
  105. // versions of CMake should be able to export files imported by 2.6
  106. // until the import format changes.
  107. os << "cmake_policy(PUSH)\n"
  108. << "cmake_policy(VERSION 2.6)\n";
  109. // Start with the import file header.
  110. this->GenerateImportHeaderCode(os);
  111. // Create all the imported targets.
  112. bool result = this->GenerateMainFile(os);
  113. // End with the import file footer.
  114. this->GenerateImportFooterCode(os);
  115. os << "cmake_policy(POP)\n";
  116. return result;
  117. }
  118. //----------------------------------------------------------------------------
  119. void cmExportFileGenerator::GenerateImportConfig(std::ostream& os,
  120. const std::string& config,
  121. std::vector<std::string> &missingTargets)
  122. {
  123. // Construct the property configuration suffix.
  124. std::string suffix = "_";
  125. if(!config.empty())
  126. {
  127. suffix += cmSystemTools::UpperCase(config);
  128. }
  129. else
  130. {
  131. suffix += "NOCONFIG";
  132. }
  133. // Generate the per-config target information.
  134. this->GenerateImportTargetsConfig(os, config, suffix, missingTargets);
  135. }
  136. //----------------------------------------------------------------------------
  137. void cmExportFileGenerator::PopulateInterfaceProperty(
  138. const std::string& propName,
  139. cmTarget *target,
  140. ImportPropertyMap &properties)
  141. {
  142. const char *input = target->GetProperty(propName);
  143. if (input)
  144. {
  145. properties[propName] = input;
  146. }
  147. }
  148. //----------------------------------------------------------------------------
  149. void cmExportFileGenerator::PopulateInterfaceProperty(
  150. const std::string& propName,
  151. const std::string& outputName,
  152. cmTarget *target,
  153. cmGeneratorExpression::PreprocessContext preprocessRule,
  154. ImportPropertyMap &properties,
  155. std::vector<std::string> &missingTargets)
  156. {
  157. const char *input = target->GetProperty(propName);
  158. if (input)
  159. {
  160. if (!*input)
  161. {
  162. // Set to empty
  163. properties[outputName] = "";
  164. return;
  165. }
  166. std::string prepro = cmGeneratorExpression::Preprocess(input,
  167. preprocessRule);
  168. if (!prepro.empty())
  169. {
  170. this->ResolveTargetsInGeneratorExpressions(prepro, target,
  171. missingTargets);
  172. properties[outputName] = prepro;
  173. }
  174. }
  175. }
  176. void cmExportFileGenerator::GenerateRequiredCMakeVersion(std::ostream& os,
  177. const char *versionString)
  178. {
  179. os << "if(CMAKE_VERSION VERSION_LESS " << versionString << ")\n"
  180. " message(FATAL_ERROR \"This file relies on consumers using "
  181. "CMake " << versionString << " or greater.\")\n"
  182. "endif()\n\n";
  183. }
  184. //----------------------------------------------------------------------------
  185. bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty(
  186. cmTarget *target,
  187. cmGeneratorExpression::PreprocessContext preprocessRule,
  188. ImportPropertyMap &properties,
  189. std::vector<std::string> &missingTargets)
  190. {
  191. if(!target->IsLinkable())
  192. {
  193. return false;
  194. }
  195. const char *input = target->GetProperty("INTERFACE_LINK_LIBRARIES");
  196. if (input)
  197. {
  198. std::string prepro = cmGeneratorExpression::Preprocess(input,
  199. preprocessRule);
  200. if (!prepro.empty())
  201. {
  202. this->ResolveTargetsInGeneratorExpressions(prepro, target,
  203. missingTargets,
  204. ReplaceFreeTargets);
  205. properties["INTERFACE_LINK_LIBRARIES"] = prepro;
  206. return true;
  207. }
  208. }
  209. return false;
  210. }
  211. //----------------------------------------------------------------------------
  212. static bool isSubDirectory(const char* a, const char* b)
  213. {
  214. return (cmSystemTools::ComparePath(a, b) ||
  215. cmSystemTools::IsSubDirectory(a, b));
  216. }
  217. //----------------------------------------------------------------------------
  218. static bool checkInterfaceDirs(const std::string &prepro,
  219. cmTarget *target, const std::string& prop)
  220. {
  221. const char* installDir =
  222. target->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
  223. const char* topSourceDir = target->GetMakefile()->GetHomeDirectory();
  224. const char* topBinaryDir = target->GetMakefile()->GetHomeOutputDirectory();
  225. std::vector<std::string> parts;
  226. cmGeneratorExpression::Split(prepro, parts);
  227. const bool inSourceBuild = strcmp(topSourceDir, topBinaryDir) == 0;
  228. bool hadFatalError = false;
  229. for(std::vector<std::string>::iterator li = parts.begin();
  230. li != parts.end(); ++li)
  231. {
  232. size_t genexPos = cmGeneratorExpression::Find(*li);
  233. if (genexPos == 0)
  234. {
  235. continue;
  236. }
  237. cmake::MessageType messageType = cmake::FATAL_ERROR;
  238. std::ostringstream e;
  239. if (genexPos != std::string::npos)
  240. {
  241. if (prop == "INTERFACE_INCLUDE_DIRECTORIES")
  242. {
  243. switch (target->GetPolicyStatusCMP0041())
  244. {
  245. case cmPolicies::WARN:
  246. messageType = cmake::WARNING;
  247. e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0041) << "\n";
  248. break;
  249. case cmPolicies::OLD:
  250. continue;
  251. case cmPolicies::REQUIRED_IF_USED:
  252. case cmPolicies::REQUIRED_ALWAYS:
  253. case cmPolicies::NEW:
  254. hadFatalError = true;
  255. break; // Issue fatal message.
  256. }
  257. }
  258. else
  259. {
  260. hadFatalError = true;
  261. }
  262. }
  263. if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}"))
  264. {
  265. continue;
  266. }
  267. if (!cmSystemTools::FileIsFullPath(li->c_str()))
  268. {
  269. e << "Target \"" << target->GetName() << "\" " << prop <<
  270. " property contains relative path:\n"
  271. " \"" << *li << "\"";
  272. target->GetMakefile()->IssueMessage(messageType, e.str());
  273. }
  274. bool inBinary = isSubDirectory(li->c_str(), topBinaryDir);
  275. bool inSource = isSubDirectory(li->c_str(), topSourceDir);
  276. if (isSubDirectory(li->c_str(), installDir))
  277. {
  278. // The include directory is inside the install tree. If the
  279. // install tree is not inside the source tree or build tree then
  280. // fall through to the checks below that the include directory is not
  281. // also inside the source tree or build tree.
  282. bool shouldContinue =
  283. (!inBinary || isSubDirectory(installDir, topBinaryDir)) &&
  284. (!inSource || isSubDirectory(installDir, topSourceDir));
  285. if (prop == "INTERFACE_INCLUDE_DIRECTORIES")
  286. {
  287. if (!shouldContinue)
  288. {
  289. switch(target->GetPolicyStatusCMP0052())
  290. {
  291. case cmPolicies::WARN:
  292. {
  293. std::ostringstream s;
  294. s << cmPolicies::GetPolicyWarning(cmPolicies::CMP0052) << "\n";
  295. s << "Directory:\n \"" << *li << "\"\nin "
  296. "INTERFACE_INCLUDE_DIRECTORIES of target \""
  297. << target->GetName() << "\" is a subdirectory of the install "
  298. "directory:\n \"" << installDir << "\"\nhowever it is also "
  299. "a subdirectory of the " << (inBinary ? "build" : "source")
  300. << " tree:\n \"" << (inBinary ? topBinaryDir : topSourceDir)
  301. << "\"" << std::endl;
  302. target->GetMakefile()->IssueMessage(cmake::AUTHOR_WARNING,
  303. s.str());
  304. }
  305. case cmPolicies::OLD:
  306. shouldContinue = true;
  307. break;
  308. case cmPolicies::REQUIRED_ALWAYS:
  309. case cmPolicies::REQUIRED_IF_USED:
  310. case cmPolicies::NEW:
  311. break;
  312. }
  313. }
  314. }
  315. if (shouldContinue)
  316. {
  317. continue;
  318. }
  319. }
  320. if (inBinary)
  321. {
  322. e << "Target \"" << target->GetName() << "\" " << prop <<
  323. " property contains path:\n"
  324. " \"" << *li << "\"\nwhich is prefixed in the build directory.";
  325. target->GetMakefile()->IssueMessage(messageType, e.str());
  326. }
  327. if (!inSourceBuild)
  328. {
  329. if (inSource)
  330. {
  331. e << "Target \"" << target->GetName() << "\" " << prop <<
  332. " property contains path:\n"
  333. " \"" << *li << "\"\nwhich is prefixed in the source directory.";
  334. target->GetMakefile()->IssueMessage(messageType, e.str());
  335. }
  336. }
  337. }
  338. return !hadFatalError;
  339. }
  340. //----------------------------------------------------------------------------
  341. static void prefixItems(std::string &exportDirs)
  342. {
  343. std::vector<std::string> entries;
  344. cmGeneratorExpression::Split(exportDirs, entries);
  345. exportDirs = "";
  346. const char *sep = "";
  347. for(std::vector<std::string>::const_iterator ei = entries.begin();
  348. ei != entries.end(); ++ei)
  349. {
  350. exportDirs += sep;
  351. sep = ";";
  352. if (!cmSystemTools::FileIsFullPath(ei->c_str())
  353. && ei->find("${_IMPORT_PREFIX}") == std::string::npos)
  354. {
  355. exportDirs += "${_IMPORT_PREFIX}/";
  356. }
  357. exportDirs += *ei;
  358. }
  359. }
  360. //----------------------------------------------------------------------------
  361. void cmExportFileGenerator::PopulateSourcesInterface(
  362. cmTargetExport *tei,
  363. cmGeneratorExpression::PreprocessContext preprocessRule,
  364. ImportPropertyMap &properties,
  365. std::vector<std::string> &missingTargets)
  366. {
  367. cmTarget *target = tei->Target;
  368. assert(preprocessRule == cmGeneratorExpression::InstallInterface);
  369. const char *propName = "INTERFACE_SOURCES";
  370. const char *input = target->GetProperty(propName);
  371. if (!input)
  372. {
  373. return;
  374. }
  375. if (!*input)
  376. {
  377. properties[propName] = "";
  378. return;
  379. }
  380. std::string prepro = cmGeneratorExpression::Preprocess(input,
  381. preprocessRule,
  382. true);
  383. if (!prepro.empty())
  384. {
  385. this->ResolveTargetsInGeneratorExpressions(prepro, target,
  386. missingTargets);
  387. if (!checkInterfaceDirs(prepro, target, propName))
  388. {
  389. return;
  390. }
  391. properties[propName] = prepro;
  392. }
  393. }
  394. //----------------------------------------------------------------------------
  395. void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
  396. cmTargetExport *tei,
  397. cmGeneratorExpression::PreprocessContext preprocessRule,
  398. ImportPropertyMap &properties,
  399. std::vector<std::string> &missingTargets)
  400. {
  401. cmTarget *target = tei->Target;
  402. assert(preprocessRule == cmGeneratorExpression::InstallInterface);
  403. const char *propName = "INTERFACE_INCLUDE_DIRECTORIES";
  404. const char *input = target->GetProperty(propName);
  405. cmGeneratorExpression ge;
  406. std::string dirs = cmGeneratorExpression::Preprocess(
  407. tei->InterfaceIncludeDirectories,
  408. preprocessRule,
  409. true);
  410. this->ReplaceInstallPrefix(dirs);
  411. cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
  412. std::string exportDirs = cge->Evaluate(target->GetMakefile(), "",
  413. false, target);
  414. if (cge->GetHadContextSensitiveCondition())
  415. {
  416. cmMakefile* mf = target->GetMakefile();
  417. std::ostringstream e;
  418. e << "Target \"" << target->GetName() << "\" is installed with "
  419. "INCLUDES DESTINATION set to a context sensitive path. Paths which "
  420. "depend on the configuration, policy values or the link interface are "
  421. "not supported. Consider using target_include_directories instead.";
  422. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  423. return;
  424. }
  425. if (!input && exportDirs.empty())
  426. {
  427. return;
  428. }
  429. if ((input && !*input) && exportDirs.empty())
  430. {
  431. // Set to empty
  432. properties[propName] = "";
  433. return;
  434. }
  435. prefixItems(exportDirs);
  436. std::string includes = (input?input:"");
  437. const char* sep = input ? ";" : "";
  438. includes += sep + exportDirs;
  439. std::string prepro = cmGeneratorExpression::Preprocess(includes,
  440. preprocessRule,
  441. true);
  442. if (!prepro.empty())
  443. {
  444. this->ResolveTargetsInGeneratorExpressions(prepro, target,
  445. missingTargets);
  446. if (!checkInterfaceDirs(prepro, target, propName))
  447. {
  448. return;
  449. }
  450. properties[propName] = prepro;
  451. }
  452. }
  453. //----------------------------------------------------------------------------
  454. void cmExportFileGenerator::PopulateInterfaceProperty(
  455. const std::string& propName,
  456. cmTarget *target,
  457. cmGeneratorExpression::PreprocessContext preprocessRule,
  458. ImportPropertyMap &properties,
  459. std::vector<std::string> &missingTargets)
  460. {
  461. this->PopulateInterfaceProperty(propName, propName, target, preprocessRule,
  462. properties, missingTargets);
  463. }
  464. //----------------------------------------------------------------------------
  465. void getPropertyContents(cmTarget const* tgt, const std::string& prop,
  466. std::set<std::string> &ifaceProperties)
  467. {
  468. const char *p = tgt->GetProperty(prop);
  469. if (!p)
  470. {
  471. return;
  472. }
  473. std::vector<std::string> content;
  474. cmSystemTools::ExpandListArgument(p, content);
  475. ifaceProperties.insert(content.begin(), content.end());
  476. }
  477. //----------------------------------------------------------------------------
  478. void getCompatibleInterfaceProperties(cmGeneratorTarget *target,
  479. std::set<std::string> &ifaceProperties,
  480. const std::string& config)
  481. {
  482. cmComputeLinkInformation *info = target->GetLinkInformation(config);
  483. if (!info)
  484. {
  485. cmMakefile* mf = target->Target->GetMakefile();
  486. std::ostringstream e;
  487. e << "Exporting the target \"" << target->GetName() << "\" is not "
  488. "allowed since its linker language cannot be determined";
  489. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  490. return;
  491. }
  492. const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
  493. for(cmComputeLinkInformation::ItemVector::const_iterator li =
  494. deps.begin();
  495. li != deps.end(); ++li)
  496. {
  497. if (!li->Target)
  498. {
  499. continue;
  500. }
  501. getPropertyContents(li->Target,
  502. "COMPATIBLE_INTERFACE_BOOL",
  503. ifaceProperties);
  504. getPropertyContents(li->Target,
  505. "COMPATIBLE_INTERFACE_STRING",
  506. ifaceProperties);
  507. getPropertyContents(li->Target,
  508. "COMPATIBLE_INTERFACE_NUMBER_MIN",
  509. ifaceProperties);
  510. getPropertyContents(li->Target,
  511. "COMPATIBLE_INTERFACE_NUMBER_MAX",
  512. ifaceProperties);
  513. }
  514. }
  515. //----------------------------------------------------------------------------
  516. void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
  517. cmGeneratorTarget *gtarget,
  518. ImportPropertyMap &properties)
  519. {
  520. cmTarget *target = gtarget->Target;
  521. this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL",
  522. target, properties);
  523. this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING",
  524. target, properties);
  525. this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN",
  526. target, properties);
  527. this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX",
  528. target, properties);
  529. std::set<std::string> ifaceProperties;
  530. getPropertyContents(target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties);
  531. getPropertyContents(target, "COMPATIBLE_INTERFACE_STRING", ifaceProperties);
  532. getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MIN",
  533. ifaceProperties);
  534. getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MAX",
  535. ifaceProperties);
  536. if (target->GetType() != cmTarget::INTERFACE_LIBRARY)
  537. {
  538. getCompatibleInterfaceProperties(gtarget, ifaceProperties, "");
  539. std::vector<std::string> configNames;
  540. target->GetMakefile()->GetConfigurations(configNames);
  541. for (std::vector<std::string>::const_iterator ci = configNames.begin();
  542. ci != configNames.end(); ++ci)
  543. {
  544. getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci);
  545. }
  546. }
  547. for (std::set<std::string>::const_iterator it = ifaceProperties.begin();
  548. it != ifaceProperties.end(); ++it)
  549. {
  550. this->PopulateInterfaceProperty("INTERFACE_" + *it,
  551. target, properties);
  552. }
  553. }
  554. //----------------------------------------------------------------------------
  555. void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* target,
  556. std::ostream& os,
  557. const ImportPropertyMap &properties)
  558. {
  559. if (!properties.empty())
  560. {
  561. std::string targetName = this->Namespace;
  562. targetName += target->GetExportName();
  563. os << "set_target_properties(" << targetName << " PROPERTIES\n";
  564. for(ImportPropertyMap::const_iterator pi = properties.begin();
  565. pi != properties.end(); ++pi)
  566. {
  567. os << " " << pi->first << " "
  568. << cmExportFileGeneratorEscape(pi->second) << "\n";
  569. }
  570. os << ")\n\n";
  571. }
  572. }
  573. //----------------------------------------------------------------------------
  574. bool
  575. cmExportFileGenerator::AddTargetNamespace(std::string &input,
  576. cmTarget* target,
  577. std::vector<std::string> &missingTargets)
  578. {
  579. cmMakefile *mf = target->GetMakefile();
  580. cmTarget *tgt = mf->FindTargetToUse(input);
  581. if (!tgt)
  582. {
  583. return false;
  584. }
  585. if(tgt->IsImported())
  586. {
  587. return true;
  588. }
  589. if(this->ExportedTargets.find(tgt) != this->ExportedTargets.end())
  590. {
  591. input = this->Namespace + tgt->GetExportName();
  592. }
  593. else
  594. {
  595. std::string namespacedTarget;
  596. this->HandleMissingTarget(namespacedTarget, missingTargets,
  597. mf, target, tgt);
  598. if (!namespacedTarget.empty())
  599. {
  600. input = namespacedTarget;
  601. }
  602. }
  603. return true;
  604. }
  605. //----------------------------------------------------------------------------
  606. void
  607. cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
  608. std::string &input,
  609. cmTarget* target,
  610. std::vector<std::string> &missingTargets,
  611. FreeTargetsReplace replace)
  612. {
  613. if (replace == NoReplaceFreeTargets)
  614. {
  615. this->ResolveTargetsInGeneratorExpression(input, target, missingTargets);
  616. return;
  617. }
  618. std::vector<std::string> parts;
  619. cmGeneratorExpression::Split(input, parts);
  620. std::string sep;
  621. input = "";
  622. for(std::vector<std::string>::iterator li = parts.begin();
  623. li != parts.end(); ++li)
  624. {
  625. if (cmGeneratorExpression::Find(*li) == std::string::npos)
  626. {
  627. this->AddTargetNamespace(*li, target, missingTargets);
  628. }
  629. else
  630. {
  631. this->ResolveTargetsInGeneratorExpression(
  632. *li,
  633. target,
  634. missingTargets);
  635. }
  636. input += sep + *li;
  637. sep = ";";
  638. }
  639. }
  640. //----------------------------------------------------------------------------
  641. void
  642. cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
  643. std::string &input,
  644. cmTarget* target,
  645. std::vector<std::string> &missingTargets)
  646. {
  647. std::string::size_type pos = 0;
  648. std::string::size_type lastPos = pos;
  649. cmMakefile *mf = target->GetMakefile();
  650. while((pos = input.find("$<TARGET_PROPERTY:", lastPos)) != input.npos)
  651. {
  652. std::string::size_type nameStartPos = pos +
  653. sizeof("$<TARGET_PROPERTY:") - 1;
  654. std::string::size_type closePos = input.find(">", nameStartPos);
  655. std::string::size_type commaPos = input.find(",", nameStartPos);
  656. std::string::size_type nextOpenPos = input.find("$<", nameStartPos);
  657. if (commaPos == input.npos // Implied 'this' target
  658. || closePos == input.npos // Imcomplete expression.
  659. || closePos < commaPos // Implied 'this' target
  660. || nextOpenPos < commaPos) // Non-literal
  661. {
  662. lastPos = nameStartPos;
  663. continue;
  664. }
  665. std::string targetName = input.substr(nameStartPos,
  666. commaPos - nameStartPos);
  667. if (this->AddTargetNamespace(targetName, target, missingTargets))
  668. {
  669. input.replace(nameStartPos, commaPos - nameStartPos, targetName);
  670. }
  671. lastPos = nameStartPos + targetName.size() + 1;
  672. }
  673. std::string errorString;
  674. pos = 0;
  675. lastPos = pos;
  676. while((pos = input.find("$<TARGET_NAME:", lastPos)) != input.npos)
  677. {
  678. std::string::size_type nameStartPos = pos + sizeof("$<TARGET_NAME:") - 1;
  679. std::string::size_type endPos = input.find(">", nameStartPos);
  680. if (endPos == input.npos)
  681. {
  682. errorString = "$<TARGET_NAME:...> expression incomplete";
  683. break;
  684. }
  685. std::string targetName = input.substr(nameStartPos,
  686. endPos - nameStartPos);
  687. if(targetName.find("$<") != input.npos)
  688. {
  689. errorString = "$<TARGET_NAME:...> requires its parameter to be a "
  690. "literal.";
  691. break;
  692. }
  693. if (!this->AddTargetNamespace(targetName, target, missingTargets))
  694. {
  695. errorString = "$<TARGET_NAME:...> requires its parameter to be a "
  696. "reachable target.";
  697. break;
  698. }
  699. input.replace(pos, endPos - pos + 1, targetName);
  700. lastPos = endPos;
  701. }
  702. this->ReplaceInstallPrefix(input);
  703. if (!errorString.empty())
  704. {
  705. mf->IssueMessage(cmake::FATAL_ERROR, errorString);
  706. }
  707. }
  708. //----------------------------------------------------------------------------
  709. void
  710. cmExportFileGenerator::ReplaceInstallPrefix(std::string &)
  711. {
  712. // Do nothing
  713. }
  714. //----------------------------------------------------------------------------
  715. void
  716. cmExportFileGenerator
  717. ::SetImportLinkInterface(const std::string& config, std::string const& suffix,
  718. cmGeneratorExpression::PreprocessContext preprocessRule,
  719. cmGeneratorTarget* target, ImportPropertyMap& properties,
  720. std::vector<std::string>& missingTargets)
  721. {
  722. // Add the transitive link dependencies for this configuration.
  723. cmLinkInterface const* iface = target->GetLinkInterface(config,
  724. target->Target);
  725. if (!iface)
  726. {
  727. return;
  728. }
  729. if (iface->ImplementationIsInterface)
  730. {
  731. // Policy CMP0022 must not be NEW.
  732. this->SetImportLinkProperty(suffix, target,
  733. "IMPORTED_LINK_INTERFACE_LIBRARIES",
  734. iface->Libraries, properties, missingTargets);
  735. return;
  736. }
  737. const char *propContent;
  738. if (const char *prop_suffixed = target->GetProperty(
  739. "LINK_INTERFACE_LIBRARIES" + suffix))
  740. {
  741. propContent = prop_suffixed;
  742. }
  743. else if (const char *prop = target->GetProperty(
  744. "LINK_INTERFACE_LIBRARIES"))
  745. {
  746. propContent = prop;
  747. }
  748. else
  749. {
  750. return;
  751. }
  752. const bool newCMP0022Behavior =
  753. target->Target
  754. ->GetPolicyStatusCMP0022() != cmPolicies::WARN
  755. && target->Target
  756. ->GetPolicyStatusCMP0022() != cmPolicies::OLD;
  757. if(newCMP0022Behavior && !this->ExportOld)
  758. {
  759. cmMakefile *mf = target->Target->GetMakefile();
  760. std::ostringstream e;
  761. e << "Target \"" << target->GetName() << "\" has policy CMP0022 enabled, "
  762. "but also has old-style LINK_INTERFACE_LIBRARIES properties "
  763. "populated, but it was exported without the "
  764. "EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties";
  765. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  766. return;
  767. }
  768. if (!*propContent)
  769. {
  770. properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = "";
  771. return;
  772. }
  773. std::string prepro = cmGeneratorExpression::Preprocess(propContent,
  774. preprocessRule);
  775. if (!prepro.empty())
  776. {
  777. this->ResolveTargetsInGeneratorExpressions(prepro, target->Target,
  778. missingTargets,
  779. ReplaceFreeTargets);
  780. properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro;
  781. }
  782. }
  783. //----------------------------------------------------------------------------
  784. void
  785. cmExportFileGenerator
  786. ::SetImportDetailProperties(const std::string& config,
  787. std::string const& suffix,
  788. cmGeneratorTarget* target,
  789. ImportPropertyMap& properties,
  790. std::vector<std::string>& missingTargets
  791. )
  792. {
  793. // Get the makefile in which to lookup target information.
  794. cmMakefile* mf = target->Makefile;
  795. // Add the soname for unix shared libraries.
  796. if(target->GetType() == cmTarget::SHARED_LIBRARY ||
  797. target->GetType() == cmTarget::MODULE_LIBRARY)
  798. {
  799. // Check whether this is a DLL platform.
  800. bool dll_platform =
  801. (mf->IsOn("WIN32") || mf->IsOn("CYGWIN") || mf->IsOn("MINGW"));
  802. if(!dll_platform)
  803. {
  804. std::string prop;
  805. std::string value;
  806. if(target->HasSOName(config))
  807. {
  808. if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
  809. {
  810. value = this->InstallNameDir(target, config);
  811. }
  812. prop = "IMPORTED_SONAME";
  813. value += target->GetSOName(config);
  814. }
  815. else
  816. {
  817. prop = "IMPORTED_NO_SONAME";
  818. value = "TRUE";
  819. }
  820. prop += suffix;
  821. properties[prop] = value;
  822. }
  823. }
  824. // Add the transitive link dependencies for this configuration.
  825. if(cmLinkInterface const* iface =
  826. target->GetLinkInterface(config, target->Target))
  827. {
  828. this->SetImportLinkProperty(suffix, target,
  829. "IMPORTED_LINK_INTERFACE_LANGUAGES",
  830. iface->Languages, properties, missingTargets);
  831. std::vector<std::string> dummy;
  832. this->SetImportLinkProperty(suffix, target,
  833. "IMPORTED_LINK_DEPENDENT_LIBRARIES",
  834. iface->SharedDeps, properties, dummy);
  835. if(iface->Multiplicity > 0)
  836. {
  837. std::string prop = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
  838. prop += suffix;
  839. std::ostringstream m;
  840. m << iface->Multiplicity;
  841. properties[prop] = m.str();
  842. }
  843. }
  844. }
  845. //----------------------------------------------------------------------------
  846. template <typename T>
  847. void
  848. cmExportFileGenerator
  849. ::SetImportLinkProperty(std::string const& suffix,
  850. cmGeneratorTarget* target,
  851. const std::string& propName,
  852. std::vector<T> const& entries,
  853. ImportPropertyMap& properties,
  854. std::vector<std::string>& missingTargets
  855. )
  856. {
  857. // Skip the property if there are no entries.
  858. if(entries.empty())
  859. {
  860. return;
  861. }
  862. // Construct the property value.
  863. std::string link_entries;
  864. const char* sep = "";
  865. for(typename std::vector<T>::const_iterator li = entries.begin();
  866. li != entries.end(); ++li)
  867. {
  868. // Separate this from the previous entry.
  869. link_entries += sep;
  870. sep = ";";
  871. std::string temp = *li;
  872. this->AddTargetNamespace(temp, target->Target, missingTargets);
  873. link_entries += temp;
  874. }
  875. // Store the property.
  876. std::string prop = propName;
  877. prop += suffix;
  878. properties[prop] = link_entries;
  879. }
  880. //----------------------------------------------------------------------------
  881. void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os,
  882. const std::string& config)
  883. {
  884. os << "#----------------------------------------------------------------\n"
  885. << "# Generated CMake target import file";
  886. if(!config.empty())
  887. {
  888. os << " for configuration \"" << config << "\".\n";
  889. }
  890. else
  891. {
  892. os << ".\n";
  893. }
  894. os << "#----------------------------------------------------------------\n"
  895. << "\n";
  896. this->GenerateImportVersionCode(os);
  897. }
  898. //----------------------------------------------------------------------------
  899. void cmExportFileGenerator::GenerateImportFooterCode(std::ostream& os)
  900. {
  901. os << "# Commands beyond this point should not need to know the version.\n"
  902. << "set(CMAKE_IMPORT_FILE_VERSION)\n";
  903. }
  904. //----------------------------------------------------------------------------
  905. void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os)
  906. {
  907. // Store an import file format version. This will let us change the
  908. // format later while still allowing old import files to work.
  909. os << "# Commands may need to know the format version.\n"
  910. << "set(CMAKE_IMPORT_FILE_VERSION 1)\n"
  911. << "\n";
  912. }
  913. //----------------------------------------------------------------------------
  914. void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
  915. const std::string &expectedTargets)
  916. {
  917. os << "# Protect against multiple inclusion, which would fail when already "
  918. "imported targets are added once more.\n"
  919. "set(_targetsDefined)\n"
  920. "set(_targetsNotDefined)\n"
  921. "set(_expectedTargets)\n"
  922. "foreach(_expectedTarget " << expectedTargets << ")\n"
  923. " list(APPEND _expectedTargets ${_expectedTarget})\n"
  924. " if(NOT TARGET ${_expectedTarget})\n"
  925. " list(APPEND _targetsNotDefined ${_expectedTarget})\n"
  926. " endif()\n"
  927. " if(TARGET ${_expectedTarget})\n"
  928. " list(APPEND _targetsDefined ${_expectedTarget})\n"
  929. " endif()\n"
  930. "endforeach()\n"
  931. "if(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n"
  932. " set(CMAKE_IMPORT_FILE_VERSION)\n"
  933. " cmake_policy(POP)\n"
  934. " return()\n"
  935. "endif()\n"
  936. "if(NOT \"${_targetsDefined}\" STREQUAL \"\")\n"
  937. " message(FATAL_ERROR \"Some (but not all) targets in this export "
  938. "set were already defined.\\nTargets Defined: ${_targetsDefined}\\n"
  939. "Targets not yet defined: ${_targetsNotDefined}\\n\")\n"
  940. "endif()\n"
  941. "unset(_targetsDefined)\n"
  942. "unset(_targetsNotDefined)\n"
  943. "unset(_expectedTargets)\n"
  944. "\n\n";
  945. }
  946. //----------------------------------------------------------------------------
  947. void
  948. cmExportFileGenerator
  949. ::GenerateImportTargetCode(std::ostream& os, cmTarget const* target)
  950. {
  951. // Construct the imported target name.
  952. std::string targetName = this->Namespace;
  953. targetName += target->GetExportName();
  954. // Create the imported target.
  955. os << "# Create imported target " << targetName << "\n";
  956. switch(target->GetType())
  957. {
  958. case cmTarget::EXECUTABLE:
  959. os << "add_executable(" << targetName << " IMPORTED)\n";
  960. break;
  961. case cmTarget::STATIC_LIBRARY:
  962. os << "add_library(" << targetName << " STATIC IMPORTED)\n";
  963. break;
  964. case cmTarget::SHARED_LIBRARY:
  965. os << "add_library(" << targetName << " SHARED IMPORTED)\n";
  966. break;
  967. case cmTarget::MODULE_LIBRARY:
  968. os << "add_library(" << targetName << " MODULE IMPORTED)\n";
  969. break;
  970. case cmTarget::UNKNOWN_LIBRARY:
  971. os << "add_library(" << targetName << " UNKNOWN IMPORTED)\n";
  972. break;
  973. case cmTarget::INTERFACE_LIBRARY:
  974. os << "add_library(" << targetName << " INTERFACE IMPORTED)\n";
  975. break;
  976. default: // should never happen
  977. break;
  978. }
  979. // Mark the imported executable if it has exports.
  980. if(target->IsExecutableWithExports())
  981. {
  982. os << "set_property(TARGET " << targetName
  983. << " PROPERTY ENABLE_EXPORTS 1)\n";
  984. }
  985. // Mark the imported library if it is a framework.
  986. if(target->IsFrameworkOnApple())
  987. {
  988. os << "set_property(TARGET " << targetName
  989. << " PROPERTY FRAMEWORK 1)\n";
  990. }
  991. // Mark the imported executable if it is an application bundle.
  992. if(target->IsAppBundleOnApple())
  993. {
  994. os << "set_property(TARGET " << targetName
  995. << " PROPERTY MACOSX_BUNDLE 1)\n";
  996. }
  997. if (target->IsCFBundleOnApple())
  998. {
  999. os << "set_property(TARGET " << targetName
  1000. << " PROPERTY BUNDLE 1)\n";
  1001. }
  1002. os << "\n";
  1003. }
  1004. //----------------------------------------------------------------------------
  1005. void
  1006. cmExportFileGenerator
  1007. ::GenerateImportPropertyCode(std::ostream& os, const std::string& config,
  1008. cmTarget const* target,
  1009. ImportPropertyMap const& properties)
  1010. {
  1011. // Construct the imported target name.
  1012. std::string targetName = this->Namespace;
  1013. targetName += target->GetExportName();
  1014. // Set the import properties.
  1015. os << "# Import target \"" << targetName << "\" for configuration \""
  1016. << config << "\"\n";
  1017. os << "set_property(TARGET " << targetName
  1018. << " APPEND PROPERTY IMPORTED_CONFIGURATIONS ";
  1019. if(!config.empty())
  1020. {
  1021. os << cmSystemTools::UpperCase(config);
  1022. }
  1023. else
  1024. {
  1025. os << "NOCONFIG";
  1026. }
  1027. os << ")\n";
  1028. os << "set_target_properties(" << targetName << " PROPERTIES\n";
  1029. for(ImportPropertyMap::const_iterator pi = properties.begin();
  1030. pi != properties.end(); ++pi)
  1031. {
  1032. os << " " << pi->first << " "
  1033. << cmExportFileGeneratorEscape(pi->second) << "\n";
  1034. }
  1035. os << " )\n"
  1036. << "\n";
  1037. }
  1038. //----------------------------------------------------------------------------
  1039. void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
  1040. const std::vector<std::string>& missingTargets)
  1041. {
  1042. if (missingTargets.empty())
  1043. {
  1044. os << "# This file does not depend on other imported targets which have\n"
  1045. "# been exported from the same project but in a separate "
  1046. "export set.\n\n";
  1047. return;
  1048. }
  1049. os << "# Make sure the targets which have been exported in some other \n"
  1050. "# export set exist.\n"
  1051. "unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
  1052. "foreach(_target ";
  1053. std::set<std::string> emitted;
  1054. for(unsigned int i=0; i<missingTargets.size(); ++i)
  1055. {
  1056. if (emitted.insert(missingTargets[i]).second)
  1057. {
  1058. os << "\"" << missingTargets[i] << "\" ";
  1059. }
  1060. }
  1061. os << ")\n"
  1062. " if(NOT TARGET \"${_target}\" )\n"
  1063. " set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets \""
  1064. "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets} ${_target}\")"
  1065. "\n"
  1066. " endif()\n"
  1067. "endforeach()\n"
  1068. "\n"
  1069. "if(DEFINED ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
  1070. " if(CMAKE_FIND_PACKAGE_NAME)\n"
  1071. " set( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n"
  1072. " set( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "
  1073. "\"The following imported targets are "
  1074. "referenced, but are missing: "
  1075. "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}\")\n"
  1076. " else()\n"
  1077. " message(FATAL_ERROR \"The following imported targets are "
  1078. "referenced, but are missing: "
  1079. "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}\")\n"
  1080. " endif()\n"
  1081. "endif()\n"
  1082. "unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
  1083. "\n";
  1084. }
  1085. //----------------------------------------------------------------------------
  1086. void
  1087. cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
  1088. {
  1089. // Add code which verifies at cmake time that the file which is being
  1090. // imported actually exists on disk. This should in theory always be theory
  1091. // case, but still when packages are split into normal and development
  1092. // packages this might get broken (e.g. the Config.cmake could be part of
  1093. // the non-development package, something similar happened to me without
  1094. // on SUSE with a mysql pkg-config file, which claimed everything is fine,
  1095. // but the development package was not installed.).
  1096. os << "# Loop over all imported files and verify that they actually exist\n"
  1097. "foreach(target ${_IMPORT_CHECK_TARGETS} )\n"
  1098. " foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n"
  1099. " if(NOT EXISTS \"${file}\" )\n"
  1100. " message(FATAL_ERROR \"The imported target \\\"${target}\\\""
  1101. " references the file\n"
  1102. " \\\"${file}\\\"\n"
  1103. "but this file does not exist. Possible reasons include:\n"
  1104. "* The file was deleted, renamed, or moved to another location.\n"
  1105. "* An install or uninstall procedure did not complete successfully.\n"
  1106. "* The installation package was faulty and contained\n"
  1107. " \\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n"
  1108. "but not all the files it references.\n"
  1109. "\")\n"
  1110. " endif()\n"
  1111. " endforeach()\n"
  1112. " unset(_IMPORT_CHECK_FILES_FOR_${target})\n"
  1113. "endforeach()\n"
  1114. "unset(_IMPORT_CHECK_TARGETS)\n"
  1115. "\n";
  1116. }
  1117. //----------------------------------------------------------------------------
  1118. void
  1119. cmExportFileGenerator
  1120. ::GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target,
  1121. ImportPropertyMap const& properties,
  1122. const std::set<std::string>& importedLocations)
  1123. {
  1124. // Construct the imported target name.
  1125. std::string targetName = this->Namespace;
  1126. targetName += target->GetExportName();
  1127. os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
  1128. "list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";
  1129. for(std::set<std::string>::const_iterator li = importedLocations.begin();
  1130. li != importedLocations.end();
  1131. ++li)
  1132. {
  1133. ImportPropertyMap::const_iterator pi = properties.find(*li);
  1134. if (pi != properties.end())
  1135. {
  1136. os << cmExportFileGeneratorEscape(pi->second) << " ";
  1137. }
  1138. }
  1139. os << ")\n\n";
  1140. }