cmExportInstallFileGenerator.cxx 21 KB

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