cmExportFileGenerator.cxx 42 KB

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