mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
Ninja: Regenerate when test or install scripts are missing
Rerun CMake when `cmake_install.cmake` or `CTestTestfile.cmake` are out of date. This enables regeneration if a subdirectory is removed before invoking `ninja`. Fixes: #26396
This commit is contained in:
@@ -4023,3 +4023,16 @@ void cmGlobalGenerator::AddInstallScript(std::string const& file)
|
||||
{
|
||||
this->InstallScripts.push_back(file);
|
||||
}
|
||||
|
||||
void cmGlobalGenerator::AddTestFile(std::string const& file)
|
||||
{
|
||||
this->TestFiles.push_back(file);
|
||||
}
|
||||
|
||||
void cmGlobalGenerator::AddCMakeFilesToRebuild(
|
||||
std::vector<std::string>& files) const
|
||||
{
|
||||
files.insert(files.end(), this->InstallScripts.begin(),
|
||||
this->InstallScripts.end());
|
||||
files.insert(files.end(), this->TestFiles.begin(), this->TestFiles.end());
|
||||
}
|
||||
|
@@ -675,6 +675,8 @@ public:
|
||||
bool CheckCMP0171() const;
|
||||
|
||||
void AddInstallScript(std::string const& file);
|
||||
void AddTestFile(std::string const& file);
|
||||
void AddCMakeFilesToRebuild(std::vector<std::string>& files) const;
|
||||
|
||||
protected:
|
||||
// for a project collect all its targets by following depend
|
||||
@@ -916,6 +918,7 @@ private:
|
||||
RuntimeDependencySetsByName;
|
||||
|
||||
std::vector<std::string> InstallScripts;
|
||||
std::vector<std::string> TestFiles;
|
||||
|
||||
#if !defined(CMAKE_BOOTSTRAP)
|
||||
// Pool of file locks
|
||||
|
@@ -3293,6 +3293,7 @@ void cmGlobalNinjaMultiGenerator::AddRebuildManifestOutputs(
|
||||
if (!this->DefaultFileConfig.empty()) {
|
||||
outputs.push_back(this->NinjaOutputPath(NINJA_BUILD_FILE));
|
||||
}
|
||||
this->AddCMakeFilesToRebuild(outputs);
|
||||
}
|
||||
|
||||
void cmGlobalNinjaMultiGenerator::GetQtAutoGenConfigs(
|
||||
|
@@ -382,6 +382,7 @@ public:
|
||||
virtual void AddRebuildManifestOutputs(cmNinjaDeps& outputs) const
|
||||
{
|
||||
outputs.push_back(this->NinjaOutputPath(NINJA_BUILD_FILE));
|
||||
this->AddCMakeFilesToRebuild(outputs);
|
||||
}
|
||||
|
||||
int GetRuleCmdLength(const std::string& name)
|
||||
|
@@ -366,6 +366,7 @@ void cmLocalGenerator::GenerateTestFiles()
|
||||
std::string file =
|
||||
cmStrCat(this->StateSnapshot.GetDirectory().GetCurrentBinary(),
|
||||
"/CTestTestfile.cmake");
|
||||
this->GlobalGenerator->AddTestFile(file);
|
||||
|
||||
cmGeneratedFileStream fout(file);
|
||||
|
||||
|
4
Tests/RunCMake/Configure/RerunCMake-build5-check.cmake
Normal file
4
Tests/RunCMake/Configure/RerunCMake-build5-check.cmake
Normal file
@@ -0,0 +1,4 @@
|
||||
file(READ ${stamp} content)
|
||||
if(NOT content STREQUAL 5)
|
||||
set(RunCMake_TEST_FAILED "Expected stamp '5' but got: '${content}'")
|
||||
endif()
|
@@ -37,6 +37,15 @@ block()
|
||||
set(RunCMake_TEST_OUTPUT_MERGE 0)
|
||||
run_cmake_command(RerunCMake-build4 ${CMAKE_COMMAND} --build .)
|
||||
endif()
|
||||
if(RunCMake_GENERATOR MATCHES "^Ninja")
|
||||
file(REMOVE "${error}")
|
||||
run_cmake(RerunCMake)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) # handle 1s resolution
|
||||
# remove cmake_install.cmake to trigger rerun
|
||||
file(REMOVE "${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake")
|
||||
file(WRITE "${input}" "5")
|
||||
run_cmake_command(RerunCMake-build5 ${CMAKE_COMMAND} --build .)
|
||||
endif()
|
||||
endblock()
|
||||
|
||||
block()
|
||||
|
Reference in New Issue
Block a user