diff options
author | Brad King <brad.king@kitware.com> | 2021-03-17 16:44:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-03-18 13:57:49 (GMT) |
commit | 06feb845aab7127a3067567a8fffb5777eac8187 (patch) | |
tree | 8ffb21abe868bb96eff177bf3ff4eddb4554c69e /Source/cmSourceFile.cxx | |
parent | fab7fe7ef5a5462952297611c1dd668a603e3a36 (diff) | |
download | CMake-06feb845aab7127a3067567a8fffb5777eac8187.zip CMake-06feb845aab7127a3067567a8fffb5777eac8187.tar.gz CMake-06feb845aab7127a3067567a8fffb5777eac8187.tar.bz2 |
CMP0118: Fix NEW behavior when looking up target sources
Under the CMP0118 NEW behavior, sources generated in one directory
should be visible when added to targets in other directories. This was
accidentally left out of commit 6624b65b3f (GENERATED prop: Add
implementation for policy CMP0118 being set to NEW, 2020-11-09,
v3.20.0-rc1~393^2~1).
Fixes: #18399
Diffstat (limited to 'Source/cmSourceFile.cxx')
-rw-r--r-- | Source/cmSourceFile.cxx | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 72bc972..3f3c8d5 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -141,14 +141,21 @@ bool cmSourceFile::FindFullPath(std::string* error, std::vector<std::string> exts = makefile->GetCMakeInstance()->GetAllExtensions(); auto cmp0115 = makefile->GetPolicyStatus(cmPolicies::CMP0115); + auto cmp0118 = makefile->GetPolicyStatus(cmPolicies::CMP0118); + bool const cmp0118new = + cmp0118 != cmPolicies::OLD && cmp0118 != cmPolicies::WARN; // Tries to find the file in a given directory - auto findInDir = [this, &exts, &lPath, cmp0115, cmp0115Warning, + auto findInDir = [this, &exts, &lPath, cmp0115, cmp0115Warning, cmp0118new, makefile](std::string const& dir) -> bool { // Compute full path std::string const fullPath = cmSystemTools::CollapseFullPath(lPath, dir); // Try full path - if (cmSystemTools::FileExists(fullPath)) { + if (cmp0118new && + makefile->GetGlobalGenerator()->IsGeneratedFile(fullPath)) { + this->IsGenerated = true; + } + if (this->IsGenerated || cmSystemTools::FileExists(fullPath)) { this->FullPath = fullPath; return true; } @@ -160,7 +167,11 @@ bool cmSourceFile::FindFullPath(std::string* error, for (std::string const& ext : exts) { if (!ext.empty()) { std::string extPath = cmStrCat(fullPath, '.', ext); - if (cmSystemTools::FileExists(extPath)) { + if (cmp0118new && + makefile->GetGlobalGenerator()->IsGeneratedFile(extPath)) { + this->IsGenerated = true; + } + if (this->IsGenerated || cmSystemTools::FileExists(extPath)) { this->FullPath = extPath; if (cmp0115 == cmPolicies::WARN) { std::string warning = |