cmGeneratorTarget_CompatibleInterface.cxx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file LICENSE.rst or https://cmake.org/licensing for details. */
  3. /* clang-format off */
  4. #include "cmGeneratorTarget.h"
  5. /* clang-format on */
  6. #include <algorithm>
  7. #include <cassert>
  8. #include <cerrno>
  9. #include <cstddef>
  10. #include <cstdlib>
  11. #include <cstring>
  12. #include <iterator>
  13. #include <map>
  14. #include <set>
  15. #include <sstream>
  16. #include <string>
  17. #include <utility>
  18. #include <vector>
  19. #include <cm/memory>
  20. #include <cmext/algorithm>
  21. #include "cmComputeLinkInformation.h"
  22. #include "cmGeneratorExpression.h"
  23. #include "cmList.h"
  24. #include "cmLocalGenerator.h"
  25. #include "cmMessageType.h"
  26. #include "cmRange.h"
  27. #include "cmStateTypes.h"
  28. #include "cmStringAlgorithms.h"
  29. #include "cmSystemTools.h"
  30. #include "cmValue.h"
  31. namespace {
  32. using UseTo = cmGeneratorTarget::UseTo;
  33. }
  34. cmGeneratorTarget::CompatibleInterfacesBase const&
  35. cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const
  36. {
  37. cmGeneratorTarget::CompatibleInterfaces& compat =
  38. this->CompatibleInterfacesMap[config];
  39. if (!compat.Done) {
  40. compat.Done = true;
  41. compat.PropsBool.insert("POSITION_INDEPENDENT_CODE");
  42. compat.PropsString.insert("AUTOUIC_OPTIONS");
  43. std::vector<cmGeneratorTarget const*> const& deps =
  44. this->GetLinkImplementationClosure(config, UseTo::Compile);
  45. for (cmGeneratorTarget const* li : deps) {
  46. #define CM_READ_COMPATIBLE_INTERFACE(X, x) \
  47. if (cmValue prop = li->GetProperty("COMPATIBLE_INTERFACE_" #X)) { \
  48. cmList props(*prop); \
  49. compat.Props##x.insert(props.begin(), props.end()); \
  50. }
  51. CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool)
  52. CM_READ_COMPATIBLE_INTERFACE(STRING, String)
  53. CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin)
  54. CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax)
  55. #undef CM_READ_COMPATIBLE_INTERFACE
  56. }
  57. }
  58. return compat;
  59. }
  60. bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty(
  61. std::string const& p, std::string const& config) const
  62. {
  63. if (this->GetType() == cmStateEnums::OBJECT_LIBRARY ||
  64. this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
  65. return false;
  66. }
  67. return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0;
  68. }
  69. bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty(
  70. std::string const& p, std::string const& config) const
  71. {
  72. if (this->GetType() == cmStateEnums::OBJECT_LIBRARY ||
  73. this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
  74. return false;
  75. }
  76. return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0;
  77. }
  78. bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty(
  79. std::string const& p, std::string const& config) const
  80. {
  81. if (this->GetType() == cmStateEnums::OBJECT_LIBRARY ||
  82. this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
  83. return false;
  84. }
  85. return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0;
  86. }
  87. bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty(
  88. std::string const& p, std::string const& config) const
  89. {
  90. if (this->GetType() == cmStateEnums::OBJECT_LIBRARY ||
  91. this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
  92. return false;
  93. }
  94. return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0;
  95. }
  96. enum CompatibleType
  97. {
  98. BoolType,
  99. StringType,
  100. NumberMinType,
  101. NumberMaxType
  102. };
  103. template <typename PropertyType>
  104. PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
  105. std::string const& prop,
  106. std::string const& config,
  107. CompatibleType, PropertyType*);
  108. template <>
  109. bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
  110. std::string const& prop,
  111. std::string const& config,
  112. CompatibleType /*unused*/,
  113. bool* /*unused*/)
  114. {
  115. return tgt->GetLinkInterfaceDependentBoolProperty(prop, config);
  116. }
  117. template <>
  118. char const* getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
  119. std::string const& prop,
  120. std::string const& config,
  121. CompatibleType t,
  122. char const** /*unused*/)
  123. {
  124. switch (t) {
  125. case BoolType:
  126. assert(false &&
  127. "String compatibility check function called for boolean");
  128. return nullptr;
  129. case StringType:
  130. return tgt->GetLinkInterfaceDependentStringProperty(prop, config);
  131. case NumberMinType:
  132. return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config);
  133. case NumberMaxType:
  134. return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config);
  135. }
  136. assert(false && "Unreachable!");
  137. return nullptr;
  138. }
  139. template <typename PropertyType>
  140. void checkPropertyConsistency(cmGeneratorTarget const* depender,
  141. cmGeneratorTarget const* dependee,
  142. std::string const& propName,
  143. std::set<std::string>& emitted,
  144. std::string const& config, CompatibleType t,
  145. PropertyType* /*unused*/)
  146. {
  147. cmValue prop = dependee->GetProperty(propName);
  148. if (!prop) {
  149. return;
  150. }
  151. cmList props{ *prop };
  152. std::string pdir =
  153. cmStrCat(cmSystemTools::GetCMakeRoot(), "/Help/prop_tgt/");
  154. for (std::string const& p : props) {
  155. std::string pname = cmSystemTools::HelpFileName(p);
  156. std::string pfile = pdir + pname + ".rst";
  157. if (cmSystemTools::FileExists(pfile, true)) {
  158. std::ostringstream e;
  159. e << "Target \"" << dependee->GetName() << "\" has property \"" << p
  160. << "\" listed in its " << propName
  161. << " property. "
  162. "This is not allowed. Only user-defined properties may appear "
  163. "listed in the "
  164. << propName << " property.";
  165. depender->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
  166. e.str());
  167. return;
  168. }
  169. if (emitted.insert(p).second) {
  170. getLinkInterfaceDependentProperty<PropertyType>(depender, p, config, t,
  171. nullptr);
  172. if (cmSystemTools::GetErrorOccurredFlag()) {
  173. return;
  174. }
  175. }
  176. }
  177. }
  178. namespace {
  179. std::string intersect(std::set<std::string> const& s1,
  180. std::set<std::string> const& s2)
  181. {
  182. std::set<std::string> intersect;
  183. std::set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(),
  184. std::inserter(intersect, intersect.begin()));
  185. if (!intersect.empty()) {
  186. return *intersect.begin();
  187. }
  188. return "";
  189. }
  190. std::string intersect(std::set<std::string> const& s1,
  191. std::set<std::string> const& s2,
  192. std::set<std::string> const& s3)
  193. {
  194. std::string result;
  195. result = intersect(s1, s2);
  196. if (!result.empty()) {
  197. return result;
  198. }
  199. result = intersect(s1, s3);
  200. if (!result.empty()) {
  201. return result;
  202. }
  203. return intersect(s2, s3);
  204. }
  205. std::string intersect(std::set<std::string> const& s1,
  206. std::set<std::string> const& s2,
  207. std::set<std::string> const& s3,
  208. std::set<std::string> const& s4)
  209. {
  210. std::string result;
  211. result = intersect(s1, s2);
  212. if (!result.empty()) {
  213. return result;
  214. }
  215. result = intersect(s1, s3);
  216. if (!result.empty()) {
  217. return result;
  218. }
  219. result = intersect(s1, s4);
  220. if (!result.empty()) {
  221. return result;
  222. }
  223. return intersect(s2, s3, s4);
  224. }
  225. }
  226. void cmGeneratorTarget::CheckPropertyCompatibility(
  227. cmComputeLinkInformation& info, std::string const& config) const
  228. {
  229. cmComputeLinkInformation::ItemVector const& deps = info.GetItems();
  230. std::set<std::string> emittedBools;
  231. static std::string const strBool = "COMPATIBLE_INTERFACE_BOOL";
  232. std::set<std::string> emittedStrings;
  233. static std::string const strString = "COMPATIBLE_INTERFACE_STRING";
  234. std::set<std::string> emittedMinNumbers;
  235. static std::string const strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN";
  236. std::set<std::string> emittedMaxNumbers;
  237. static std::string const strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX";
  238. for (auto const& dep : deps) {
  239. if (!dep.Target || dep.Target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
  240. continue;
  241. }
  242. checkPropertyConsistency<bool>(this, dep.Target, strBool, emittedBools,
  243. config, BoolType, nullptr);
  244. if (cmSystemTools::GetErrorOccurredFlag()) {
  245. return;
  246. }
  247. checkPropertyConsistency<char const*>(this, dep.Target, strString,
  248. emittedStrings, config, StringType,
  249. nullptr);
  250. if (cmSystemTools::GetErrorOccurredFlag()) {
  251. return;
  252. }
  253. checkPropertyConsistency<char const*>(this, dep.Target, strNumMin,
  254. emittedMinNumbers, config,
  255. NumberMinType, nullptr);
  256. if (cmSystemTools::GetErrorOccurredFlag()) {
  257. return;
  258. }
  259. checkPropertyConsistency<char const*>(this, dep.Target, strNumMax,
  260. emittedMaxNumbers, config,
  261. NumberMaxType, nullptr);
  262. if (cmSystemTools::GetErrorOccurredFlag()) {
  263. return;
  264. }
  265. }
  266. std::string prop = intersect(emittedBools, emittedStrings, emittedMinNumbers,
  267. emittedMaxNumbers);
  268. if (!prop.empty()) {
  269. // Use a sorted std::vector to keep the error message sorted.
  270. std::vector<std::string> props;
  271. auto i = emittedBools.find(prop);
  272. if (i != emittedBools.end()) {
  273. props.push_back(strBool);
  274. }
  275. i = emittedStrings.find(prop);
  276. if (i != emittedStrings.end()) {
  277. props.push_back(strString);
  278. }
  279. i = emittedMinNumbers.find(prop);
  280. if (i != emittedMinNumbers.end()) {
  281. props.push_back(strNumMin);
  282. }
  283. i = emittedMaxNumbers.find(prop);
  284. if (i != emittedMaxNumbers.end()) {
  285. props.push_back(strNumMax);
  286. }
  287. std::sort(props.begin(), props.end());
  288. std::string propsString = cmStrCat(
  289. cmJoin(cmMakeRange(props).retreat(1), ", "), " and the ", props.back());
  290. std::ostringstream e;
  291. e << "Property \"" << prop << "\" appears in both the " << propsString
  292. << " property in the dependencies of target \"" << this->GetName()
  293. << "\". This is not allowed. A property may only require "
  294. "compatibility "
  295. "in a boolean interpretation, a numeric minimum, a numeric maximum "
  296. "or a "
  297. "string interpretation, but not a mixture.";
  298. this->LocalGenerator->IssueMessage(MessageType::FATAL_ERROR, e.str());
  299. }
  300. }
  301. template <typename PropertyType>
  302. std::string valueAsString(PropertyType);
  303. template <>
  304. std::string valueAsString<bool>(bool value)
  305. {
  306. return value ? "TRUE" : "FALSE";
  307. }
  308. template <>
  309. std::string valueAsString<char const*>(char const* value)
  310. {
  311. return value ? value : "(unset)";
  312. }
  313. template <>
  314. std::string valueAsString<std::string>(std::string value)
  315. {
  316. return value;
  317. }
  318. template <>
  319. std::string valueAsString<cmValue>(cmValue value)
  320. {
  321. return value ? *value : std::string("(unset)");
  322. }
  323. template <>
  324. std::string valueAsString<std::nullptr_t>(std::nullptr_t /*unused*/)
  325. {
  326. return "(unset)";
  327. }
  328. static std::string compatibilityType(CompatibleType t)
  329. {
  330. switch (t) {
  331. case BoolType:
  332. return "Boolean compatibility";
  333. case StringType:
  334. return "String compatibility";
  335. case NumberMaxType:
  336. return "Numeric maximum compatibility";
  337. case NumberMinType:
  338. return "Numeric minimum compatibility";
  339. }
  340. assert(false && "Unreachable!");
  341. return "";
  342. }
  343. static std::string compatibilityAgree(CompatibleType t, bool dominant)
  344. {
  345. switch (t) {
  346. case BoolType:
  347. case StringType:
  348. return dominant ? "(Disagree)\n" : "(Agree)\n";
  349. case NumberMaxType:
  350. case NumberMinType:
  351. return dominant ? "(Dominant)\n" : "(Ignored)\n";
  352. }
  353. assert(false && "Unreachable!");
  354. return "";
  355. }
  356. template <typename PropertyType>
  357. PropertyType getTypedProperty(
  358. cmGeneratorTarget const* tgt, std::string const& prop,
  359. cmGeneratorExpressionInterpreter* genexInterpreter = nullptr);
  360. template <>
  361. bool getTypedProperty<bool>(cmGeneratorTarget const* tgt,
  362. std::string const& prop,
  363. cmGeneratorExpressionInterpreter* genexInterpreter)
  364. {
  365. if (!genexInterpreter) {
  366. return tgt->GetPropertyAsBool(prop);
  367. }
  368. cmValue value = tgt->GetProperty(prop);
  369. return cmIsOn(genexInterpreter->Evaluate(value ? *value : "", prop));
  370. }
  371. template <>
  372. char const* getTypedProperty<char const*>(
  373. cmGeneratorTarget const* tgt, std::string const& prop,
  374. cmGeneratorExpressionInterpreter* genexInterpreter)
  375. {
  376. cmValue value = tgt->GetProperty(prop);
  377. if (!genexInterpreter) {
  378. return value.GetCStr();
  379. }
  380. return genexInterpreter->Evaluate(value ? *value : "", prop).c_str();
  381. }
  382. template <>
  383. std::string getTypedProperty<std::string>(
  384. cmGeneratorTarget const* tgt, std::string const& prop,
  385. cmGeneratorExpressionInterpreter* genexInterpreter)
  386. {
  387. cmValue value = tgt->GetProperty(prop);
  388. if (!genexInterpreter) {
  389. return valueAsString(value);
  390. }
  391. return genexInterpreter->Evaluate(value ? *value : "", prop);
  392. }
  393. template <typename PropertyType>
  394. PropertyType impliedValue(PropertyType);
  395. template <>
  396. bool impliedValue<bool>(bool /*unused*/)
  397. {
  398. return false;
  399. }
  400. template <>
  401. char const* impliedValue<char const*>(char const* /*unused*/)
  402. {
  403. return "";
  404. }
  405. template <>
  406. std::string impliedValue<std::string>(std::string /*unused*/) // NOLINT(*)
  407. {
  408. return std::string();
  409. }
  410. template <typename PropertyType>
  411. std::pair<bool, PropertyType> consistentProperty(PropertyType lhs,
  412. PropertyType rhs,
  413. CompatibleType t);
  414. template <>
  415. std::pair<bool, bool> consistentProperty(bool lhs, bool rhs,
  416. CompatibleType /*unused*/)
  417. {
  418. return { lhs == rhs, lhs };
  419. }
  420. static std::pair<bool, char const*> consistentStringProperty(char const* lhs,
  421. char const* rhs)
  422. {
  423. bool const b = strcmp(lhs, rhs) == 0;
  424. return { b, b ? lhs : nullptr };
  425. }
  426. static std::pair<bool, std::string> consistentStringProperty(
  427. std::string const& lhs, std::string const& rhs)
  428. {
  429. bool const b = lhs == rhs;
  430. return { b, b ? lhs : valueAsString(nullptr) };
  431. }
  432. static std::pair<bool, char const*> consistentNumberProperty(char const* lhs,
  433. char const* rhs,
  434. CompatibleType t)
  435. {
  436. char* pEnd;
  437. long lnum = strtol(lhs, &pEnd, 0);
  438. if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) {
  439. return { false, nullptr };
  440. }
  441. long rnum = strtol(rhs, &pEnd, 0);
  442. if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) {
  443. return { false, nullptr };
  444. }
  445. if (t == NumberMaxType) {
  446. return { true, std::max(lnum, rnum) == lnum ? lhs : rhs };
  447. }
  448. return { true, std::min(lnum, rnum) == lnum ? lhs : rhs };
  449. }
  450. template <>
  451. std::pair<bool, char const*> consistentProperty(char const* lhs,
  452. char const* rhs,
  453. CompatibleType t)
  454. {
  455. if (!lhs && !rhs) {
  456. return { true, lhs };
  457. }
  458. if (!lhs) {
  459. return { true, rhs };
  460. }
  461. if (!rhs) {
  462. return { true, lhs };
  463. }
  464. switch (t) {
  465. case BoolType: {
  466. bool same = cmIsOn(lhs) == cmIsOn(rhs);
  467. return { same, same ? lhs : nullptr };
  468. }
  469. case StringType:
  470. return consistentStringProperty(lhs, rhs);
  471. case NumberMinType:
  472. case NumberMaxType:
  473. return consistentNumberProperty(lhs, rhs, t);
  474. }
  475. assert(false && "Unreachable!");
  476. return { false, nullptr };
  477. }
  478. static std::pair<bool, std::string> consistentProperty(std::string const& lhs,
  479. std::string const& rhs,
  480. CompatibleType t)
  481. {
  482. std::string const null_ptr = valueAsString(nullptr);
  483. if (lhs == null_ptr && rhs == null_ptr) {
  484. return { true, lhs };
  485. }
  486. if (lhs == null_ptr) {
  487. return { true, rhs };
  488. }
  489. if (rhs == null_ptr) {
  490. return { true, lhs };
  491. }
  492. switch (t) {
  493. case BoolType: {
  494. bool same = cmIsOn(lhs) == cmIsOn(rhs);
  495. return { same, same ? lhs : null_ptr };
  496. }
  497. case StringType:
  498. return consistentStringProperty(lhs, rhs);
  499. case NumberMinType:
  500. case NumberMaxType: {
  501. auto value = consistentNumberProperty(lhs.c_str(), rhs.c_str(), t);
  502. return { value.first,
  503. value.first ? std::string(value.second) : null_ptr };
  504. }
  505. }
  506. assert(false && "Unreachable!");
  507. return { false, null_ptr };
  508. }
  509. template <typename PropertyType>
  510. PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
  511. std::string const& p,
  512. std::string const& config,
  513. char const* defaultValue,
  514. CompatibleType t,
  515. PropertyType* /*unused*/)
  516. {
  517. PropertyType propContent = getTypedProperty<PropertyType>(tgt, p);
  518. std::vector<std::string> headPropKeys = tgt->GetPropertyKeys();
  519. bool const explicitlySet = cm::contains(headPropKeys, p);
  520. bool const impliedByUse = tgt->IsNullImpliedByLinkLibraries(p);
  521. assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet));
  522. std::vector<cmGeneratorTarget const*> const& deps =
  523. tgt->GetLinkImplementationClosure(config, UseTo::Compile);
  524. if (deps.empty()) {
  525. return propContent;
  526. }
  527. bool propInitialized = explicitlySet;
  528. std::string report = cmStrCat(" * Target \"", tgt->GetName());
  529. if (explicitlySet) {
  530. report += "\" has property content \"";
  531. report += valueAsString<PropertyType>(propContent);
  532. report += "\"\n";
  533. } else if (impliedByUse) {
  534. report += "\" property is implied by use.\n";
  535. } else {
  536. report += "\" property not set.\n";
  537. }
  538. std::string interfaceProperty = "INTERFACE_" + p;
  539. std::unique_ptr<cmGeneratorExpressionInterpreter> genexInterpreter;
  540. if (p == "POSITION_INDEPENDENT_CODE") {
  541. // Corresponds to EvaluatingPICExpression.
  542. genexInterpreter = cm::make_unique<cmGeneratorExpressionInterpreter>(
  543. tgt->GetLocalGenerator(), config, tgt);
  544. }
  545. for (cmGeneratorTarget const* theTarget : deps) {
  546. // An error should be reported if one dependency
  547. // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other
  548. // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the
  549. // target itself has a POSITION_INDEPENDENT_CODE which disagrees
  550. // with a dependency.
  551. std::vector<std::string> propKeys = theTarget->GetPropertyKeys();
  552. bool const ifaceIsSet = cm::contains(propKeys, interfaceProperty);
  553. PropertyType ifacePropContent = getTypedProperty<PropertyType>(
  554. theTarget, interfaceProperty, genexInterpreter.get());
  555. std::string reportEntry;
  556. if (ifaceIsSet) {
  557. reportEntry += " * Target \"";
  558. reportEntry += theTarget->GetName();
  559. reportEntry += "\" property value \"";
  560. reportEntry += valueAsString<PropertyType>(ifacePropContent);
  561. reportEntry += "\" ";
  562. }
  563. if (explicitlySet) {
  564. if (ifaceIsSet) {
  565. std::pair<bool, PropertyType> consistent =
  566. consistentProperty(propContent, ifacePropContent, t);
  567. report += reportEntry;
  568. report += compatibilityAgree(t, propContent != consistent.second);
  569. if (!consistent.first) {
  570. std::ostringstream e;
  571. e << "Property " << p << " on target \"" << tgt->GetName()
  572. << "\" does\nnot match the "
  573. "INTERFACE_"
  574. << p
  575. << " property requirement\nof "
  576. "dependency \""
  577. << theTarget->GetName() << "\".\n";
  578. cmSystemTools::Error(e.str());
  579. break;
  580. }
  581. propContent = consistent.second;
  582. continue;
  583. }
  584. // Explicitly set on target and not set in iface. Can't disagree.
  585. continue;
  586. }
  587. if (impliedByUse) {
  588. propContent = impliedValue<PropertyType>(propContent);
  589. if (ifaceIsSet) {
  590. std::pair<bool, PropertyType> consistent =
  591. consistentProperty(propContent, ifacePropContent, t);
  592. report += reportEntry;
  593. report += compatibilityAgree(t, propContent != consistent.second);
  594. if (!consistent.first) {
  595. std::ostringstream e;
  596. e << "Property " << p << " on target \"" << tgt->GetName()
  597. << "\" is\nimplied to be " << defaultValue
  598. << " because it was used to determine the link libraries\n"
  599. "already. The INTERFACE_"
  600. << p << " property on\ndependency \"" << theTarget->GetName()
  601. << "\" is in conflict.\n";
  602. cmSystemTools::Error(e.str());
  603. break;
  604. }
  605. propContent = consistent.second;
  606. continue;
  607. }
  608. // Implicitly set on target and not set in iface. Can't disagree.
  609. continue;
  610. }
  611. if (ifaceIsSet) {
  612. if (propInitialized) {
  613. std::pair<bool, PropertyType> consistent =
  614. consistentProperty(propContent, ifacePropContent, t);
  615. report += reportEntry;
  616. report += compatibilityAgree(t, propContent != consistent.second);
  617. if (!consistent.first) {
  618. std::ostringstream e;
  619. e << "The INTERFACE_" << p << " property of \""
  620. << theTarget->GetName() << "\" does\nnot agree with the value of "
  621. << p << " already determined\nfor \"" << tgt->GetName() << "\".\n";
  622. cmSystemTools::Error(e.str());
  623. break;
  624. }
  625. propContent = consistent.second;
  626. continue;
  627. }
  628. report += reportEntry + "(Interface set)\n";
  629. propContent = ifacePropContent;
  630. propInitialized = true;
  631. } else {
  632. // Not set. Nothing to agree on.
  633. continue;
  634. }
  635. }
  636. tgt->ReportPropertyOrigin(p, valueAsString<PropertyType>(propContent),
  637. report, compatibilityType(t));
  638. return propContent;
  639. }
  640. bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty(
  641. std::string const& p, std::string const& config) const
  642. {
  643. return checkInterfacePropertyCompatibility<bool>(this, p, config, "FALSE",
  644. BoolType, nullptr);
  645. }
  646. std::string cmGeneratorTarget::GetLinkInterfaceDependentStringAsBoolProperty(
  647. std::string const& p, std::string const& config) const
  648. {
  649. return checkInterfacePropertyCompatibility<std::string>(
  650. this, p, config, "FALSE", BoolType, nullptr);
  651. }
  652. char const* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty(
  653. std::string const& p, std::string const& config) const
  654. {
  655. return checkInterfacePropertyCompatibility<char const*>(
  656. this, p, config, "empty", StringType, nullptr);
  657. }
  658. char const* cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty(
  659. std::string const& p, std::string const& config) const
  660. {
  661. return checkInterfacePropertyCompatibility<char const*>(
  662. this, p, config, "empty", NumberMinType, nullptr);
  663. }
  664. char const* cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty(
  665. std::string const& p, std::string const& config) const
  666. {
  667. return checkInterfacePropertyCompatibility<char const*>(
  668. this, p, config, "empty", NumberMaxType, nullptr);
  669. }