mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 05:16:58 +00:00
cmake: Clarify errors when a script cannot be read
Report the path and reason when a file cannot be opened. Particularly, when under `cmake -P` there is no backtrace to identify the file, leaving very opaque error messages. Also avoid reporting a second generic error when we've already reported that the file does not exist. For cases where the generic error is hit, reword it for clarity.
This commit is contained in:
1 parent
9018d8259b
commit
fe6b359067
7 files changed
+15
-4
No files matched your search
@@ -132,7 +132,9 @@ bool cmListFileParser::ParseFile()
|
||||
cmListFileLexer_BOM bom;
|
||||
if (!cmListFileLexer_SetFileName(this->Lexer.get(), filename->c_str(),
|
||||
&bom)) {
|
||||
this->IssueFileOpenError("cmListFileCache: error can not open file.");
|
||||
this->IssueFileOpenError(
|
||||
cmStrCat("Cannot open file \"", this->FileName,
|
||||
"\": ", cmSystemTools::GetLastSystemError()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -898,9 +898,10 @@ void cmake::ReadListFile(std::vector<std::string> const& args,
|
||||
}
|
||||
if (!cmSystemTools::FileExists(path, true)) {
|
||||
cmSystemTools::Error("Not a file: " + path);
|
||||
return;
|
||||
}
|
||||
if (!mf.ReadListFile(path)) {
|
||||
cmSystemTools::Error("Error processing file: " + path);
|
||||
cmSystemTools::Error("Failed to read file: " + path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
^CMake Error: Not a file: [^
|
||||
]*/Tests/RunCMake/CommandLine/P_no-file-build/nosuchscriptfile\.cmake
|
||||
CMake Error: Error processing file: [^
|
||||
]*/Tests/RunCMake/CommandLine/P_no-file-build/nosuchscriptfile\.cmake$
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,6 @@
|
||||
^CMake Error at [^
|
||||
]*/P_parse-error\.cmake:2:
|
||||
Parse error\. Function missing ending "\)"\. End of file reached\.
|
||||
+
|
||||
CMake Error: Failed to read file: [^
|
||||
]*/Tests/RunCMake/CommandLine/P_parse-error\.cmake$
|
||||
@@ -0,0 +1,2 @@
|
||||
message(STATUS "before")
|
||||
foo(
|
||||
@@ -123,6 +123,7 @@ run_cmake_command(G_no-arg ${CMAKE_COMMAND} -B DummyBuildDir -G)
|
||||
run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -B DummyBuildDir -G NoSuchGenerator)
|
||||
run_cmake_command(P_no-arg ${CMAKE_COMMAND} -P)
|
||||
run_cmake_command(P_no-file ${CMAKE_COMMAND} -P nosuchscriptfile.cmake)
|
||||
run_cmake_command(P_parse-error ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_parse-error.cmake")
|
||||
run_cmake_command(P_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_args.cmake" relative/path "${RunCMake_SOURCE_DIR}")
|
||||
run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO -S -B --fresh --version)
|
||||
run_cmake_command(P_P_in_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -P "${RunCMake_SOURCE_DIR}/non_existing.cmake")
|
||||
|
||||
Reference in new issue
Block a user