cmTargetPropertyComputer.cxx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 "cmTargetPropertyComputer.h"
  4. #include <sstream>
  5. #include "cmMessageType.h"
  6. #include "cmMessenger.h"
  7. #include "cmPolicies.h"
  8. #include "cmStateSnapshot.h"
  9. bool cmTargetPropertyComputer::HandleLocationPropertyPolicy(
  10. std::string const& tgtName, cmMessenger* messenger,
  11. cmListFileBacktrace const& context)
  12. {
  13. std::ostringstream e;
  14. const char* modal = nullptr;
  15. MessageType messageType = MessageType::AUTHOR_WARNING;
  16. switch (context.GetBottom().GetPolicy(cmPolicies::CMP0026)) {
  17. case cmPolicies::WARN:
  18. e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0026) << "\n";
  19. modal = "should";
  20. CM_FALLTHROUGH;
  21. case cmPolicies::OLD:
  22. break;
  23. case cmPolicies::REQUIRED_ALWAYS:
  24. case cmPolicies::REQUIRED_IF_USED:
  25. case cmPolicies::NEW:
  26. modal = "may";
  27. messageType = MessageType::FATAL_ERROR;
  28. break;
  29. }
  30. if (modal) {
  31. e << "The LOCATION property " << modal << " not be read from target \""
  32. << tgtName
  33. << "\". Use the target name directly with "
  34. "add_custom_command, or use the generator expression $<TARGET_FILE>, "
  35. "as appropriate.\n";
  36. messenger->IssueMessage(messageType, e.str(), context);
  37. }
  38. return messageType != MessageType::FATAL_ERROR;
  39. }