cmExportFileGenerator.cxx 41 KB

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