diff options
author | Brad King <brad.king@kitware.com> | 2013-11-08 15:33:14 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-11-08 15:33:14 (GMT) |
commit | 2053e0cd51810d434ec4563186d5e2792d1c9cab (patch) | |
tree | 9941a15086825e24aac3d8b436ba5cd0398b83ec /Source/cmAddLibraryCommand.cxx | |
parent | 064e6d32728a73edcf44d6b52572dbec19e0c90d (diff) | |
parent | 596b2a8c0820bed8195e2377927a18cf2d76727c (diff) | |
download | CMake-2053e0cd51810d434ec4563186d5e2792d1c9cab.zip CMake-2053e0cd51810d434ec4563186d5e2792d1c9cab.tar.gz CMake-2053e0cd51810d434ec4563186d5e2792d1c9cab.tar.bz2 |
Merge topic 'tll-target-policies'
596b2a8 Disallow linking to utility targets (#13902).
301bb5c Disallow link-to-self (#13947).
05f5fde Disallow invalid target names (#13140)
Diffstat (limited to 'Source/cmAddLibraryCommand.cxx')
-rw-r--r-- | Source/cmAddLibraryCommand.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 0e61c99..4c591b6 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -108,6 +108,45 @@ bool cmAddLibraryCommand break; } } + + bool nameOk = cmGeneratorExpression::IsValidTargetName(libName); + if (nameOk && !importTarget && !isAlias) + { + nameOk = libName.find(":") == std::string::npos; + } + if (!nameOk) + { + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) + { + case cmPolicies::WARN: + issueMessage = type != cmTarget::INTERFACE_LIBRARY; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if (issueMessage) + { + cmOStringStream e; + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n"; + e << "The target name \"" << libName << "\" is not valid for certain " + "CMake features, such as generator expressions, and may result " + "in undefined behavior."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + if (isAlias) { if(!cmGeneratorExpression::IsValidTargetName(libName.c_str())) |