cmExportInstallFileGenerator.cxx 21 KB

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