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