MCPcopy Create free account
hub / github.com/Kitware/CMake / CheckCMP0004

Method CheckCMP0004

Source/cmGeneratorTarget.cxx:5008–5031  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5006}
5007
5008std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
5009{
5010 // Strip whitespace off the library names because we used to do this
5011 // in case variables were expanded at generate time. We no longer
5012 // do the expansion but users link to libraries like " ${VAR} ".
5013 std::string lib = item;
5014 std::string::size_type pos = lib.find_first_not_of(" \t\r\n");
5015 if (pos != std::string::npos) {
5016 lib = lib.substr(pos);
5017 }
5018 pos = lib.find_last_not_of(" \t\r\n");
5019 if (pos != std::string::npos) {
5020 lib = lib.substr(0, pos + 1);
5021 }
5022 if (lib != item) {
5023 cmake* cm = this->LocalGenerator->GetCMakeInstance();
5024 std::ostringstream e;
5025 e << "Target \"" << this->GetName() << "\" links to item \"" << item
5026 << "\" which has leading or trailing whitespace. "
5027 << "This is now an error according to policy CMP0004.";
5028 cm->IssueMessage(MessageType::FATAL_ERROR, e.str(), this->GetBacktrace());
5029 }
5030 return lib;
5031}
5032
5033bool cmGeneratorTarget::IsDeprecated() const
5034{

Callers 2

LookupLinkItemMethod · 0.95

Calls 8

GetBacktraceMethod · 0.95
find_first_not_ofMethod · 0.80
find_last_not_ofMethod · 0.80
strMethod · 0.80
substrMethod · 0.45
GetCMakeInstanceMethod · 0.45
GetNameMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected