mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-24 15:38:54 -06:00
Ninja: Fail early on when ninja build tool does not run
Diagnose failure to run `ninja --version` and abort early. Otherwise we end up aborting with a confusing message about ninja version "" being too old. Closes: #16378
This commit is contained in:
@@ -564,8 +564,17 @@ bool cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf)
|
|||||||
command.push_back(this->NinjaCommand);
|
command.push_back(this->NinjaCommand);
|
||||||
command.push_back("--version");
|
command.push_back("--version");
|
||||||
std::string version;
|
std::string version;
|
||||||
cmSystemTools::RunSingleCommand(command, &version, CM_NULLPTR, CM_NULLPTR,
|
std::string error;
|
||||||
CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
|
if (!cmSystemTools::RunSingleCommand(command, &version, &error, CM_NULLPTR,
|
||||||
|
CM_NULLPTR,
|
||||||
|
cmSystemTools::OUTPUT_NONE)) {
|
||||||
|
mf->IssueMessage(cmake::FATAL_ERROR, "Running\n '" +
|
||||||
|
cmJoin(command, "' '") + "'\n"
|
||||||
|
"failed with:\n " +
|
||||||
|
error);
|
||||||
|
cmSystemTools::SetFatalErrorOccured();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
this->NinjaVersion = cmSystemTools::TrimWhitespace(version);
|
this->NinjaVersion = cmSystemTools::TrimWhitespace(version);
|
||||||
this->CheckNinjaFeatures();
|
this->CheckNinjaFeatures();
|
||||||
}
|
}
|
||||||
|
|||||||
1
Tests/RunCMake/Ninja/NinjaToolMissing-result.txt
Normal file
1
Tests/RunCMake/Ninja/NinjaToolMissing-result.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
6
Tests/RunCMake/Ninja/NinjaToolMissing-stderr.txt
Normal file
6
Tests/RunCMake/Ninja/NinjaToolMissing-stderr.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
^CMake Error at CMakeLists.txt:[0-9]+ \(project\):
|
||||||
|
Running
|
||||||
|
|
||||||
|
'ninja-tool-missing' '--version'
|
||||||
|
|
||||||
|
failed with:
|
||||||
0
Tests/RunCMake/Ninja/NinjaToolMissing.cmake
Normal file
0
Tests/RunCMake/Ninja/NinjaToolMissing.cmake
Normal file
@@ -15,6 +15,12 @@ else()
|
|||||||
message(FATAL_ERROR "'ninja --version' reported:\n${ninja_out}")
|
message(FATAL_ERROR "'ninja --version' reported:\n${ninja_out}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
function(run_NinjaToolMissing)
|
||||||
|
set(RunCMake_MAKE_PROGRAM ninja-tool-missing)
|
||||||
|
run_cmake(NinjaToolMissing)
|
||||||
|
endfunction()
|
||||||
|
run_NinjaToolMissing()
|
||||||
|
|
||||||
function(run_CMP0058 case)
|
function(run_CMP0058 case)
|
||||||
# Use a single build tree for a few tests without cleaning.
|
# Use a single build tree for a few tests without cleaning.
|
||||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0058-${case}-build)
|
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0058-${case}-build)
|
||||||
|
|||||||
Reference in New Issue
Block a user