ENH: add a rule to automatically re-run cmake from the top if the CMakeCache.txt file is changed

This commit is contained in:
Bill Hoffman 2002-12-05 14:56:31 -05:00
parent 83f596ee9d
commit 7985bc118e
2 changed files with 21 additions and 3 deletions

View File

@ -456,8 +456,18 @@ bool cmCacheManager::SaveCache(const char* path)
cmSystemTools::CopyFileIfDifferent(tempFile.c_str(),
cacheFile.c_str());
cmSystemTools::RemoveFile(tempFile.c_str());
return true;
std::string checkCacheFile = path;
checkCacheFile += "/cmake.check_cache";
std::ofstream checkCache(checkCacheFile.c_str());
if(!checkCache)
{
cmSystemTools::Error("Unable to open check cache file for write. ",
checkCacheFile.c_str());
return false;
}
checkCache << "# This file is generated by cmake for dependency checking of the CMakeCache.txt file\n";
return true;
}
void cmCacheManager::OutputHelpString(std::ofstream& fout,
const std::string& helpString)

View File

@ -215,12 +215,13 @@ void cmLocalUnixMakefileGenerator::OutputMakefile(const char* file,
fout << " " << cmSystemTools::ConvertToOutputPath(cacheFile.c_str());
fout << "\n\n\n";
this->OutputMakeVariables(fout);
// Set up the default target as the VERY first target, so that make with no arguments will run it
this->
OutputMakeRule(fout,
"Default target executed when no arguments are given to make, first make sure cmake.depends exists, cmake.check_depends is up-to-date, check the sources, then build the all target",
"default_target",
0,
"$(CMAKE_BINARY_DIR)/cmake.check_cache",
"$(MAKE) $(MAKESILENT) cmake.depends",
"$(MAKE) $(MAKESILENT) cmake.check_depends",
"$(MAKE) $(MAKESILENT) -f cmake.check_depends",
@ -1568,6 +1569,7 @@ void cmLocalUnixMakefileGenerator::OutputSubDirectoryRules(std::ostream& fout)
{
return;
}
this->OutputSubDirectoryVars(fout,
"SUBDIR_BUILD",
"default_target",
@ -2120,6 +2122,12 @@ void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
"$(CMAKE_BINARY_DIR)/CMakeCache.txt",
"$(CMAKE_COMMAND) "
"-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
this->OutputMakeRule(fout,
"CMakeCache.txt because out-of-date:",
"$(CMAKE_BINARY_DIR)/cmake.check_cache",
"$(CMAKE_BINARY_DIR)/CMakeCache.txt",
"$(CMAKE_COMMAND) "
"-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
// if CMAKE_EDIT_COMMAND is defined then add a rule to run it
// called edit_cache
if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))