cmExportFileGenerator.cxx 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  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->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->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->GetPolicyStatusCMP0022() != cmPolicies::WARN
  755. && target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
  756. if(newCMP0022Behavior && !this->ExportOld)
  757. {
  758. cmMakefile *mf = target->Target->GetMakefile();
  759. std::ostringstream e;
  760. e << "Target \"" << target->GetName() << "\" has policy CMP0022 enabled, "
  761. "but also has old-style LINK_INTERFACE_LIBRARIES properties "
  762. "populated, but it was exported without the "
  763. "EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties";
  764. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  765. return;
  766. }
  767. if (!*propContent)
  768. {
  769. properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = "";
  770. return;
  771. }
  772. std::string prepro = cmGeneratorExpression::Preprocess(propContent,
  773. preprocessRule);
  774. if (!prepro.empty())
  775. {
  776. this->ResolveTargetsInGeneratorExpressions(prepro, target,
  777. missingTargets,
  778. ReplaceFreeTargets);
  779. properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro;
  780. }
  781. }
  782. //----------------------------------------------------------------------------
  783. void
  784. cmExportFileGenerator
  785. ::SetImportDetailProperties(const std::string& config,
  786. std::string const& suffix,
  787. cmGeneratorTarget* target,
  788. ImportPropertyMap& properties,
  789. std::vector<std::string>& missingTargets
  790. )
  791. {
  792. // Get the makefile in which to lookup target information.
  793. cmMakefile* mf = target->Makefile;
  794. // Add the soname for unix shared libraries.
  795. if(target->GetType() == cmState::SHARED_LIBRARY ||
  796. target->GetType() == cmState::MODULE_LIBRARY)
  797. {
  798. // Check whether this is a DLL platform.
  799. bool dll_platform =
  800. (mf->IsOn("WIN32") || mf->IsOn("CYGWIN") || mf->IsOn("MINGW"));
  801. if(!dll_platform)
  802. {
  803. std::string prop;
  804. std::string value;
  805. if(target->HasSOName(config))
  806. {
  807. if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
  808. {
  809. value = this->InstallNameDir(target, config);
  810. }
  811. prop = "IMPORTED_SONAME";
  812. value += target->GetSOName(config);
  813. }
  814. else
  815. {
  816. prop = "IMPORTED_NO_SONAME";
  817. value = "TRUE";
  818. }
  819. prop += suffix;
  820. properties[prop] = value;
  821. }
  822. }
  823. // Add the transitive link dependencies for this configuration.
  824. if(cmLinkInterface const* iface =
  825. target->GetLinkInterface(config, target))
  826. {
  827. this->SetImportLinkProperty(suffix, target,
  828. "IMPORTED_LINK_INTERFACE_LANGUAGES",
  829. iface->Languages, properties, missingTargets);
  830. std::vector<std::string> dummy;
  831. this->SetImportLinkProperty(suffix, target,
  832. "IMPORTED_LINK_DEPENDENT_LIBRARIES",
  833. iface->SharedDeps, properties, dummy);
  834. if(iface->Multiplicity > 0)
  835. {
  836. std::string prop = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
  837. prop += suffix;
  838. std::ostringstream m;
  839. m << iface->Multiplicity;
  840. properties[prop] = m.str();
  841. }
  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. //----------------------------------------------------------------------------
  880. void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os,
  881. const std::string& config)
  882. {
  883. os << "#----------------------------------------------------------------\n"
  884. << "# Generated CMake target import file";
  885. if(!config.empty())
  886. {
  887. os << " for configuration \"" << config << "\".\n";
  888. }
  889. else
  890. {
  891. os << ".\n";
  892. }
  893. os << "#----------------------------------------------------------------\n"
  894. << "\n";
  895. this->GenerateImportVersionCode(os);
  896. }
  897. //----------------------------------------------------------------------------
  898. void cmExportFileGenerator::GenerateImportFooterCode(std::ostream& os)
  899. {
  900. os << "# Commands beyond this point should not need to know the version.\n"
  901. << "set(CMAKE_IMPORT_FILE_VERSION)\n";
  902. }
  903. //----------------------------------------------------------------------------
  904. void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os)
  905. {
  906. // Store an import file format version. This will let us change the
  907. // format later while still allowing old import files to work.
  908. os << "# Commands may need to know the format version.\n"
  909. << "set(CMAKE_IMPORT_FILE_VERSION 1)\n"
  910. << "\n";
  911. }
  912. //----------------------------------------------------------------------------
  913. void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
  914. const std::string &expectedTargets)
  915. {
  916. os << "# Protect against multiple inclusion, which would fail when already "
  917. "imported targets are added once more.\n"
  918. "set(_targetsDefined)\n"
  919. "set(_targetsNotDefined)\n"
  920. "set(_expectedTargets)\n"
  921. "foreach(_expectedTarget " << expectedTargets << ")\n"
  922. " list(APPEND _expectedTargets ${_expectedTarget})\n"
  923. " if(NOT TARGET ${_expectedTarget})\n"
  924. " list(APPEND _targetsNotDefined ${_expectedTarget})\n"
  925. " endif()\n"
  926. " if(TARGET ${_expectedTarget})\n"
  927. " list(APPEND _targetsDefined ${_expectedTarget})\n"
  928. " endif()\n"
  929. "endforeach()\n"
  930. "if(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n"
  931. " set(CMAKE_IMPORT_FILE_VERSION)\n"
  932. " cmake_policy(POP)\n"
  933. " return()\n"
  934. "endif()\n"
  935. "if(NOT \"${_targetsDefined}\" STREQUAL \"\")\n"
  936. " message(FATAL_ERROR \"Some (but not all) targets in this export "
  937. "set were already defined.\\nTargets Defined: ${_targetsDefined}\\n"
  938. "Targets not yet defined: ${_targetsNotDefined}\\n\")\n"
  939. "endif()\n"
  940. "unset(_targetsDefined)\n"
  941. "unset(_targetsNotDefined)\n"
  942. "unset(_expectedTargets)\n"
  943. "\n\n";
  944. }
  945. //----------------------------------------------------------------------------
  946. void
  947. cmExportFileGenerator
  948. ::GenerateImportTargetCode(std::ostream& os, const cmGeneratorTarget* target)
  949. {
  950. // Construct the imported target name.
  951. std::string targetName = this->Namespace;
  952. targetName += target->GetExportName();
  953. // Create the imported target.
  954. os << "# Create imported target " << targetName << "\n";
  955. switch(target->GetType())
  956. {
  957. case cmState::EXECUTABLE:
  958. os << "add_executable(" << targetName << " IMPORTED)\n";
  959. break;
  960. case cmState::STATIC_LIBRARY:
  961. os << "add_library(" << targetName << " STATIC IMPORTED)\n";
  962. break;
  963. case cmState::SHARED_LIBRARY:
  964. os << "add_library(" << targetName << " SHARED IMPORTED)\n";
  965. break;
  966. case cmState::MODULE_LIBRARY:
  967. os << "add_library(" << targetName << " MODULE IMPORTED)\n";
  968. break;
  969. case cmState::UNKNOWN_LIBRARY:
  970. os << "add_library(" << targetName << " UNKNOWN IMPORTED)\n";
  971. break;
  972. case cmState::INTERFACE_LIBRARY:
  973. os << "add_library(" << targetName << " INTERFACE IMPORTED)\n";
  974. break;
  975. default: // should never happen
  976. break;
  977. }
  978. // Mark the imported executable if it has exports.
  979. if(target->IsExecutableWithExports())
  980. {
  981. os << "set_property(TARGET " << targetName
  982. << " PROPERTY ENABLE_EXPORTS 1)\n";
  983. }
  984. // Mark the imported library if it is a framework.
  985. if(target->IsFrameworkOnApple())
  986. {
  987. os << "set_property(TARGET " << targetName
  988. << " PROPERTY FRAMEWORK 1)\n";
  989. }
  990. // Mark the imported executable if it is an application bundle.
  991. if(target->IsAppBundleOnApple())
  992. {
  993. os << "set_property(TARGET " << targetName
  994. << " PROPERTY MACOSX_BUNDLE 1)\n";
  995. }
  996. if (target->IsCFBundleOnApple())
  997. {
  998. os << "set_property(TARGET " << targetName
  999. << " PROPERTY BUNDLE 1)\n";
  1000. }
  1001. os << "\n";
  1002. }
  1003. //----------------------------------------------------------------------------
  1004. void
  1005. cmExportFileGenerator
  1006. ::GenerateImportPropertyCode(std::ostream& os, const std::string& config,
  1007. cmGeneratorTarget const* target,
  1008. ImportPropertyMap const& properties)
  1009. {
  1010. // Construct the imported target name.
  1011. std::string targetName = this->Namespace;
  1012. targetName += target->GetExportName();
  1013. // Set the import properties.
  1014. os << "# Import target \"" << targetName << "\" for configuration \""
  1015. << config << "\"\n";
  1016. os << "set_property(TARGET " << targetName
  1017. << " APPEND PROPERTY IMPORTED_CONFIGURATIONS ";
  1018. if(!config.empty())
  1019. {
  1020. os << cmSystemTools::UpperCase(config);
  1021. }
  1022. else
  1023. {
  1024. os << "NOCONFIG";
  1025. }
  1026. os << ")\n";
  1027. os << "set_target_properties(" << targetName << " PROPERTIES\n";
  1028. for(ImportPropertyMap::const_iterator pi = properties.begin();
  1029. pi != properties.end(); ++pi)
  1030. {
  1031. os << " " << pi->first << " "
  1032. << cmExportFileGeneratorEscape(pi->second) << "\n";
  1033. }
  1034. os << " )\n"
  1035. << "\n";
  1036. }
  1037. //----------------------------------------------------------------------------
  1038. void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
  1039. const std::vector<std::string>& missingTargets)
  1040. {
  1041. if (missingTargets.empty())
  1042. {
  1043. os << "# This file does not depend on other imported targets which have\n"
  1044. "# been exported from the same project but in a separate "
  1045. "export set.\n\n";
  1046. return;
  1047. }
  1048. os << "# Make sure the targets which have been exported in some other \n"
  1049. "# export set exist.\n"
  1050. "unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
  1051. "foreach(_target ";
  1052. std::set<std::string> emitted;
  1053. for(unsigned int i=0; i<missingTargets.size(); ++i)
  1054. {
  1055. if (emitted.insert(missingTargets[i]).second)
  1056. {
  1057. os << "\"" << missingTargets[i] << "\" ";
  1058. }
  1059. }
  1060. os << ")\n"
  1061. " if(NOT TARGET \"${_target}\" )\n"
  1062. " set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets \""
  1063. "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets} ${_target}\")"
  1064. "\n"
  1065. " endif()\n"
  1066. "endforeach()\n"
  1067. "\n"
  1068. "if(DEFINED ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
  1069. " if(CMAKE_FIND_PACKAGE_NAME)\n"
  1070. " set( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n"
  1071. " set( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "
  1072. "\"The following imported targets are "
  1073. "referenced, but are missing: "
  1074. "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}\")\n"
  1075. " else()\n"
  1076. " message(FATAL_ERROR \"The following imported targets are "
  1077. "referenced, but are missing: "
  1078. "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}\")\n"
  1079. " endif()\n"
  1080. "endif()\n"
  1081. "unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
  1082. "\n";
  1083. }
  1084. //----------------------------------------------------------------------------
  1085. void
  1086. cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
  1087. {
  1088. // Add code which verifies at cmake time that the file which is being
  1089. // imported actually exists on disk. This should in theory always be theory
  1090. // case, but still when packages are split into normal and development
  1091. // packages this might get broken (e.g. the Config.cmake could be part of
  1092. // the non-development package, something similar happened to me without
  1093. // on SUSE with a mysql pkg-config file, which claimed everything is fine,
  1094. // but the development package was not installed.).
  1095. os << "# Loop over all imported files and verify that they actually exist\n"
  1096. "foreach(target ${_IMPORT_CHECK_TARGETS} )\n"
  1097. " foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n"
  1098. " if(NOT EXISTS \"${file}\" )\n"
  1099. " message(FATAL_ERROR \"The imported target \\\"${target}\\\""
  1100. " references the file\n"
  1101. " \\\"${file}\\\"\n"
  1102. "but this file does not exist. Possible reasons include:\n"
  1103. "* The file was deleted, renamed, or moved to another location.\n"
  1104. "* An install or uninstall procedure did not complete successfully.\n"
  1105. "* The installation package was faulty and contained\n"
  1106. " \\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n"
  1107. "but not all the files it references.\n"
  1108. "\")\n"
  1109. " endif()\n"
  1110. " endforeach()\n"
  1111. " unset(_IMPORT_CHECK_FILES_FOR_${target})\n"
  1112. "endforeach()\n"
  1113. "unset(_IMPORT_CHECK_TARGETS)\n"
  1114. "\n";
  1115. }
  1116. //----------------------------------------------------------------------------
  1117. void
  1118. cmExportFileGenerator
  1119. ::GenerateImportedFileChecksCode(std::ostream& os, cmGeneratorTarget* target,
  1120. ImportPropertyMap const& properties,
  1121. const std::set<std::string>& importedLocations)
  1122. {
  1123. // Construct the imported target name.
  1124. std::string targetName = this->Namespace;
  1125. targetName += target->GetExportName();
  1126. os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
  1127. "list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";
  1128. for(std::set<std::string>::const_iterator li = importedLocations.begin();
  1129. li != importedLocations.end();
  1130. ++li)
  1131. {
  1132. ImportPropertyMap::const_iterator pi = properties.find(*li);
  1133. if (pi != properties.end())
  1134. {
  1135. os << cmExportFileGeneratorEscape(pi->second) << " ";
  1136. }
  1137. }
  1138. os << ")\n\n";
  1139. }