cmExportFileGenerator.cxx 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255
  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. cmGeneratorTarget *target = tei->Target->GetMakefile()
  402. ->GetGlobalGenerator()
  403. ->GetGeneratorTarget(tei->Target);
  404. assert(preprocessRule == cmGeneratorExpression::InstallInterface);
  405. const char *propName = "INTERFACE_INCLUDE_DIRECTORIES";
  406. const char *input = target->GetProperty(propName);
  407. cmGeneratorExpression ge;
  408. std::string dirs = cmGeneratorExpression::Preprocess(
  409. tei->InterfaceIncludeDirectories,
  410. preprocessRule,
  411. true);
  412. this->ReplaceInstallPrefix(dirs);
  413. cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
  414. std::string exportDirs = cge->Evaluate(target->Target->GetMakefile(), "",
  415. false, target->Target);
  416. if (cge->GetHadContextSensitiveCondition())
  417. {
  418. cmMakefile* mf = target->Target->GetMakefile();
  419. std::ostringstream e;
  420. e << "Target \"" << target->GetName() << "\" is installed with "
  421. "INCLUDES DESTINATION set to a context sensitive path. Paths which "
  422. "depend on the configuration, policy values or the link interface are "
  423. "not supported. Consider using target_include_directories instead.";
  424. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  425. return;
  426. }
  427. if (!input && exportDirs.empty())
  428. {
  429. return;
  430. }
  431. if ((input && !*input) && exportDirs.empty())
  432. {
  433. // Set to empty
  434. properties[propName] = "";
  435. return;
  436. }
  437. prefixItems(exportDirs);
  438. std::string includes = (input?input:"");
  439. const char* sep = input ? ";" : "";
  440. includes += sep + exportDirs;
  441. std::string prepro = cmGeneratorExpression::Preprocess(includes,
  442. preprocessRule,
  443. true);
  444. if (!prepro.empty())
  445. {
  446. this->ResolveTargetsInGeneratorExpressions(prepro, target->Target,
  447. missingTargets);
  448. if (!checkInterfaceDirs(prepro, target->Target, propName))
  449. {
  450. return;
  451. }
  452. properties[propName] = prepro;
  453. }
  454. }
  455. //----------------------------------------------------------------------------
  456. void cmExportFileGenerator::PopulateInterfaceProperty(
  457. const std::string& propName,
  458. cmTarget *target,
  459. cmGeneratorExpression::PreprocessContext preprocessRule,
  460. ImportPropertyMap &properties,
  461. std::vector<std::string> &missingTargets)
  462. {
  463. this->PopulateInterfaceProperty(propName, propName, target, preprocessRule,
  464. properties, missingTargets);
  465. }
  466. //----------------------------------------------------------------------------
  467. void getPropertyContents(cmTarget const* tgt, 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. cmTarget *target = gtarget->Target;
  523. this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL",
  524. target, properties);
  525. this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING",
  526. target, properties);
  527. this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN",
  528. target, properties);
  529. this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX",
  530. target, properties);
  531. std::set<std::string> ifaceProperties;
  532. getPropertyContents(target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties);
  533. getPropertyContents(target, "COMPATIBLE_INTERFACE_STRING", ifaceProperties);
  534. getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MIN",
  535. ifaceProperties);
  536. getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MAX",
  537. ifaceProperties);
  538. if (target->GetType() != cmTarget::INTERFACE_LIBRARY)
  539. {
  540. getCompatibleInterfaceProperties(gtarget, ifaceProperties, "");
  541. std::vector<std::string> configNames;
  542. target->GetMakefile()->GetConfigurations(configNames);
  543. for (std::vector<std::string>::const_iterator ci = configNames.begin();
  544. ci != configNames.end(); ++ci)
  545. {
  546. getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci);
  547. }
  548. }
  549. for (std::set<std::string>::const_iterator it = ifaceProperties.begin();
  550. it != ifaceProperties.end(); ++it)
  551. {
  552. this->PopulateInterfaceProperty("INTERFACE_" + *it,
  553. target, properties);
  554. }
  555. }
  556. //----------------------------------------------------------------------------
  557. void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* 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. cmTarget* target,
  579. std::vector<std::string> &missingTargets)
  580. {
  581. cmMakefile *mf = target->GetMakefile();
  582. cmTarget *tgt = mf->FindTargetToUse(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. mf, 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. cmTarget* 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. cmTarget* target,
  647. std::vector<std::string> &missingTargets)
  648. {
  649. std::string::size_type pos = 0;
  650. std::string::size_type lastPos = pos;
  651. cmMakefile *mf = target->GetMakefile();
  652. while((pos = input.find("$<TARGET_PROPERTY:", lastPos)) != input.npos)
  653. {
  654. std::string::size_type nameStartPos = pos +
  655. sizeof("$<TARGET_PROPERTY:") - 1;
  656. std::string::size_type closePos = input.find(">", nameStartPos);
  657. std::string::size_type commaPos = input.find(",", nameStartPos);
  658. std::string::size_type nextOpenPos = input.find("$<", nameStartPos);
  659. if (commaPos == input.npos // Implied 'this' target
  660. || closePos == input.npos // Imcomplete expression.
  661. || closePos < commaPos // Implied 'this' target
  662. || nextOpenPos < commaPos) // Non-literal
  663. {
  664. lastPos = nameStartPos;
  665. continue;
  666. }
  667. std::string targetName = input.substr(nameStartPos,
  668. commaPos - nameStartPos);
  669. if (this->AddTargetNamespace(targetName, target, missingTargets))
  670. {
  671. input.replace(nameStartPos, commaPos - nameStartPos, targetName);
  672. }
  673. lastPos = nameStartPos + targetName.size() + 1;
  674. }
  675. std::string errorString;
  676. pos = 0;
  677. lastPos = pos;
  678. while((pos = input.find("$<TARGET_NAME:", lastPos)) != input.npos)
  679. {
  680. std::string::size_type nameStartPos = pos + sizeof("$<TARGET_NAME:") - 1;
  681. std::string::size_type endPos = input.find(">", nameStartPos);
  682. if (endPos == input.npos)
  683. {
  684. errorString = "$<TARGET_NAME:...> expression incomplete";
  685. break;
  686. }
  687. std::string targetName = input.substr(nameStartPos,
  688. endPos - nameStartPos);
  689. if(targetName.find("$<") != input.npos)
  690. {
  691. errorString = "$<TARGET_NAME:...> requires its parameter to be a "
  692. "literal.";
  693. break;
  694. }
  695. if (!this->AddTargetNamespace(targetName, target, missingTargets))
  696. {
  697. errorString = "$<TARGET_NAME:...> requires its parameter to be a "
  698. "reachable target.";
  699. break;
  700. }
  701. input.replace(pos, endPos - pos + 1, targetName);
  702. lastPos = endPos;
  703. }
  704. this->ReplaceInstallPrefix(input);
  705. if (!errorString.empty())
  706. {
  707. mf->IssueMessage(cmake::FATAL_ERROR, errorString);
  708. }
  709. }
  710. //----------------------------------------------------------------------------
  711. void
  712. cmExportFileGenerator::ReplaceInstallPrefix(std::string &)
  713. {
  714. // Do nothing
  715. }
  716. //----------------------------------------------------------------------------
  717. void
  718. cmExportFileGenerator
  719. ::SetImportLinkInterface(const std::string& config, std::string const& suffix,
  720. cmGeneratorExpression::PreprocessContext preprocessRule,
  721. cmGeneratorTarget* target, ImportPropertyMap& properties,
  722. std::vector<std::string>& missingTargets)
  723. {
  724. // Add the transitive link dependencies for this configuration.
  725. cmLinkInterface const* iface = target->GetLinkInterface(config,
  726. target->Target);
  727. if (!iface)
  728. {
  729. return;
  730. }
  731. if (iface->ImplementationIsInterface)
  732. {
  733. // Policy CMP0022 must not be NEW.
  734. this->SetImportLinkProperty(suffix, target,
  735. "IMPORTED_LINK_INTERFACE_LIBRARIES",
  736. iface->Libraries, properties, missingTargets);
  737. return;
  738. }
  739. const char *propContent;
  740. if (const char *prop_suffixed = target->GetProperty(
  741. "LINK_INTERFACE_LIBRARIES" + suffix))
  742. {
  743. propContent = prop_suffixed;
  744. }
  745. else if (const char *prop = target->GetProperty(
  746. "LINK_INTERFACE_LIBRARIES"))
  747. {
  748. propContent = prop;
  749. }
  750. else
  751. {
  752. return;
  753. }
  754. const bool newCMP0022Behavior =
  755. target->Target
  756. ->GetPolicyStatusCMP0022() != cmPolicies::WARN
  757. && target->Target
  758. ->GetPolicyStatusCMP0022() != cmPolicies::OLD;
  759. if(newCMP0022Behavior && !this->ExportOld)
  760. {
  761. cmMakefile *mf = target->Target->GetMakefile();
  762. std::ostringstream e;
  763. e << "Target \"" << target->GetName() << "\" has policy CMP0022 enabled, "
  764. "but also has old-style LINK_INTERFACE_LIBRARIES properties "
  765. "populated, but it was exported without the "
  766. "EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties";
  767. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  768. return;
  769. }
  770. if (!*propContent)
  771. {
  772. properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = "";
  773. return;
  774. }
  775. std::string prepro = cmGeneratorExpression::Preprocess(propContent,
  776. preprocessRule);
  777. if (!prepro.empty())
  778. {
  779. this->ResolveTargetsInGeneratorExpressions(prepro, target->Target,
  780. missingTargets,
  781. ReplaceFreeTargets);
  782. properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro;
  783. }
  784. }
  785. //----------------------------------------------------------------------------
  786. void
  787. cmExportFileGenerator
  788. ::SetImportDetailProperties(const std::string& config,
  789. std::string const& suffix,
  790. cmGeneratorTarget* target,
  791. ImportPropertyMap& properties,
  792. std::vector<std::string>& missingTargets
  793. )
  794. {
  795. // Get the makefile in which to lookup target information.
  796. cmMakefile* mf = target->Makefile;
  797. // Add the soname for unix shared libraries.
  798. if(target->GetType() == cmTarget::SHARED_LIBRARY ||
  799. target->GetType() == cmTarget::MODULE_LIBRARY)
  800. {
  801. // Check whether this is a DLL platform.
  802. bool dll_platform =
  803. (mf->IsOn("WIN32") || mf->IsOn("CYGWIN") || mf->IsOn("MINGW"));
  804. if(!dll_platform)
  805. {
  806. std::string prop;
  807. std::string value;
  808. if(target->HasSOName(config))
  809. {
  810. if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
  811. {
  812. value = this->InstallNameDir(target, config);
  813. }
  814. prop = "IMPORTED_SONAME";
  815. value += target->GetSOName(config);
  816. }
  817. else
  818. {
  819. prop = "IMPORTED_NO_SONAME";
  820. value = "TRUE";
  821. }
  822. prop += suffix;
  823. properties[prop] = value;
  824. }
  825. }
  826. // Add the transitive link dependencies for this configuration.
  827. if(cmLinkInterface const* iface =
  828. target->GetLinkInterface(config, target->Target))
  829. {
  830. this->SetImportLinkProperty(suffix, target,
  831. "IMPORTED_LINK_INTERFACE_LANGUAGES",
  832. iface->Languages, properties, missingTargets);
  833. std::vector<std::string> dummy;
  834. this->SetImportLinkProperty(suffix, target,
  835. "IMPORTED_LINK_DEPENDENT_LIBRARIES",
  836. iface->SharedDeps, properties, dummy);
  837. if(iface->Multiplicity > 0)
  838. {
  839. std::string prop = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
  840. prop += suffix;
  841. std::ostringstream m;
  842. m << iface->Multiplicity;
  843. properties[prop] = m.str();
  844. }
  845. }
  846. }
  847. //----------------------------------------------------------------------------
  848. template <typename T>
  849. void
  850. cmExportFileGenerator
  851. ::SetImportLinkProperty(std::string const& suffix,
  852. cmGeneratorTarget* target,
  853. const std::string& propName,
  854. std::vector<T> const& entries,
  855. ImportPropertyMap& properties,
  856. std::vector<std::string>& missingTargets
  857. )
  858. {
  859. // Skip the property if there are no entries.
  860. if(entries.empty())
  861. {
  862. return;
  863. }
  864. // Construct the property value.
  865. std::string link_entries;
  866. const char* sep = "";
  867. for(typename std::vector<T>::const_iterator li = entries.begin();
  868. li != entries.end(); ++li)
  869. {
  870. // Separate this from the previous entry.
  871. link_entries += sep;
  872. sep = ";";
  873. std::string temp = *li;
  874. this->AddTargetNamespace(temp, target->Target, missingTargets);
  875. link_entries += temp;
  876. }
  877. // Store the property.
  878. std::string prop = propName;
  879. prop += suffix;
  880. properties[prop] = link_entries;
  881. }
  882. //----------------------------------------------------------------------------
  883. void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os,
  884. const std::string& config)
  885. {
  886. os << "#----------------------------------------------------------------\n"
  887. << "# Generated CMake target import file";
  888. if(!config.empty())
  889. {
  890. os << " for configuration \"" << config << "\".\n";
  891. }
  892. else
  893. {
  894. os << ".\n";
  895. }
  896. os << "#----------------------------------------------------------------\n"
  897. << "\n";
  898. this->GenerateImportVersionCode(os);
  899. }
  900. //----------------------------------------------------------------------------
  901. void cmExportFileGenerator::GenerateImportFooterCode(std::ostream& os)
  902. {
  903. os << "# Commands beyond this point should not need to know the version.\n"
  904. << "set(CMAKE_IMPORT_FILE_VERSION)\n";
  905. }
  906. //----------------------------------------------------------------------------
  907. void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os)
  908. {
  909. // Store an import file format version. This will let us change the
  910. // format later while still allowing old import files to work.
  911. os << "# Commands may need to know the format version.\n"
  912. << "set(CMAKE_IMPORT_FILE_VERSION 1)\n"
  913. << "\n";
  914. }
  915. //----------------------------------------------------------------------------
  916. void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
  917. const std::string &expectedTargets)
  918. {
  919. os << "# Protect against multiple inclusion, which would fail when already "
  920. "imported targets are added once more.\n"
  921. "set(_targetsDefined)\n"
  922. "set(_targetsNotDefined)\n"
  923. "set(_expectedTargets)\n"
  924. "foreach(_expectedTarget " << expectedTargets << ")\n"
  925. " list(APPEND _expectedTargets ${_expectedTarget})\n"
  926. " if(NOT TARGET ${_expectedTarget})\n"
  927. " list(APPEND _targetsNotDefined ${_expectedTarget})\n"
  928. " endif()\n"
  929. " if(TARGET ${_expectedTarget})\n"
  930. " list(APPEND _targetsDefined ${_expectedTarget})\n"
  931. " endif()\n"
  932. "endforeach()\n"
  933. "if(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n"
  934. " set(CMAKE_IMPORT_FILE_VERSION)\n"
  935. " cmake_policy(POP)\n"
  936. " return()\n"
  937. "endif()\n"
  938. "if(NOT \"${_targetsDefined}\" STREQUAL \"\")\n"
  939. " message(FATAL_ERROR \"Some (but not all) targets in this export "
  940. "set were already defined.\\nTargets Defined: ${_targetsDefined}\\n"
  941. "Targets not yet defined: ${_targetsNotDefined}\\n\")\n"
  942. "endif()\n"
  943. "unset(_targetsDefined)\n"
  944. "unset(_targetsNotDefined)\n"
  945. "unset(_expectedTargets)\n"
  946. "\n\n";
  947. }
  948. //----------------------------------------------------------------------------
  949. void
  950. cmExportFileGenerator
  951. ::GenerateImportTargetCode(std::ostream& os, cmTarget const* target)
  952. {
  953. // Construct the imported target name.
  954. std::string targetName = this->Namespace;
  955. targetName += target->GetExportName();
  956. // Create the imported target.
  957. os << "# Create imported target " << targetName << "\n";
  958. switch(target->GetType())
  959. {
  960. case cmTarget::EXECUTABLE:
  961. os << "add_executable(" << targetName << " IMPORTED)\n";
  962. break;
  963. case cmTarget::STATIC_LIBRARY:
  964. os << "add_library(" << targetName << " STATIC IMPORTED)\n";
  965. break;
  966. case cmTarget::SHARED_LIBRARY:
  967. os << "add_library(" << targetName << " SHARED IMPORTED)\n";
  968. break;
  969. case cmTarget::MODULE_LIBRARY:
  970. os << "add_library(" << targetName << " MODULE IMPORTED)\n";
  971. break;
  972. case cmTarget::UNKNOWN_LIBRARY:
  973. os << "add_library(" << targetName << " UNKNOWN IMPORTED)\n";
  974. break;
  975. case cmTarget::INTERFACE_LIBRARY:
  976. os << "add_library(" << targetName << " INTERFACE IMPORTED)\n";
  977. break;
  978. default: // should never happen
  979. break;
  980. }
  981. // Mark the imported executable if it has exports.
  982. if(target->IsExecutableWithExports())
  983. {
  984. os << "set_property(TARGET " << targetName
  985. << " PROPERTY ENABLE_EXPORTS 1)\n";
  986. }
  987. // Mark the imported library if it is a framework.
  988. if(target->IsFrameworkOnApple())
  989. {
  990. os << "set_property(TARGET " << targetName
  991. << " PROPERTY FRAMEWORK 1)\n";
  992. }
  993. // Mark the imported executable if it is an application bundle.
  994. if(target->IsAppBundleOnApple())
  995. {
  996. os << "set_property(TARGET " << targetName
  997. << " PROPERTY MACOSX_BUNDLE 1)\n";
  998. }
  999. if (target->IsCFBundleOnApple())
  1000. {
  1001. os << "set_property(TARGET " << targetName
  1002. << " PROPERTY BUNDLE 1)\n";
  1003. }
  1004. os << "\n";
  1005. }
  1006. //----------------------------------------------------------------------------
  1007. void
  1008. cmExportFileGenerator
  1009. ::GenerateImportPropertyCode(std::ostream& os, const std::string& config,
  1010. cmTarget const* target,
  1011. ImportPropertyMap const& properties)
  1012. {
  1013. // Construct the imported target name.
  1014. std::string targetName = this->Namespace;
  1015. targetName += target->GetExportName();
  1016. // Set the import properties.
  1017. os << "# Import target \"" << targetName << "\" for configuration \""
  1018. << config << "\"\n";
  1019. os << "set_property(TARGET " << targetName
  1020. << " APPEND PROPERTY IMPORTED_CONFIGURATIONS ";
  1021. if(!config.empty())
  1022. {
  1023. os << cmSystemTools::UpperCase(config);
  1024. }
  1025. else
  1026. {
  1027. os << "NOCONFIG";
  1028. }
  1029. os << ")\n";
  1030. os << "set_target_properties(" << targetName << " PROPERTIES\n";
  1031. for(ImportPropertyMap::const_iterator pi = properties.begin();
  1032. pi != properties.end(); ++pi)
  1033. {
  1034. os << " " << pi->first << " "
  1035. << cmExportFileGeneratorEscape(pi->second) << "\n";
  1036. }
  1037. os << " )\n"
  1038. << "\n";
  1039. }
  1040. //----------------------------------------------------------------------------
  1041. void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
  1042. const std::vector<std::string>& missingTargets)
  1043. {
  1044. if (missingTargets.empty())
  1045. {
  1046. os << "# This file does not depend on other imported targets which have\n"
  1047. "# been exported from the same project but in a separate "
  1048. "export set.\n\n";
  1049. return;
  1050. }
  1051. os << "# Make sure the targets which have been exported in some other \n"
  1052. "# export set exist.\n"
  1053. "unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
  1054. "foreach(_target ";
  1055. std::set<std::string> emitted;
  1056. for(unsigned int i=0; i<missingTargets.size(); ++i)
  1057. {
  1058. if (emitted.insert(missingTargets[i]).second)
  1059. {
  1060. os << "\"" << missingTargets[i] << "\" ";
  1061. }
  1062. }
  1063. os << ")\n"
  1064. " if(NOT TARGET \"${_target}\" )\n"
  1065. " set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets \""
  1066. "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets} ${_target}\")"
  1067. "\n"
  1068. " endif()\n"
  1069. "endforeach()\n"
  1070. "\n"
  1071. "if(DEFINED ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
  1072. " if(CMAKE_FIND_PACKAGE_NAME)\n"
  1073. " set( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n"
  1074. " set( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "
  1075. "\"The following imported targets are "
  1076. "referenced, but are missing: "
  1077. "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}\")\n"
  1078. " else()\n"
  1079. " message(FATAL_ERROR \"The following imported targets are "
  1080. "referenced, but are missing: "
  1081. "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}\")\n"
  1082. " endif()\n"
  1083. "endif()\n"
  1084. "unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
  1085. "\n";
  1086. }
  1087. //----------------------------------------------------------------------------
  1088. void
  1089. cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
  1090. {
  1091. // Add code which verifies at cmake time that the file which is being
  1092. // imported actually exists on disk. This should in theory always be theory
  1093. // case, but still when packages are split into normal and development
  1094. // packages this might get broken (e.g. the Config.cmake could be part of
  1095. // the non-development package, something similar happened to me without
  1096. // on SUSE with a mysql pkg-config file, which claimed everything is fine,
  1097. // but the development package was not installed.).
  1098. os << "# Loop over all imported files and verify that they actually exist\n"
  1099. "foreach(target ${_IMPORT_CHECK_TARGETS} )\n"
  1100. " foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n"
  1101. " if(NOT EXISTS \"${file}\" )\n"
  1102. " message(FATAL_ERROR \"The imported target \\\"${target}\\\""
  1103. " references the file\n"
  1104. " \\\"${file}\\\"\n"
  1105. "but this file does not exist. Possible reasons include:\n"
  1106. "* The file was deleted, renamed, or moved to another location.\n"
  1107. "* An install or uninstall procedure did not complete successfully.\n"
  1108. "* The installation package was faulty and contained\n"
  1109. " \\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n"
  1110. "but not all the files it references.\n"
  1111. "\")\n"
  1112. " endif()\n"
  1113. " endforeach()\n"
  1114. " unset(_IMPORT_CHECK_FILES_FOR_${target})\n"
  1115. "endforeach()\n"
  1116. "unset(_IMPORT_CHECK_TARGETS)\n"
  1117. "\n";
  1118. }
  1119. //----------------------------------------------------------------------------
  1120. void
  1121. cmExportFileGenerator
  1122. ::GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target,
  1123. ImportPropertyMap const& properties,
  1124. const std::set<std::string>& importedLocations)
  1125. {
  1126. // Construct the imported target name.
  1127. std::string targetName = this->Namespace;
  1128. targetName += target->GetExportName();
  1129. os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
  1130. "list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";
  1131. for(std::set<std::string>::const_iterator li = importedLocations.begin();
  1132. li != importedLocations.end();
  1133. ++li)
  1134. {
  1135. ImportPropertyMap::const_iterator pi = properties.find(*li);
  1136. if (pi != properties.end())
  1137. {
  1138. os << cmExportFileGeneratorEscape(pi->second) << " ";
  1139. }
  1140. }
  1141. os << ")\n\n";
  1142. }