include: refactor call sites of cmMakefile::ReadDependentFile
Fixes: #16773
This commit is contained in:
parent
ef9030a94f
commit
3c324689a7
@ -122,7 +122,7 @@ bool cmCTestSubdirCommand(std::vector<std::string> const& args,
|
||||
readit = status.GetMakefile().ReadDependentFile(fname);
|
||||
}
|
||||
if (!readit) {
|
||||
status.SetError(cmStrCat("Could not find include file: ", fname));
|
||||
status.SetError(cmStrCat("Could not load include file: ", fname));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -358,6 +358,17 @@ static bool IncludeByVariable(cmExecutionStatus& status,
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string includeFile =
|
||||
cmSystemTools::CollapseFullPath(*include, mf.GetCurrentSourceDirectory());
|
||||
if (!cmSystemTools::FileExists(includeFile)) {
|
||||
status.SetError(cmStrCat("could not find requested file:\n ", *include));
|
||||
return false;
|
||||
}
|
||||
if (cmSystemTools::FileIsDirectory(includeFile)) {
|
||||
status.SetError(cmStrCat("requested file is a directory:\n ", *include));
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool readit = mf.ReadDependentFile(*include);
|
||||
if (readit) {
|
||||
return true;
|
||||
@ -367,7 +378,7 @@ static bool IncludeByVariable(cmExecutionStatus& status,
|
||||
return true;
|
||||
}
|
||||
|
||||
status.SetError(cmStrCat("could not find file:\n ", *include));
|
||||
status.SetError(cmStrCat("could not load requested file:\n ", *include));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
CMake Error at ExportExportInclude.cmake:6 \(include\):
|
||||
include could not find load file:
|
||||
include could not find requested file:
|
||||
|
||||
.*/Tests/RunCMake/include/ExportExportInclude-build/theTargets.cmake
|
||||
Call Stack \(most recent call first\):
|
||||
|
1
Tests/RunCMake/include/IncludeIsDirectory-result.txt
Normal file
1
Tests/RunCMake/include/IncludeIsDirectory-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
6
Tests/RunCMake/include/IncludeIsDirectory-stderr.txt
Normal file
6
Tests/RunCMake/include/IncludeIsDirectory-stderr.txt
Normal file
@ -0,0 +1,6 @@
|
||||
CMake Error at IncludeIsDirectory.cmake:1 \(include\):
|
||||
include requested file is a directory:
|
||||
|
||||
.*/Tests/RunCMake/include/IncludeIsDirectory-build
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
1
Tests/RunCMake/include/IncludeIsDirectory.cmake
Normal file
1
Tests/RunCMake/include/IncludeIsDirectory.cmake
Normal file
@ -0,0 +1 @@
|
||||
include("${CMAKE_CURRENT_BINARY_DIR}")
|
1
Tests/RunCMake/include/IncludeMalformed-result.txt
Normal file
1
Tests/RunCMake/include/IncludeMalformed-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
13
Tests/RunCMake/include/IncludeMalformed-stderr.txt
Normal file
13
Tests/RunCMake/include/IncludeMalformed-stderr.txt
Normal file
@ -0,0 +1,13 @@
|
||||
CMake Error at malformedInclude.cmake:1:
|
||||
Parse error. Function missing ending "\)". End of file reached.
|
||||
Call Stack \(most recent call first\):
|
||||
IncludeMalformed.cmake:1 \(include\)
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
||||
|
||||
CMake Error at IncludeMalformed.cmake:1 \(include\):
|
||||
include could not load requested file:
|
||||
|
||||
malformedInclude.cmake
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
1
Tests/RunCMake/include/IncludeMalformed.cmake
Normal file
1
Tests/RunCMake/include/IncludeMalformed.cmake
Normal file
@ -0,0 +1 @@
|
||||
include("malformedInclude.cmake")
|
@ -5,3 +5,5 @@ run_cmake(EmptyStringOptional)
|
||||
run_cmake(CMP0024-WARN)
|
||||
run_cmake(CMP0024-NEW)
|
||||
run_cmake(ExportExportInclude)
|
||||
run_cmake(IncludeIsDirectory)
|
||||
run_cmake(IncludeMalformed)
|
||||
|
1
Tests/RunCMake/include/malformedInclude.cmake
Normal file
1
Tests/RunCMake/include/malformedInclude.cmake
Normal file
@ -0,0 +1 @@
|
||||
if(
|
Loading…
Reference in New Issue
Block a user