cmExportFileGenerator.cxx 42 KB

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