diff options
author | Asit Dhal <dhal.asitk@gmail.com> | 2020-10-21 09:20:37 (GMT) |
---|---|---|
committer | Asit Dhal <dhal.asitk@gmail.com> | 2020-10-21 09:20:37 (GMT) |
commit | 3c324689a7a3e16b7f232b943efd4ded971467bf (patch) | |
tree | 4a424dbf0a4c4995e261cf480339c19f26cfe9dc /Source/cmIncludeCommand.cxx | |
parent | ef9030a94f1cd65b38daa636ab3b66b3268f8674 (diff) | |
download | CMake-3c324689a7a3e16b7f232b943efd4ded971467bf.zip CMake-3c324689a7a3e16b7f232b943efd4ded971467bf.tar.gz CMake-3c324689a7a3e16b7f232b943efd4ded971467bf.tar.bz2 |
include: refactor call sites of cmMakefile::ReadDependentFile
Fixes: #16773
Diffstat (limited to 'Source/cmIncludeCommand.cxx')
-rw-r--r-- | Source/cmIncludeCommand.cxx | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index ae801bb..5e3aec5 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -146,11 +146,24 @@ bool cmIncludeCommand(std::vector<std::string> const& args, std::string listFile = cmSystemTools::CollapseFullPath( fname, status.GetMakefile().GetCurrentSourceDirectory()); - if (optional && !cmSystemTools::FileExists(listFile)) { + + const bool fileDoesnotExist = !cmSystemTools::FileExists(listFile); + const bool fileIsDirectory = cmSystemTools::FileIsDirectory(listFile); + if (fileDoesnotExist || fileIsDirectory) { if (!resultVarName.empty()) { status.GetMakefile().AddDefinition(resultVarName, "NOTFOUND"); } - return true; + if (optional) { + return true; + } + if (fileDoesnotExist) { + status.SetError(cmStrCat("could not find requested file:\n ", fname)); + return false; + } + if (fileIsDirectory) { + status.SetError(cmStrCat("requested file is a directory:\n ", fname)); + return false; + } } bool readit = @@ -163,9 +176,7 @@ bool cmIncludeCommand(std::vector<std::string> const& args, } if (!optional && !readit && !cmSystemTools::GetFatalErrorOccured()) { - std::string m = cmStrCat("could not find load file:\n" - " ", - fname); + std::string m = cmStrCat("could not load requested file:\n ", fname); status.SetError(m); return false; } |