mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-22 06:59:01 -06:00
include: refactor call sites of cmMakefile::ReadDependentFile
Fixes: #16773
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user