cmExportFileGenerator.cxx 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  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. cmGeneratorTarget *target, const std::string& prop)
  220. {
  221. const char* installDir =
  222. target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
  223. const char* topSourceDir = target->Makefile->GetHomeDirectory();
  224. const char* topBinaryDir = target->Makefile->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->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->GetLocalGenerator()->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->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->GetLocalGenerator()->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->GetLocalGenerator()->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->GetLocalGenerator()->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. cmGeneratorTarget* gt = target->GetMakefile()
  388. ->GetGlobalGenerator()->GetGeneratorTarget(target);
  389. if (!checkInterfaceDirs(prepro, gt, propName))
  390. {
  391. return;
  392. }
  393. properties[propName] = prepro;
  394. }
  395. }
  396. //----------------------------------------------------------------------------
  397. void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
  398. cmTargetExport *tei,
  399. cmGeneratorExpression::PreprocessContext preprocessRule,
  400. ImportPropertyMap &properties,
  401. std::vector<std::string> &missingTargets)
  402. {
  403. cmGeneratorTarget *target = tei->Target->GetMakefile()
  404. ->GetGlobalGenerator()
  405. ->GetGeneratorTarget(tei->Target);
  406. assert(preprocessRule == cmGeneratorExpression::InstallInterface);
  407. const char *propName = "INTERFACE_INCLUDE_DIRECTORIES";
  408. const char *input = target->GetProperty(propName);
  409. cmGeneratorExpression ge;
  410. std::string dirs = cmGeneratorExpression::Preprocess(
  411. tei->InterfaceIncludeDirectories,
  412. preprocessRule,
  413. true);
  414. this->ReplaceInstallPrefix(dirs);
  415. cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
  416. std::string exportDirs = cge->Evaluate(target->Target->GetMakefile(), "",
  417. false, target->Target);
  418. if (cge->GetHadContextSensitiveCondition())
  419. {
  420. cmMakefile* mf = target->Target->GetMakefile();
  421. std::ostringstream e;
  422. e << "Target \"" << target->GetName() << "\" is installed with "
  423. "INCLUDES DESTINATION set to a context sensitive path. Paths which "
  424. "depend on the configuration, policy values or the link interface are "
  425. "not supported. Consider using target_include_directories instead.";
  426. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  427. return;
  428. }
  429. if (!input && exportDirs.empty())
  430. {
  431. return;
  432. }
  433. if ((input && !*input) && exportDirs.empty())
  434. {
  435. // Set to empty
  436. properties[propName] = "";
  437. return;
  438. }
  439. prefixItems(exportDirs);
  440. std::string includes = (input?input:"");
  441. const char* sep = input ? ";" : "";
  442. includes += sep + exportDirs;
  443. std::string prepro = cmGeneratorExpression::Preprocess(includes,
  444. preprocessRule,
  445. true);
  446. if (!prepro.empty())
  447. {
  448. this->ResolveTargetsInGeneratorExpressions(prepro, target->Target,
  449. missingTargets);
  450. if (!checkInterfaceDirs(prepro, target, propName))
  451. {
  452. return;
  453. }
  454. properties[propName] = prepro;
  455. }
  456. }
  457. //----------------------------------------------------------------------------
  458. void cmExportFileGenerator::PopulateInterfaceProperty(
  459. const std::string& propName,
  460. cmTarget *target,
  461. cmGeneratorExpression::PreprocessContext preprocessRule,
  462. ImportPropertyMap &properties,
  463. std::vector<std::string> &missingTargets)
  464. {
  465. this->PopulateInterfaceProperty(propName, propName, target, preprocessRule,
  466. properties, missingTargets);
  467. }
  468. //----------------------------------------------------------------------------
  469. void getPropertyContents(cmTarget const* tgt, const std::string& prop,
  470. std::set<std::string> &ifaceProperties)
  471. {
  472. const char *p = tgt->GetProperty(prop);
  473. if (!p)
  474. {
  475. return;
  476. }
  477. std::vector<std::string> content;
  478. cmSystemTools::ExpandListArgument(p, content);
  479. ifaceProperties.insert(content.begin(), content.end());
  480. }
  481. //----------------------------------------------------------------------------
  482. void getCompatibleInterfaceProperties(cmGeneratorTarget *target,
  483. std::set<std::string> &ifaceProperties,
  484. const std::string& config)
  485. {
  486. cmComputeLinkInformation *info = target->GetLinkInformation(config);
  487. if (!info)
  488. {
  489. cmMakefile* mf = target->Target->GetMakefile();
  490. std::ostringstream e;
  491. e << "Exporting the target \"" << target->GetName() << "\" is not "
  492. "allowed since its linker language cannot be determined";
  493. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  494. return;
  495. }
  496. const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
  497. for(cmComputeLinkInformation::ItemVector::const_iterator li =
  498. deps.begin();
  499. li != deps.end(); ++li)
  500. {
  501. if (!li->Target)
  502. {
  503. continue;
  504. }
  505. getPropertyContents(li->Target,
  506. "COMPATIBLE_INTERFACE_BOOL",
  507. ifaceProperties);
  508. getPropertyContents(li->Target,
  509. "COMPATIBLE_INTERFACE_STRING",
  510. ifaceProperties);
  511. getPropertyContents(li->Target,
  512. "COMPATIBLE_INTERFACE_NUMBER_MIN",
  513. ifaceProperties);
  514. getPropertyContents(li->Target,
  515. "COMPATIBLE_INTERFACE_NUMBER_MAX",
  516. ifaceProperties);
  517. }
  518. }
  519. //----------------------------------------------------------------------------
  520. void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
  521. cmGeneratorTarget *gtarget,
  522. ImportPropertyMap &properties)
  523. {
  524. cmTarget *target = gtarget->Target;
  525. this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL",
  526. target, properties);
  527. this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING",
  528. target, properties);
  529. this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN",
  530. target, properties);
  531. this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX",
  532. target, properties);
  533. std::set<std::string> ifaceProperties;
  534. getPropertyContents(target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties);
  535. getPropertyContents(target, "COMPATIBLE_INTERFACE_STRING", ifaceProperties);
  536. getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MIN",
  537. ifaceProperties);
  538. getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MAX",
  539. ifaceProperties);
  540. if (target->GetType() != cmTarget::INTERFACE_LIBRARY)
  541. {
  542. getCompatibleInterfaceProperties(gtarget, ifaceProperties, "");
  543. std::vector<std::string> configNames;
  544. target->GetMakefile()->GetConfigurations(configNames);
  545. for (std::vector<std::string>::const_iterator ci = configNames.begin();
  546. ci != configNames.end(); ++ci)
  547. {
  548. getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci);
  549. }
  550. }
  551. for (std::set<std::string>::const_iterator it = ifaceProperties.begin();
  552. it != ifaceProperties.end(); ++it)
  553. {
  554. this->PopulateInterfaceProperty("INTERFACE_" + *it,
  555. target, properties);
  556. }
  557. }
  558. //----------------------------------------------------------------------------
  559. void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* target,
  560. std::ostream& os,
  561. const ImportPropertyMap &properties)
  562. {
  563. if (!properties.empty())
  564. {
  565. std::string targetName = this->Namespace;
  566. targetName += target->GetExportName();
  567. os << "set_target_properties(" << targetName << " PROPERTIES\n";
  568. for(ImportPropertyMap::const_iterator pi = properties.begin();
  569. pi != properties.end(); ++pi)
  570. {
  571. os << " " << pi->first << " "
  572. << cmExportFileGeneratorEscape(pi->second) << "\n";
  573. }
  574. os << ")\n\n";
  575. }
  576. }
  577. //----------------------------------------------------------------------------
  578. bool
  579. cmExportFileGenerator::AddTargetNamespace(std::string &input,
  580. cmTarget* target,
  581. std::vector<std::string> &missingTargets)
  582. {
  583. cmMakefile *mf = target->GetMakefile();
  584. cmTarget *tgt = mf->FindTargetToUse(input);
  585. if (!tgt)
  586. {
  587. return false;
  588. }
  589. if(tgt->IsImported())
  590. {
  591. return true;
  592. }
  593. if(this->ExportedTargets.find(tgt) != this->ExportedTargets.end())
  594. {
  595. input = this->Namespace + tgt->GetExportName();
  596. }
  597. else
  598. {
  599. std::string namespacedTarget;
  600. this->HandleMissingTarget(namespacedTarget, missingTargets,
  601. mf, target, tgt);
  602. if (!namespacedTarget.empty())
  603. {
  604. input = namespacedTarget;
  605. }
  606. }
  607. return true;
  608. }
  609. //----------------------------------------------------------------------------
  610. void
  611. cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
  612. std::string &input,
  613. cmTarget* target,
  614. std::vector<std::string> &missingTargets,
  615. FreeTargetsReplace replace)
  616. {
  617. if (replace == NoReplaceFreeTargets)
  618. {
  619. this->ResolveTargetsInGeneratorExpression(input, target, missingTargets);
  620. return;
  621. }
  622. std::vector<std::string> parts;
  623. cmGeneratorExpression::Split(input, parts);
  624. std::string sep;
  625. input = "";
  626. for(std::vector<std::string>::iterator li = parts.begin();
  627. li != parts.end(); ++li)
  628. {
  629. if (cmGeneratorExpression::Find(*li) == std::string::npos)
  630. {
  631. this->AddTargetNamespace(*li, target, missingTargets);
  632. }
  633. else
  634. {
  635. this->ResolveTargetsInGeneratorExpression(
  636. *li,
  637. target,
  638. missingTargets);
  639. }
  640. input += sep + *li;
  641. sep = ";";
  642. }
  643. }
  644. //----------------------------------------------------------------------------
  645. void
  646. cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
  647. std::string &input,
  648. cmTarget* target,
  649. std::vector<std::string> &missingTargets)
  650. {
  651. std::string::size_type pos = 0;
  652. std::string::size_type lastPos = pos;
  653. cmMakefile *mf = target->GetMakefile();
  654. while((pos = input.find("$<TARGET_PROPERTY:", lastPos)) != input.npos)
  655. {
  656. std::string::size_type nameStartPos = pos +
  657. sizeof("$<TARGET_PROPERTY:") - 1;
  658. std::string::size_type closePos = input.find(">", nameStartPos);
  659. std::string::size_type commaPos = input.find(",", nameStartPos);
  660. std::string::size_type nextOpenPos = input.find("$<", nameStartPos);
  661. if (commaPos == input.npos // Implied 'this' target
  662. || closePos == input.npos // Imcomplete expression.
  663. || closePos < commaPos // Implied 'this' target
  664. || nextOpenPos < commaPos) // Non-literal
  665. {
  666. lastPos = nameStartPos;
  667. continue;
  668. }
  669. std::string targetName = input.substr(nameStartPos,
  670. commaPos - nameStartPos);
  671. if (this->AddTargetNamespace(targetName, target, missingTargets))
  672. {
  673. input.replace(nameStartPos, commaPos - nameStartPos, targetName);
  674. }
  675. lastPos = nameStartPos + targetName.size() + 1;
  676. }
  677. std::string errorString;
  678. pos = 0;
  679. lastPos = pos;
  680. while((pos = input.find("$<TARGET_NAME:", lastPos)) != input.npos)
  681. {
  682. std::string::size_type nameStartPos = pos + sizeof("$<TARGET_NAME:") - 1;
  683. std::string::size_type endPos = input.find(">", nameStartPos);
  684. if (endPos == input.npos)
  685. {
  686. errorString = "$<TARGET_NAME:...> expression incomplete";
  687. break;
  688. }
  689. std::string targetName = input.substr(nameStartPos,
  690. endPos - nameStartPos);
  691. if(targetName.find("$<") != input.npos)
  692. {
  693. errorString = "$<TARGET_NAME:...> requires its parameter to be a "
  694. "literal.";
  695. break;
  696. }
  697. if (!this->AddTargetNamespace(targetName, target, missingTargets))
  698. {
  699. errorString = "$<TARGET_NAME:...> requires its parameter to be a "
  700. "reachable target.";
  701. break;
  702. }
  703. input.replace(pos, endPos - pos + 1, targetName);
  704. lastPos = endPos;
  705. }
  706. this->ReplaceInstallPrefix(input);
  707. if (!errorString.empty())
  708. {
  709. mf->IssueMessage(cmake::FATAL_ERROR, errorString);
  710. }
  711. }
  712. //----------------------------------------------------------------------------
  713. void
  714. cmExportFileGenerator::ReplaceInstallPrefix(std::string &)
  715. {
  716. // Do nothing
  717. }
  718. //----------------------------------------------------------------------------
  719. void
  720. cmExportFileGenerator
  721. ::SetImportLinkInterface(const std::string& config, std::string const& suffix,
  722. cmGeneratorExpression::PreprocessContext preprocessRule,
  723. cmGeneratorTarget* target, ImportPropertyMap& properties,
  724. std::vector<std::string>& missingTargets)
  725. {
  726. // Add the transitive link dependencies for this configuration.
  727. cmLinkInterface const* iface = target->GetLinkInterface(config,
  728. target->Target);
  729. if (!iface)
  730. {
  731. return;
  732. }
  733. if (iface->ImplementationIsInterface)
  734. {
  735. // Policy CMP0022 must not be NEW.
  736. this->SetImportLinkProperty(suffix, target,
  737. "IMPORTED_LINK_INTERFACE_LIBRARIES",
  738. iface->Libraries, properties, missingTargets);
  739. return;
  740. }
  741. const char *propContent;
  742. if (const char *prop_suffixed = target->GetProperty(
  743. "LINK_INTERFACE_LIBRARIES" + suffix))
  744. {
  745. propContent = prop_suffixed;
  746. }
  747. else if (const char *prop = target->GetProperty(
  748. "LINK_INTERFACE_LIBRARIES"))
  749. {
  750. propContent = prop;
  751. }
  752. else
  753. {
  754. return;
  755. }
  756. const bool newCMP0022Behavior =
  757. target->Target
  758. ->GetPolicyStatusCMP0022() != cmPolicies::WARN
  759. && target->Target
  760. ->GetPolicyStatusCMP0022() != cmPolicies::OLD;
  761. if(newCMP0022Behavior && !this->ExportOld)
  762. {
  763. cmMakefile *mf = target->Target->GetMakefile();
  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. mf->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->Target,
  782. missingTargets,
  783. ReplaceFreeTargets);
  784. properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro;
  785. }
  786. }
  787. //----------------------------------------------------------------------------
  788. void
  789. cmExportFileGenerator
  790. ::SetImportDetailProperties(const std::string& config,
  791. std::string const& suffix,
  792. cmGeneratorTarget* target,
  793. ImportPropertyMap& properties,
  794. std::vector<std::string>& missingTargets
  795. )
  796. {
  797. // Get the makefile in which to lookup target information.
  798. cmMakefile* mf = target->Makefile;
  799. // Add the soname for unix shared libraries.
  800. if(target->GetType() == cmTarget::SHARED_LIBRARY ||
  801. target->GetType() == cmTarget::MODULE_LIBRARY)
  802. {
  803. // Check whether this is a DLL platform.
  804. bool dll_platform =
  805. (mf->IsOn("WIN32") || mf->IsOn("CYGWIN") || mf->IsOn("MINGW"));
  806. if(!dll_platform)
  807. {
  808. std::string prop;
  809. std::string value;
  810. if(target->HasSOName(config))
  811. {
  812. if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
  813. {
  814. value = this->InstallNameDir(target, config);
  815. }
  816. prop = "IMPORTED_SONAME";
  817. value += target->GetSOName(config);
  818. }
  819. else
  820. {
  821. prop = "IMPORTED_NO_SONAME";
  822. value = "TRUE";
  823. }
  824. prop += suffix;
  825. properties[prop] = value;
  826. }
  827. }
  828. // Add the transitive link dependencies for this configuration.
  829. if(cmLinkInterface const* iface =
  830. target->GetLinkInterface(config, target->Target))
  831. {
  832. this->SetImportLinkProperty(suffix, target,
  833. "IMPORTED_LINK_INTERFACE_LANGUAGES",
  834. iface->Languages, properties, missingTargets);
  835. std::vector<std::string> dummy;
  836. this->SetImportLinkProperty(suffix, target,
  837. "IMPORTED_LINK_DEPENDENT_LIBRARIES",
  838. iface->SharedDeps, properties, dummy);
  839. if(iface->Multiplicity > 0)
  840. {
  841. std::string prop = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
  842. prop += suffix;
  843. std::ostringstream m;
  844. m << iface->Multiplicity;
  845. properties[prop] = m.str();
  846. }
  847. }
  848. }
  849. //----------------------------------------------------------------------------
  850. template <typename T>
  851. void
  852. cmExportFileGenerator
  853. ::SetImportLinkProperty(std::string const& suffix,
  854. cmGeneratorTarget* target,
  855. const std::string& propName,
  856. std::vector<T> const& entries,
  857. ImportPropertyMap& properties,
  858. std::vector<std::string>& missingTargets
  859. )
  860. {
  861. // Skip the property if there are no entries.
  862. if(entries.empty())
  863. {
  864. return;
  865. }
  866. // Construct the property value.
  867. std::string link_entries;
  868. const char* sep = "";
  869. for(typename std::vector<T>::const_iterator li = entries.begin();
  870. li != entries.end(); ++li)
  871. {
  872. // Separate this from the previous entry.
  873. link_entries += sep;
  874. sep = ";";
  875. std::string temp = *li;
  876. this->AddTargetNamespace(temp, target->Target, missingTargets);
  877. link_entries += temp;
  878. }
  879. // Store the property.
  880. std::string prop = propName;
  881. prop += suffix;
  882. properties[prop] = link_entries;
  883. }
  884. //----------------------------------------------------------------------------
  885. void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os,
  886. const std::string& config)
  887. {
  888. os << "#----------------------------------------------------------------\n"
  889. << "# Generated CMake target import file";
  890. if(!config.empty())
  891. {
  892. os << " for configuration \"" << config << "\".\n";
  893. }
  894. else
  895. {
  896. os << ".\n";
  897. }
  898. os << "#----------------------------------------------------------------\n"
  899. << "\n";
  900. this->GenerateImportVersionCode(os);
  901. }
  902. //----------------------------------------------------------------------------
  903. void cmExportFileGenerator::GenerateImportFooterCode(std::ostream& os)
  904. {
  905. os << "# Commands beyond this point should not need to know the version.\n"
  906. << "set(CMAKE_IMPORT_FILE_VERSION)\n";
  907. }
  908. //----------------------------------------------------------------------------
  909. void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os)
  910. {
  911. // Store an import file format version. This will let us change the
  912. // format later while still allowing old import files to work.
  913. os << "# Commands may need to know the format version.\n"
  914. << "set(CMAKE_IMPORT_FILE_VERSION 1)\n"
  915. << "\n";
  916. }
  917. //----------------------------------------------------------------------------
  918. void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
  919. const std::string &expectedTargets)
  920. {
  921. os << "# Protect against multiple inclusion, which would fail when already "
  922. "imported targets are added once more.\n"
  923. "set(_targetsDefined)\n"
  924. "set(_targetsNotDefined)\n"
  925. "set(_expectedTargets)\n"
  926. "foreach(_expectedTarget " << expectedTargets << ")\n"
  927. " list(APPEND _expectedTargets ${_expectedTarget})\n"
  928. " if(NOT TARGET ${_expectedTarget})\n"
  929. " list(APPEND _targetsNotDefined ${_expectedTarget})\n"
  930. " endif()\n"
  931. " if(TARGET ${_expectedTarget})\n"
  932. " list(APPEND _targetsDefined ${_expectedTarget})\n"
  933. " endif()\n"
  934. "endforeach()\n"
  935. "if(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n"
  936. " set(CMAKE_IMPORT_FILE_VERSION)\n"
  937. " cmake_policy(POP)\n"
  938. " return()\n"
  939. "endif()\n"
  940. "if(NOT \"${_targetsDefined}\" STREQUAL \"\")\n"
  941. " message(FATAL_ERROR \"Some (but not all) targets in this export "
  942. "set were already defined.\\nTargets Defined: ${_targetsDefined}\\n"
  943. "Targets not yet defined: ${_targetsNotDefined}\\n\")\n"
  944. "endif()\n"
  945. "unset(_targetsDefined)\n"
  946. "unset(_targetsNotDefined)\n"
  947. "unset(_expectedTargets)\n"
  948. "\n\n";
  949. }
  950. //----------------------------------------------------------------------------
  951. void
  952. cmExportFileGenerator
  953. ::GenerateImportTargetCode(std::ostream& os, cmTarget const* target)
  954. {
  955. // Construct the imported target name.
  956. std::string targetName = this->Namespace;
  957. targetName += target->GetExportName();
  958. // Create the imported target.
  959. os << "# Create imported target " << targetName << "\n";
  960. switch(target->GetType())
  961. {
  962. case cmTarget::EXECUTABLE:
  963. os << "add_executable(" << targetName << " IMPORTED)\n";
  964. break;
  965. case cmTarget::STATIC_LIBRARY:
  966. os << "add_library(" << targetName << " STATIC IMPORTED)\n";
  967. break;
  968. case cmTarget::SHARED_LIBRARY:
  969. os << "add_library(" << targetName << " SHARED IMPORTED)\n";
  970. break;
  971. case cmTarget::MODULE_LIBRARY:
  972. os << "add_library(" << targetName << " MODULE IMPORTED)\n";
  973. break;
  974. case cmTarget::UNKNOWN_LIBRARY:
  975. os << "add_library(" << targetName << " UNKNOWN IMPORTED)\n";
  976. break;
  977. case cmTarget::INTERFACE_LIBRARY:
  978. os << "add_library(" << targetName << " INTERFACE IMPORTED)\n";
  979. break;
  980. default: // should never happen
  981. break;
  982. }
  983. // Mark the imported executable if it has exports.
  984. if(target->IsExecutableWithExports())
  985. {
  986. os << "set_property(TARGET " << targetName
  987. << " PROPERTY ENABLE_EXPORTS 1)\n";
  988. }
  989. // Mark the imported library if it is a framework.
  990. if(target->IsFrameworkOnApple())
  991. {
  992. os << "set_property(TARGET " << targetName
  993. << " PROPERTY FRAMEWORK 1)\n";
  994. }
  995. // Mark the imported executable if it is an application bundle.
  996. if(target->IsAppBundleOnApple())
  997. {
  998. os << "set_property(TARGET " << targetName
  999. << " PROPERTY MACOSX_BUNDLE 1)\n";
  1000. }
  1001. if (target->IsCFBundleOnApple())
  1002. {
  1003. os << "set_property(TARGET " << targetName
  1004. << " PROPERTY BUNDLE 1)\n";
  1005. }
  1006. os << "\n";
  1007. }
  1008. //----------------------------------------------------------------------------
  1009. void
  1010. cmExportFileGenerator
  1011. ::GenerateImportPropertyCode(std::ostream& os, const std::string& config,
  1012. cmTarget const* target,
  1013. ImportPropertyMap const& properties)
  1014. {
  1015. // Construct the imported target name.
  1016. std::string targetName = this->Namespace;
  1017. targetName += target->GetExportName();
  1018. // Set the import properties.
  1019. os << "# Import target \"" << targetName << "\" for configuration \""
  1020. << config << "\"\n";
  1021. os << "set_property(TARGET " << targetName
  1022. << " APPEND PROPERTY IMPORTED_CONFIGURATIONS ";
  1023. if(!config.empty())
  1024. {
  1025. os << cmSystemTools::UpperCase(config);
  1026. }
  1027. else
  1028. {
  1029. os << "NOCONFIG";
  1030. }
  1031. os << ")\n";
  1032. os << "set_target_properties(" << targetName << " PROPERTIES\n";
  1033. for(ImportPropertyMap::const_iterator pi = properties.begin();
  1034. pi != properties.end(); ++pi)
  1035. {
  1036. os << " " << pi->first << " "
  1037. << cmExportFileGeneratorEscape(pi->second) << "\n";
  1038. }
  1039. os << " )\n"
  1040. << "\n";
  1041. }
  1042. //----------------------------------------------------------------------------
  1043. void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
  1044. const std::vector<std::string>& missingTargets)
  1045. {
  1046. if (missingTargets.empty())
  1047. {
  1048. os << "# This file does not depend on other imported targets which have\n"
  1049. "# been exported from the same project but in a separate "
  1050. "export set.\n\n";
  1051. return;
  1052. }
  1053. os << "# Make sure the targets which have been exported in some other \n"
  1054. "# export set exist.\n"
  1055. "unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
  1056. "foreach(_target ";
  1057. std::set<std::string> emitted;
  1058. for(unsigned int i=0; i<missingTargets.size(); ++i)
  1059. {
  1060. if (emitted.insert(missingTargets[i]).second)
  1061. {
  1062. os << "\"" << missingTargets[i] << "\" ";
  1063. }
  1064. }
  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. }
  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. os << "# Loop over all imported files and verify that they actually exist\n"
  1101. "foreach(target ${_IMPORT_CHECK_TARGETS} )\n"
  1102. " foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n"
  1103. " if(NOT EXISTS \"${file}\" )\n"
  1104. " message(FATAL_ERROR \"The imported target \\\"${target}\\\""
  1105. " references the file\n"
  1106. " \\\"${file}\\\"\n"
  1107. "but this file does not exist. Possible reasons include:\n"
  1108. "* The file was deleted, renamed, or moved to another location.\n"
  1109. "* An install or uninstall procedure did not complete successfully.\n"
  1110. "* The installation package was faulty and contained\n"
  1111. " \\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n"
  1112. "but not all the files it references.\n"
  1113. "\")\n"
  1114. " endif()\n"
  1115. " endforeach()\n"
  1116. " unset(_IMPORT_CHECK_FILES_FOR_${target})\n"
  1117. "endforeach()\n"
  1118. "unset(_IMPORT_CHECK_TARGETS)\n"
  1119. "\n";
  1120. }
  1121. //----------------------------------------------------------------------------
  1122. void
  1123. cmExportFileGenerator
  1124. ::GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target,
  1125. ImportPropertyMap const& properties,
  1126. const std::set<std::string>& importedLocations)
  1127. {
  1128. // Construct the imported target name.
  1129. std::string targetName = this->Namespace;
  1130. targetName += target->GetExportName();
  1131. os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
  1132. "list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";
  1133. for(std::set<std::string>::const_iterator li = importedLocations.begin();
  1134. li != importedLocations.end();
  1135. ++li)
  1136. {
  1137. ImportPropertyMap::const_iterator pi = properties.find(*li);
  1138. if (pi != properties.end())
  1139. {
  1140. os << cmExportFileGeneratorEscape(pi->second) << " ";
  1141. }
  1142. }
  1143. os << ")\n\n";
  1144. }