summaryrefslogtreecommitdiffstats
path: root/Source/cmTargetSourcesCommand.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2021-10-22 15:04:37 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2021-10-27 19:17:23 (GMT)
commitf2bd02246830617c3dec5b517821f14a9aa3453c (patch)
tree54cfa71b58bb1efe332d790510e0f26a4360ddeb /Source/cmTargetSourcesCommand.cxx
parentf2a44a8afabe6d0d87f1b5d4acf31b2049a021fd (diff)
downloadCMake-f2bd02246830617c3dec5b517821f14a9aa3453c.zip
CMake-f2bd02246830617c3dec5b517821f14a9aa3453c.tar.gz
CMake-f2bd02246830617c3dec5b517821f14a9aa3453c.tar.bz2
cmTargetSources: Refactor to add enum class parameters
Diffstat (limited to 'Source/cmTargetSourcesCommand.cxx')
-rw-r--r--Source/cmTargetSourcesCommand.cxx74
1 files changed, 46 insertions, 28 deletions
diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx
index 26282ef..88841bc 100644
--- a/Source/cmTargetSourcesCommand.cxx
+++ b/Source/cmTargetSourcesCommand.cxx
@@ -26,8 +26,10 @@ protected:
bool prepend, bool system) override
{
this->cmTargetPropCommandBase::HandleInterfaceContent(
- tgt, this->ConvertToAbsoluteContent(tgt, content, true), prepend,
- system);
+ tgt,
+ this->ConvertToAbsoluteContent(tgt, content, IsInterface::Yes,
+ CheckCMP0076::Yes),
+ prepend, system);
}
private:
@@ -43,9 +45,9 @@ private:
const std::vector<std::string>& content,
bool /*prepend*/, bool /*system*/) override
{
- tgt->AppendProperty(
- "SOURCES",
- this->Join(this->ConvertToAbsoluteContent(tgt, content, false)));
+ tgt->AppendProperty("SOURCES",
+ this->Join(this->ConvertToAbsoluteContent(
+ tgt, content, IsInterface::No, CheckCMP0076::Yes)));
return true; // Successfully handled.
}
@@ -54,18 +56,29 @@ private:
return cmJoin(content, ";");
}
+ enum class IsInterface
+ {
+ Yes,
+ No,
+ };
+ enum class CheckCMP0076
+ {
+ Yes,
+ No,
+ };
std::vector<std::string> ConvertToAbsoluteContent(
cmTarget* tgt, const std::vector<std::string>& content,
- bool isInterfaceContent);
+ IsInterface isInterfaceContent, CheckCMP0076 checkCmp0076);
};
std::vector<std::string> TargetSourcesImpl::ConvertToAbsoluteContent(
cmTarget* tgt, const std::vector<std::string>& content,
- bool isInterfaceContent)
+ IsInterface isInterfaceContent, CheckCMP0076 checkCmp0076)
{
// Skip conversion in case old behavior has been explicitly requested
- if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0076) ==
- cmPolicies::OLD) {
+ if (checkCmp0076 == CheckCMP0076::Yes &&
+ this->Makefile->GetPolicyStatus(cmPolicies::CMP0076) ==
+ cmPolicies::OLD) {
return content;
}
@@ -76,7 +89,7 @@ std::vector<std::string> TargetSourcesImpl::ConvertToAbsoluteContent(
std::string absoluteSrc;
if (cmSystemTools::FileIsFullPath(src) ||
cmGeneratorExpression::Find(src) == 0 ||
- (!isInterfaceContent &&
+ (isInterfaceContent == IsInterface::No &&
(this->Makefile->GetCurrentSourceDirectory() ==
tgt->GetMakefile()->GetCurrentSourceDirectory()))) {
absoluteSrc = src;
@@ -95,28 +108,33 @@ std::vector<std::string> TargetSourcesImpl::ConvertToAbsoluteContent(
bool issueMessage = true;
bool useAbsoluteContent = false;
std::ostringstream e;
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0076)) {
- case cmPolicies::WARN:
- e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0076) << "\n";
- break;
- case cmPolicies::OLD:
- issueMessage = false;
- break;
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::REQUIRED_IF_USED:
- this->Makefile->IssueMessage(
- MessageType::FATAL_ERROR,
- cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0076));
- break;
- case cmPolicies::NEW: {
- issueMessage = false;
- useAbsoluteContent = true;
- break;
+ if (checkCmp0076 == CheckCMP0076::Yes) {
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0076)) {
+ case cmPolicies::WARN:
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0076) << "\n";
+ break;
+ case cmPolicies::OLD:
+ issueMessage = false;
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0076));
+ break;
+ case cmPolicies::NEW: {
+ issueMessage = false;
+ useAbsoluteContent = true;
+ break;
+ }
}
+ } else {
+ issueMessage = false;
+ useAbsoluteContent = true;
}
if (issueMessage) {
- if (isInterfaceContent) {
+ if (isInterfaceContent == IsInterface::Yes) {
e << "An interface source of target \"" << tgt->GetName()
<< "\" has a relative path.";
} else {