cmExportInstallFileGenerator.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmExportInstallFileGenerator.h"
  4. #include <algorithm>
  5. #include <cassert>
  6. #include <cstddef>
  7. #include <memory>
  8. #include <set>
  9. #include <sstream>
  10. #include <utility>
  11. #include "cmExportSet.h"
  12. #include "cmGeneratedFileStream.h"
  13. #include "cmGeneratorTarget.h"
  14. #include "cmGlobalGenerator.h"
  15. #include "cmInstallTargetGenerator.h"
  16. #include "cmList.h"
  17. #include "cmLocalGenerator.h"
  18. #include "cmMakefile.h"
  19. #include "cmMessageType.h"
  20. #include "cmStringAlgorithms.h"
  21. #include "cmSystemTools.h"
  22. #include "cmTarget.h"
  23. #include "cmTargetExport.h"
  24. #include "cmValue.h"
  25. #include "cmake.h"
  26. cmExportInstallFileGenerator::cmExportInstallFileGenerator(
  27. cmInstallExportGenerator* iegen)
  28. : IEGen(iegen)
  29. {
  30. }
  31. void cmExportInstallFileGenerator::ReplaceInstallPrefix(
  32. std::string& input) const
  33. {
  34. cmGeneratorExpression::ReplaceInstallPrefix(input, this->GetInstallPrefix());
  35. }
  36. void cmExportInstallFileGenerator::PopulateImportProperties(
  37. std::string const& config, std::string const& suffix,
  38. cmTargetExport const* targetExport, ImportPropertyMap& properties,
  39. std::set<std::string>& importedLocations)
  40. {
  41. this->SetImportLocationProperty(config, suffix,
  42. targetExport->ArchiveGenerator, properties,
  43. importedLocations);
  44. this->SetImportLocationProperty(config, suffix,
  45. targetExport->LibraryGenerator, properties,
  46. importedLocations);
  47. this->SetImportLocationProperty(config, suffix,
  48. targetExport->RuntimeGenerator, properties,
  49. importedLocations);
  50. this->SetImportLocationProperty(config, suffix,
  51. targetExport->ObjectsGenerator, properties,
  52. importedLocations);
  53. this->SetImportLocationProperty(config, suffix,
  54. targetExport->FrameworkGenerator, properties,
  55. importedLocations);
  56. this->SetImportLocationProperty(config, suffix,
  57. targetExport->BundleGenerator, properties,
  58. importedLocations);
  59. // If any file location was set for the target add it to the
  60. // import file.
  61. if (!properties.empty()) {
  62. // Get the rest of the target details.
  63. cmGeneratorTarget const* const gtgt = targetExport->Target;
  64. this->SetImportDetailProperties(config, suffix, gtgt, properties);
  65. // TODO: PUBLIC_HEADER_LOCATION
  66. // This should wait until the build feature propagation stuff is done.
  67. // Then this can be a propagated include directory.
  68. // this->GenerateImportProperty(config, te->HeaderGenerator, properties);
  69. }
  70. }
  71. std::string cmExportInstallFileGenerator::GetImportXcFrameworkLocation(
  72. std::string const& config, cmTargetExport const* targetExport) const
  73. {
  74. std::string importedXcFrameworkLocation = targetExport->XcFrameworkLocation;
  75. if (!importedXcFrameworkLocation.empty()) {
  76. importedXcFrameworkLocation = cmGeneratorExpression::Preprocess(
  77. importedXcFrameworkLocation,
  78. cmGeneratorExpression::PreprocessContext::InstallInterface,
  79. this->GetImportPrefixWithSlash());
  80. importedXcFrameworkLocation = cmGeneratorExpression::Evaluate(
  81. importedXcFrameworkLocation, targetExport->Target->GetLocalGenerator(),
  82. config, targetExport->Target, nullptr, targetExport->Target);
  83. if (!importedXcFrameworkLocation.empty() &&
  84. !cmSystemTools::FileIsFullPath(importedXcFrameworkLocation) &&
  85. !cmHasPrefix(importedXcFrameworkLocation,
  86. this->GetImportPrefixWithSlash())) {
  87. return cmStrCat(this->GetImportPrefixWithSlash(),
  88. importedXcFrameworkLocation);
  89. }
  90. }
  91. return importedXcFrameworkLocation;
  92. }
  93. bool cmExportInstallFileGenerator::GenerateImportFileConfig(
  94. std::string const& config)
  95. {
  96. // Skip configurations not enabled for this export.
  97. if (!this->IEGen->InstallsForConfig(config)) {
  98. return true;
  99. }
  100. // Construct the name of the file to generate.
  101. std::string fileName = cmStrCat(this->FileDir, '/', this->FileBase,
  102. this->GetConfigFileNameSeparator());
  103. if (!config.empty()) {
  104. fileName += cmSystemTools::LowerCase(config);
  105. } else {
  106. fileName += "noconfig";
  107. }
  108. fileName += this->FileExt;
  109. // Open the output file to generate it.
  110. cmGeneratedFileStream exportFileStream(fileName, true);
  111. if (!exportFileStream) {
  112. std::string se = cmSystemTools::GetLastSystemError();
  113. std::ostringstream e;
  114. e << "cannot write to file \"" << fileName << "\": " << se;
  115. cmSystemTools::Error(e.str());
  116. return false;
  117. }
  118. exportFileStream.SetCopyIfDifferent(true);
  119. std::ostream& os = exportFileStream;
  120. // Generate the per-config target information.
  121. this->GenerateImportConfig(os, config);
  122. // Record this per-config import file.
  123. this->ConfigImportFiles[config] = fileName;
  124. return true;
  125. }
  126. void cmExportInstallFileGenerator::SetImportLocationProperty(
  127. std::string const& config, std::string const& suffix,
  128. cmInstallTargetGenerator* itgen, ImportPropertyMap& properties,
  129. std::set<std::string>& importedLocations)
  130. {
  131. // Skip rules that do not match this configuration.
  132. if (!(itgen && itgen->InstallsForConfig(config))) {
  133. return;
  134. }
  135. // Get the target to be installed.
  136. cmGeneratorTarget* target = itgen->GetTarget();
  137. // Construct the installed location of the target.
  138. std::string dest = itgen->GetDestination(config);
  139. std::string value;
  140. if (!cmSystemTools::FileIsFullPath(dest)) {
  141. // The target is installed relative to the installation prefix.
  142. value = std::string{ this->GetImportPrefixWithSlash() };
  143. }
  144. value += dest;
  145. value += "/";
  146. if (itgen->IsImportLibrary()) {
  147. // Construct the property name.
  148. std::string prop = cmStrCat("IMPORTED_IMPLIB", suffix);
  149. // Append the installed file name.
  150. value += cmInstallTargetGenerator::GetInstallFilename(
  151. target, config, cmInstallTargetGenerator::NameImplibReal);
  152. // Store the property.
  153. properties[prop] = value;
  154. importedLocations.insert(prop);
  155. } else if (itgen->GetTarget()->GetType() == cmStateEnums::OBJECT_LIBRARY) {
  156. // Construct the property name.
  157. std::string prop = cmStrCat("IMPORTED_OBJECTS", suffix);
  158. // Compute all the object files inside this target and setup
  159. // IMPORTED_OBJECTS as a list of object files
  160. std::vector<std::string> objects;
  161. itgen->GetInstallObjectNames(config, objects);
  162. for (std::string& obj : objects) {
  163. obj = cmStrCat(value, obj);
  164. }
  165. // Store the property.
  166. properties[prop] = cmList::to_string(objects);
  167. importedLocations.insert(prop);
  168. } else {
  169. if (target->IsFrameworkOnApple() && target->HasImportLibrary(config)) {
  170. // store as well IMPLIB value
  171. auto importProp = cmStrCat("IMPORTED_IMPLIB", suffix);
  172. auto importValue =
  173. cmStrCat(value,
  174. cmInstallTargetGenerator::GetInstallFilename(
  175. target, config, cmInstallTargetGenerator::NameImplibReal));
  176. // Store the property.
  177. properties[importProp] = importValue;
  178. importedLocations.insert(importProp);
  179. }
  180. // Construct the property name.
  181. std::string prop = cmStrCat("IMPORTED_LOCATION", suffix);
  182. // Append the installed file name.
  183. if (target->IsAppBundleOnApple()) {
  184. value += cmInstallTargetGenerator::GetInstallFilename(target, config);
  185. value += ".app/";
  186. if (!target->Makefile->PlatformIsAppleEmbedded()) {
  187. value += "Contents/MacOS/";
  188. }
  189. value += cmInstallTargetGenerator::GetInstallFilename(target, config);
  190. } else {
  191. value += cmInstallTargetGenerator::GetInstallFilename(
  192. target, config, cmInstallTargetGenerator::NameReal);
  193. }
  194. // Store the property.
  195. properties[prop] = value;
  196. importedLocations.insert(prop);
  197. }
  198. }
  199. cmStateEnums::TargetType cmExportInstallFileGenerator::GetExportTargetType(
  200. cmTargetExport const* targetExport) const
  201. {
  202. cmStateEnums::TargetType targetType = targetExport->Target->GetType();
  203. // An OBJECT library installed with no OBJECTS DESTINATION
  204. // is transformed to an INTERFACE library.
  205. if (targetType == cmStateEnums::OBJECT_LIBRARY &&
  206. !targetExport->ObjectsGenerator) {
  207. targetType = cmStateEnums::INTERFACE_LIBRARY;
  208. }
  209. return targetType;
  210. }
  211. std::string const& cmExportInstallFileGenerator::GetExportName() const
  212. {
  213. return this->GetExportSet()->GetName();
  214. }
  215. void cmExportInstallFileGenerator::HandleMissingTarget(
  216. std::string& link_libs, cmGeneratorTarget const* depender,
  217. cmGeneratorTarget* dependee)
  218. {
  219. auto const& exportInfo = this->FindExportInfo(dependee);
  220. if (exportInfo.Namespaces.size() == 1 && exportInfo.Sets.size() == 1) {
  221. std::string missingTarget = *exportInfo.Namespaces.begin();
  222. missingTarget += dependee->GetExportName();
  223. link_libs += missingTarget;
  224. this->MissingTargets.emplace_back(std::move(missingTarget));
  225. } else {
  226. // All exported targets should be known here and should be unique.
  227. // This is probably user-error.
  228. this->ComplainAboutMissingTarget(depender, dependee, exportInfo);
  229. }
  230. }
  231. cmExportFileGenerator::ExportInfo cmExportInstallFileGenerator::FindExportInfo(
  232. cmGeneratorTarget const* target) const
  233. {
  234. std::vector<std::string> exportFiles;
  235. std::set<std::string> exportSets;
  236. std::set<std::string> namespaces;
  237. auto const& name = target->GetName();
  238. auto& allExportSets =
  239. target->GetLocalGenerator()->GetGlobalGenerator()->GetExportSets();
  240. for (auto const& exp : allExportSets) {
  241. auto const& exportSet = exp.second;
  242. auto const& targets = exportSet.GetTargetExports();
  243. if (std::any_of(targets.begin(), targets.end(),
  244. [&name](std::unique_ptr<cmTargetExport> const& te) {
  245. return te->TargetName == name;
  246. })) {
  247. exportSets.insert(exp.first);
  248. std::vector<cmInstallExportGenerator const*> const* installs =
  249. exportSet.GetInstallations();
  250. for (cmInstallExportGenerator const* install : *installs) {
  251. exportFiles.push_back(install->GetDestinationFile());
  252. namespaces.insert(install->GetNamespace());
  253. }
  254. }
  255. }
  256. return { exportFiles, exportSets, namespaces };
  257. }
  258. void cmExportInstallFileGenerator::ComplainAboutMissingTarget(
  259. cmGeneratorTarget const* depender, cmGeneratorTarget const* dependee,
  260. ExportInfo const& exportInfo) const
  261. {
  262. std::ostringstream e;
  263. e << "install(" << this->IEGen->InstallSubcommand() << " \""
  264. << this->GetExportName() << "\" ...) "
  265. << "includes target \"" << depender->GetName()
  266. << "\" which requires target \"" << dependee->GetName() << "\" ";
  267. if (exportInfo.Sets.empty()) {
  268. e << "that is not in any export set.";
  269. } else {
  270. if (exportInfo.Sets.size() == 1) {
  271. e << "that is not in this export set, but in another export set which "
  272. "is "
  273. "exported multiple times with different namespaces: ";
  274. } else {
  275. e << "that is not in this export set, but in multiple other export "
  276. "sets: ";
  277. }
  278. e << cmJoin(exportInfo.Files, ", ") << ".\n"
  279. << "An exported target cannot depend upon another target which is "
  280. "exported in more than one export set or with more than one "
  281. "namespace. "
  282. "Consider consolidating the exports of the \""
  283. << dependee->GetName() << "\" target to a single export.";
  284. }
  285. this->ReportError(e.str());
  286. }
  287. void cmExportInstallFileGenerator::ComplainAboutDuplicateTarget(
  288. std::string const& targetName) const
  289. {
  290. std::ostringstream e;
  291. e << "install(" << this->IEGen->InstallSubcommand() << " \""
  292. << this->GetExportName() << "\" ...) "
  293. << "includes target \"" << targetName
  294. << "\" more than once in the export set.";
  295. this->ReportError(e.str());
  296. }
  297. void cmExportInstallFileGenerator::ReportError(
  298. std::string const& errorMessage) const
  299. {
  300. this->IEGen->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
  301. MessageType::FATAL_ERROR, errorMessage,
  302. this->IEGen->GetLocalGenerator()->GetMakefile()->GetBacktrace());
  303. }
  304. std::string cmExportInstallFileGenerator::InstallNameDir(
  305. cmGeneratorTarget const* target, std::string const& config)
  306. {
  307. std::string install_name_dir;
  308. cmMakefile* mf = target->Target->GetMakefile();
  309. if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
  310. auto const& prefix = this->GetInstallPrefix();
  311. install_name_dir = target->GetInstallNameDirForInstallTree(config, prefix);
  312. }
  313. return install_name_dir;
  314. }
  315. std::string cmExportInstallFileGenerator::GetCxxModuleFile() const
  316. {
  317. return this->GetCxxModuleFile(this->GetExportSet()->GetName());
  318. }
  319. bool cmExportInstallFileGenerator::CollectExports(
  320. std::function<void(cmTargetExport const*)> const& visitor)
  321. {
  322. auto pred = [&](std::unique_ptr<cmTargetExport> const& te) -> bool {
  323. if (te->NamelinkOnly) {
  324. return true;
  325. }
  326. if (this->ExportedTargets.insert(te->Target).second) {
  327. visitor(te.get());
  328. return true;
  329. }
  330. this->ComplainAboutDuplicateTarget(te->Target->GetName());
  331. return false;
  332. };
  333. auto const& targets = this->GetExportSet()->GetTargetExports();
  334. return std::all_of(targets.begin(), targets.end(), pred);
  335. }
  336. bool cmExportInstallFileGenerator::PopulateInterfaceProperties(
  337. cmTargetExport const* targetExport, ImportPropertyMap& properties)
  338. {
  339. cmGeneratorTarget const* const gt = targetExport->Target;
  340. std::string includesDestinationDirs;
  341. this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", gt,
  342. cmGeneratorExpression::InstallInterface,
  343. properties);
  344. this->PopulateIncludeDirectoriesInterface(
  345. gt, cmGeneratorExpression::InstallInterface, properties, *targetExport,
  346. includesDestinationDirs);
  347. this->PopulateLinkDirectoriesInterface(
  348. gt, cmGeneratorExpression::InstallInterface, properties);
  349. this->PopulateLinkDependsInterface(
  350. gt, cmGeneratorExpression::InstallInterface, properties);
  351. this->PopulateSourcesInterface(gt, cmGeneratorExpression::InstallInterface,
  352. properties);
  353. return this->PopulateInterfaceProperties(
  354. gt, includesDestinationDirs, cmGeneratorExpression::InstallInterface,
  355. properties);
  356. }
  357. namespace {
  358. bool isSubDirectory(std::string const& a, std::string const& b)
  359. {
  360. return (cmSystemTools::ComparePath(a, b) ||
  361. cmSystemTools::IsSubDirectory(a, b));
  362. }
  363. }
  364. bool cmExportInstallFileGenerator::CheckInterfaceDirs(
  365. std::string const& prepro, cmGeneratorTarget const* target,
  366. std::string const& prop) const
  367. {
  368. std::string const& installDir =
  369. target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
  370. std::string const& topSourceDir =
  371. target->GetLocalGenerator()->GetSourceDirectory();
  372. std::string const& topBinaryDir =
  373. target->GetLocalGenerator()->GetBinaryDirectory();
  374. std::vector<std::string> parts;
  375. cmGeneratorExpression::Split(prepro, parts);
  376. bool const inSourceBuild = topSourceDir == topBinaryDir;
  377. bool hadFatalError = false;
  378. for (std::string const& li : parts) {
  379. size_t genexPos = cmGeneratorExpression::Find(li);
  380. if (genexPos == 0) {
  381. continue;
  382. }
  383. if (cmHasPrefix(li, this->GetImportPrefixWithSlash())) {
  384. continue;
  385. }
  386. std::ostringstream e;
  387. if (genexPos != std::string::npos) {
  388. hadFatalError = true;
  389. }
  390. if (!cmSystemTools::FileIsFullPath(li)) {
  391. /* clang-format off */
  392. e << "Target \"" << target->GetName() << "\" " << prop <<
  393. " property contains relative path:\n"
  394. " \"" << li << "\"";
  395. /* clang-format on */
  396. target->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
  397. e.str());
  398. }
  399. bool inBinary = isSubDirectory(li, topBinaryDir);
  400. bool inSource = isSubDirectory(li, topSourceDir);
  401. if (isSubDirectory(li, installDir)) {
  402. // The include directory is inside the install tree. If the
  403. // install tree is inside the source tree or build tree then do not
  404. // fall through to the checks below that the include directory is not
  405. // also inside the source tree or build tree.
  406. if ((!inBinary || isSubDirectory(installDir, topBinaryDir)) &&
  407. (!inSource || isSubDirectory(installDir, topSourceDir))) {
  408. continue;
  409. }
  410. }
  411. if (inBinary) {
  412. /* clang-format off */
  413. e << "Target \"" << target->GetName() << "\" " << prop <<
  414. " property contains path:\n"
  415. " \"" << li << "\"\nwhich is prefixed in the build directory.";
  416. /* clang-format on */
  417. target->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
  418. e.str());
  419. }
  420. if (!inSourceBuild) {
  421. if (inSource) {
  422. e << "Target \"" << target->GetName() << "\" " << prop
  423. << " property contains path:\n"
  424. " \""
  425. << li << "\"\nwhich is prefixed in the source directory.";
  426. target->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
  427. e.str());
  428. }
  429. }
  430. }
  431. return !hadFatalError;
  432. }
  433. void cmExportInstallFileGenerator::PopulateSourcesInterface(
  434. cmGeneratorTarget const* gt,
  435. cmGeneratorExpression::PreprocessContext preprocessRule,
  436. ImportPropertyMap& properties)
  437. {
  438. assert(preprocessRule == cmGeneratorExpression::InstallInterface);
  439. char const* const propName = "INTERFACE_SOURCES";
  440. cmValue input = gt->GetProperty(propName);
  441. if (!input) {
  442. return;
  443. }
  444. if (input->empty()) {
  445. properties[propName].clear();
  446. return;
  447. }
  448. std::string prepro = cmGeneratorExpression::Preprocess(
  449. *input, preprocessRule, this->GetImportPrefixWithSlash());
  450. if (!prepro.empty()) {
  451. this->ResolveTargetsInGeneratorExpressions(prepro, gt);
  452. if (!this->CheckInterfaceDirs(prepro, gt, propName)) {
  453. return;
  454. }
  455. properties[propName] = prepro;
  456. }
  457. }
  458. void cmExportInstallFileGenerator::PopulateIncludeDirectoriesInterface(
  459. cmGeneratorTarget const* target,
  460. cmGeneratorExpression::PreprocessContext preprocessRule,
  461. ImportPropertyMap& properties, cmTargetExport const& te,
  462. std::string& includesDestinationDirs)
  463. {
  464. assert(preprocessRule == cmGeneratorExpression::InstallInterface);
  465. includesDestinationDirs.clear();
  466. char const* const propName = "INTERFACE_INCLUDE_DIRECTORIES";
  467. cmValue input = target->GetProperty(propName);
  468. cmGeneratorExpression ge(*target->Makefile->GetCMakeInstance());
  469. std::string dirs = cmGeneratorExpression::Preprocess(
  470. cmList::to_string(target->Target->GetInstallIncludeDirectoriesEntries(te)),
  471. preprocessRule, this->GetImportPrefixWithSlash());
  472. this->ReplaceInstallPrefix(dirs);
  473. std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
  474. std::string exportDirs =
  475. cge->Evaluate(target->GetLocalGenerator(), "", target);
  476. if (cge->GetHadContextSensitiveCondition()) {
  477. cmLocalGenerator* lg = target->GetLocalGenerator();
  478. std::ostringstream e;
  479. e << "Target \"" << target->GetName()
  480. << "\" is installed with "
  481. "INCLUDES DESTINATION set to a context sensitive path. Paths which "
  482. "depend on the configuration, policy values or the link interface "
  483. "are "
  484. "not supported. Consider using target_include_directories instead.";
  485. lg->IssueMessage(MessageType::FATAL_ERROR, e.str());
  486. return;
  487. }
  488. if (!input && exportDirs.empty()) {
  489. return;
  490. }
  491. if ((input && input->empty()) && exportDirs.empty()) {
  492. // Set to empty
  493. properties[propName].clear();
  494. return;
  495. }
  496. this->AddImportPrefix(exportDirs);
  497. includesDestinationDirs = exportDirs;
  498. std::string includes = (input ? *input : "");
  499. char const* const sep = input ? ";" : "";
  500. includes += sep + exportDirs;
  501. std::string prepro = cmGeneratorExpression::Preprocess(
  502. includes, preprocessRule, this->GetImportPrefixWithSlash());
  503. if (!prepro.empty()) {
  504. this->ResolveTargetsInGeneratorExpressions(prepro, target);
  505. if (!this->CheckInterfaceDirs(prepro, target, propName)) {
  506. return;
  507. }
  508. properties[propName] = prepro;
  509. }
  510. }
  511. void cmExportInstallFileGenerator::PopulateLinkDependsInterface(
  512. cmGeneratorTarget const* gt,
  513. cmGeneratorExpression::PreprocessContext preprocessRule,
  514. ImportPropertyMap& properties)
  515. {
  516. assert(preprocessRule == cmGeneratorExpression::InstallInterface);
  517. char const* const propName = "INTERFACE_LINK_DEPENDS";
  518. cmValue input = gt->GetProperty(propName);
  519. if (!input) {
  520. return;
  521. }
  522. if (input->empty()) {
  523. properties[propName].clear();
  524. return;
  525. }
  526. std::string prepro = cmGeneratorExpression::Preprocess(
  527. *input, preprocessRule, this->GetImportPrefixWithSlash());
  528. if (!prepro.empty()) {
  529. this->ResolveTargetsInGeneratorExpressions(prepro, gt);
  530. if (!this->CheckInterfaceDirs(prepro, gt, propName)) {
  531. return;
  532. }
  533. properties[propName] = prepro;
  534. }
  535. }
  536. void cmExportInstallFileGenerator::PopulateLinkDirectoriesInterface(
  537. cmGeneratorTarget const* gt,
  538. cmGeneratorExpression::PreprocessContext preprocessRule,
  539. ImportPropertyMap& properties)
  540. {
  541. assert(preprocessRule == cmGeneratorExpression::InstallInterface);
  542. char const* const propName = "INTERFACE_LINK_DIRECTORIES";
  543. cmValue input = gt->GetProperty(propName);
  544. if (!input) {
  545. return;
  546. }
  547. if (input->empty()) {
  548. properties[propName].clear();
  549. return;
  550. }
  551. std::string prepro = cmGeneratorExpression::Preprocess(
  552. *input, preprocessRule, this->GetImportPrefixWithSlash());
  553. if (!prepro.empty()) {
  554. this->ResolveTargetsInGeneratorExpressions(prepro, gt);
  555. if (!this->CheckInterfaceDirs(prepro, gt, propName)) {
  556. return;
  557. }
  558. properties[propName] = prepro;
  559. }
  560. }