cmExportInstallFileGenerator.cxx 21 KB

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